일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Series
- dataframe
- mariadb
- pycharm
- install
- pandas
- mean
- E-P1
- javascript
- GT-S80
- GitHub
- Python
- index
- DFS
- CNN
- 알고리즘
- LSTM
- 삼성소프트웨어멤버십
- SciPy
- keras
- Lotto
- ipad
- imread
- Numpy
- RNN
- pip
- Button
- SPL
- synology
- Splunk
Archives
- Today
- Total
잠토의 잠망경
nevron Chart 본문
neveron chart source code
using Nevron;
using Nevron.Chart;
using Nevron.Chart.Windows;
using Nevron.Dom;
using Nevron.GraphicsCore;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void GenerateData(NBubbleSeries m_Bubble)
{
m_Bubble.Values.Clear();
m_Bubble.XValues.Clear();
m_Bubble.ZValues.Clear();
m_Bubble.Sizes.Clear();
Random r = new Random();
for (int i = 0; i < 4; i++)
{
m_Bubble.Values.Add(r.NextDouble() * 5);
m_Bubble.XValues.Add(r.NextDouble() * 5);
m_Bubble.ZValues.Add(r.NextDouble() * 5);
m_Bubble.Sizes.Add(r.NextDouble());
}
}
public void DrawBar01()
{
nChartControl1.Clear();
// create a title
NLabel title = new NLabel("2D Bar Chart");
title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
// configure chart
NChart chart = nChartControl1.Charts[0];
chart.Axis(StandardAxis.Depth).Visible = false;
// add interlace stripe
NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);
stripStyle.Interlaced = true;
stripStyle.SetShowAtWall(ChartWallType.Back, true);
stripStyle.SetShowAtWall(ChartWallType.Left, true);
linearScale.StripStyles.Add(stripStyle);
// setup a bar series
NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
bar.Name = "Bar Series";
bar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);
bar.ShadowStyle.Type = ShadowType.GaussianBlur;
bar.ShadowStyle.Offset = new NPointL(2, 2);
bar.ShadowStyle.Color = Color.FromArgb(80, 0, 0, 0);
bar.ShadowStyle.FadeLength = new NLength(5);
bar.HasBottomEdge = false;
// add some data to the bar series
bar.AddDataPoint(new NDataPoint(18, "C++"));
bar.AddDataPoint(new NDataPoint(15, "Ruby"));
bar.AddDataPoint(new NDataPoint(21, "Python"));
bar.AddDataPoint(new NDataPoint(23, "Java"));
bar.AddDataPoint(new NDataPoint(27, "Javascript"));
bar.AddDataPoint(new NDataPoint(29, "C#"));
bar.AddDataPoint(new NDataPoint(26, "PHP"));
// apply layout
ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]);
NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.CoolMultiColor);
styleSheet.Apply(nChartControl1.Document);
// invert Y 축
{
NStandardScaleConfigurator scaleConfigurator = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
scaleConfigurator.Invert = true;
nChartControl1.Refresh();
}
// graph
{
NBarSeries mbar = (NBarSeries)nChartControl1.Charts[0].Series[0];
bar.WidthPercent = 10;
}
}
public void DrawBubble2()
{
nChartControl1.Clear();
nChartControl1.Controller.Tools.Add(new NPanelSelectorTool());
nChartControl1.Controller.Tools.Add(new NTrackballTool());
// set a chart title
NLabel title = new NLabel("XYZ Bubble Chart");
title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
// setup chart
NChart m_Chart = nChartControl1.Charts[0];
m_Chart.Enable3D = true;
m_Chart.Width = 50;
m_Chart.Depth = 50;
m_Chart.Height = 50;
m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);
m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft);
NLinearScaleConfigurator depthScale = new NLinearScaleConfigurator();
depthScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
depthScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
depthScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true);
m_Chart.Axis(StandardAxis.Depth).ScaleConfigurator = depthScale;
NLinearScaleConfigurator yScale = new NLinearScaleConfigurator();
yScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true);
// add interlace style
NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(new NArgbColor(Color.Beige)), null, true, 0, 0, 1, 1);
stripStyle.SetShowAtWall(ChartWallType.Back, true);
stripStyle.SetShowAtWall(ChartWallType.Left, true);
stripStyle.Interlaced = true;
yScale.StripStyles.Add(stripStyle);
m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = yScale;
// switch the x axis in linear mode
NLinearScaleConfigurator xScale = new NLinearScaleConfigurator();
xScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = xScale;
NBubbleSeries m_Bubble = (NBubbleSeries)m_Chart.Series.Add(SeriesType.Bubble);
m_Bubble.InflateMargins = true;
m_Bubble.DataLabelStyle.Visible = false;
m_Bubble.BubbleShape = PointShape.Sphere;
m_Bubble.Legend.Format = "x:<xvalue> y:<value> z:<zvalue> sz:<size>";
m_Bubble.Legend.Mode = SeriesLegendMode.DataPoints;
m_Bubble.MinSize = new NLength(10.0f, NRelativeUnit.ParentPercentage);
m_Bubble.MaxSize = new NLength(20.0f, NRelativeUnit.ParentPercentage);
m_Bubble.UseXValues = true;
m_Bubble.UseZValues = true;
m_Bubble.Values.ValueFormatter = new NNumericValueFormatter("0.#");
m_Bubble.XValues.ValueFormatter = new NNumericValueFormatter("0.#");
m_Bubble.ZValues.ValueFormatter = new NNumericValueFormatter("0.#");
m_Bubble.Sizes.ValueFormatter = new NNumericValueFormatter("0.#");
GenerateData(m_Bubble);
// apply layout
ConfigureStandardLayout(m_Chart, title, nChartControl1.Legends[0]);
// apply style sheet
NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.CoolMultiColor);
styleSheet.Apply(nChartControl1.Document);
}
public void DrawBubble1()
{
nChartControl1.Clear();
// set a chart title
NLabel title = nChartControl1.Labels.AddHeader("XY Bubble Chart");
title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
// setup chart
NChart m_Chart = nChartControl1.Charts[0];
NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
// add interlace style
NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(new NArgbColor(Color.Beige)), null, true, 0, 0, 1, 1);
stripStyle.SetShowAtWall(ChartWallType.Back, true);
stripStyle.SetShowAtWall(ChartWallType.Left, true);
stripStyle.Interlaced = true;
linearScale.StripStyles.Add(stripStyle);
linearScale = new NLinearScaleConfigurator();
m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale;
linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
NBubbleSeries m_Bubble = (NBubbleSeries)m_Chart.Series.Add(SeriesType.Bubble);
m_Bubble.DataLabelStyle.Visible = false;
m_Bubble.Legend.Format = "<label>";
m_Bubble.Legend.Mode = SeriesLegendMode.DataPoints;
m_Bubble.ShadowStyle.Type = ShadowType.Solid;
m_Bubble.ShadowStyle.Offset = new NPointL(1.2f, 1.2f);
m_Bubble.ShadowStyle.Color = Color.FromArgb(60, 0, 0, 0);
m_Bubble.UseXValues = true;
m_Bubble.AddDataPoint(new NBubbleDataPoint(27, 51, 4, "India"));
m_Bubble.AddDataPoint(new NBubbleDataPoint(50, 67, 5, "China"));
m_Bubble.AddDataPoint(new NBubbleDataPoint(76, 22, 6, "Mexico"));
m_Bubble.AddDataPoint(new NBubbleDataPoint(210, 9, 7, "Russia"));
m_Bubble.AddDataPoint(new NBubbleDataPoint(360, 4, 8, "USA"));
m_Bubble.AddDataPoint(new NBubbleDataPoint(470, 5, 9, "Canada"));
// apply layout
ConfigureStandardLayout(m_Chart, title, nChartControl1.Legends[0]);
// apply style sheet
NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.NevronMultiColor);
styleSheet.Apply(nChartControl1.Document);
// legend setting
{
m_Bubble.Legend.Format = String.Format("Size:<size> X:<xvalue> Y:<value> <label>");
nChartControl1.Refresh();
}
// invert Y 축
{
NStandardScaleConfigurator scaleConfigurator = (NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
scaleConfigurator.Invert = true;
nChartControl1.Refresh();
}
// invert X 축
{
NStandardScaleConfigurator scaleConfigurator = (NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;
scaleConfigurator.Invert = true;
nChartControl1.Refresh();
}
}
public void DrawBubble()
{
nChartControl1.Clear();
// title
NLabel title = nChartControl1.Labels.AddHeader("2D Bubble Chart");
title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
// configure the chart
NChart m_Chart = nChartControl1.Charts[0];
m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal);
m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft);
m_Chart.Axis(StandardAxis.Depth).Visible = false;
NLinearScaleConfigurator linearScale = m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
// add interlace stripe
NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);
stripStyle.Interlaced = true;
stripStyle.SetShowAtWall(ChartWallType.Back, true);
stripStyle.SetShowAtWall(ChartWallType.Left, true);
linearScale.StripStyles.Add(stripStyle);
NOrdinalScaleConfigurator ordinalScale = m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator;
ordinalScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
// add a bubble series
NBubbleSeries m_Bubble = (NBubbleSeries)m_Chart.Series.Add(SeriesType.Bubble);
m_Bubble.DataLabelStyle.VertAlign = VertAlign.Center;
m_Bubble.DataLabelStyle.Visible = false;
m_Bubble.Legend.Mode = SeriesLegendMode.DataPoints;
m_Bubble.MinSize = new NLength(7.0f, NRelativeUnit.ParentPercentage);
m_Bubble.MaxSize = new NLength(16.0f, NRelativeUnit.ParentPercentage);
m_Bubble.AddDataPoint(new NBubbleDataPoint(10, 10, "Company 1"));
m_Bubble.AddDataPoint(new NBubbleDataPoint(15, 20, "Company 2"));
m_Bubble.AddDataPoint(new NBubbleDataPoint(12, 25, "Company 3"));
m_Bubble.AddDataPoint(new NBubbleDataPoint(8, 15, "Company 4"));
m_Bubble.AddDataPoint(new NBubbleDataPoint(14, 17, "Company 5"));
m_Bubble.AddDataPoint(new NBubbleDataPoint(11, 12, "Company 6"));
// apply layout
ConfigureStandardLayout(m_Chart, title, nChartControl1.Legends[0]);
// init form controls
// 색상 변경
{
NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.CoolMultiColor);
styleSheet.Apply(nChartControl1.Document);
nChartControl1.Refresh();
}
// Margin
{
m_Bubble.InflateMargins = true;
nChartControl1.Refresh();
}
// legend setting
{
m_Bubble.Legend.Format = String.Format("<value>{0}<label>", "wonjae -> ");
nChartControl1.Refresh();
}
// invert
{
NStandardScaleConfigurator scaleConfigurator = (NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
scaleConfigurator.Invert = true;
nChartControl1.Refresh();
}
}
void ConfigureStandardLayout(NChart chart, NLabel title, NLegend legend)
{
nChartControl1.Panels.Clear();
if (title != null)
{
nChartControl1.Panels.Add(title);
title.DockMode = PanelDockMode.Top;
title.Padding = new NMarginsL(5, 8, 5, 4);
}
if (legend != null)
{
nChartControl1.Panels.Add(legend);
legend.DockMode = PanelDockMode.Right;
legend.Padding = new NMarginsL(1, 1, 5, 5);
}
if (chart != null)
{
nChartControl1.Panels.Add(chart);
float topPad = (title == null) ? 11 : 8;
float rightPad = (legend == null) ? 11 : 4;
if (chart.BoundsMode == BoundsMode.None)
{
if (chart.Enable3D || !(chart is NCartesianChart))
{
chart.BoundsMode = BoundsMode.Fit;
}
else
{
chart.BoundsMode = BoundsMode.Stretch;
}
}
chart.DockMode = PanelDockMode.Fill;
chart.Padding = new NMarginsL(
new NLength(11, NRelativeUnit.ParentPercentage),
new NLength(topPad, NRelativeUnit.ParentPercentage),
new NLength(rightPad, NRelativeUnit.ParentPercentage),
new NLength(11, NRelativeUnit.ParentPercentage));
}
}
private void button1_Click(object sender, EventArgs e)
{
DrawBubble();
}
private void button2_Click(object sender, EventArgs e)
{
DrawBubble1();
}
private void button3_Click(object sender, EventArgs e)
{
DrawBubble2();
}
private void button4_Click(object sender, EventArgs e)
{
DrawBar01();
}
}
}
Comments