//3D scatter chart creation\\ public void createChart(WinChartViewer viewer, int chartIndex) { int[] chartColor = new int[8] { 0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x55ffff, 0x888888, 0x111111 }; ThreeDScatterChart c = new ThreeDScatterChart(640, 480); for (int k = 0; k < cltr; k++) { RanSeries r = new RanSeries(k); Double[] xData = new Double[1]; Double[] yData = new Double[1]; Double[] zData = new Double[1]; xData = r.getSeries2(1, V[k, 0], 0, 0); yData = r.getSeries2(1, V[k, 1], 0, 0); zData = r.getSeries2(1, V[k, 2], 0, 0); c.addScatterGroup(xData, yData, zData, "", Chart.GlassSphere2Shape, 18, chartColor[k]); if (viewFuzzyBtn.Visible == true) { for (int i = 0; i < num / 2; i++) { if (custCltr[i] == k) { xData = r.getSeries2(1, X[i, 0], 0, 0); yData = r.getSeries2(1, X[i, 1], 0, 0); zData = r.getSeries2(1, X[i, 2], 0, 0); c.addScatterGroup(xData, yData, zData, "", Chart.GlassSphere2Shape, 12, chartColor[k]); } } c.addScatterGroup(xData, yData, zData, rfmv[k], Chart.GlassSphere2Shape, 12, chartColor[k]); c.addLegend(400, 10); } else { for (int i = 0; i < num / 2; i++) { if (custCltr[i] == k) { xData = r.getSeries2(1, X[i, 0] * temp10, 0, 0); yData = r.getSeries2(1, X[i, 1] * temp10, 0, 0); zData = r.getSeries2(1, X[i, 2] * temp10, 0, 0); c.addScatterGroup(xData, yData, zData, "", Chart.GlassSphere2Shape, 12, chartColor[k]); } } } } c.setPlotRegion(350, 225, 360, 360, 270); c.setViewAngle(15, 30); c.xAxis().setTitle("Recency"); c.yAxis().setTitle("Frequency"); c.zAxis().setTitle("Monetary"); viewer.Chart = c; viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='(x={x|p}, y={y|p}, z={z|p}'"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // Data for the chart as 2 random data series RanSeries r = new RanSeries(127); double[] data0 = r.getSeries(180, 10, -1.5, 1.5); double[] data1 = r.getSeries(180, 150, -15, 15); DateTime[] timeStamps = r.getDateSeries(180, new DateTime(2011, 1, 1), 86400); // Create a XYChart object of size 670 x 400 pixels XYChart c = new XYChart(670, 400); // Add a title to the chart using 18pt Times New Roman Bold Italic font c.addTitle("Plasma Stabilizer Energy Usage", "Times New Roman Bold Italic", 18); // Set the plotarea at (50, 55) with width 100 pixels less than chart width, and height 90 // pixels less than chart height. Use a vertical gradient from light blue (f0f6ff) to sky // blue (a0c0ff) as background. Set border to transparent and grid lines to white (ffffff). c.setPlotArea(50, 55, c.getWidth() - 100, c.getHeight() - 90, c.linearGradientColor(0, 55, 0, c.getHeight() - 35, 0xf0f6ff, 0xa0c0ff), -1, Chart.Transparent, 0xffffff, 0xffffff); // Add a legend box at (50, 25) using horizontal layout. Use 10pt Arial Bold as font. Set the // background and border color to Transparent. c.addLegend(50, 25, false, "Arial Bold", 10).setBackground(Chart.Transparent); // Set axis label style to 8pt Arial Bold c.xAxis().setLabelStyle("Arial Bold", 8); c.yAxis().setLabelStyle("Arial Bold", 8); c.yAxis2().setLabelStyle("Arial Bold", 8); // Set the axis stem to transparent c.xAxis().setColors(Chart.Transparent); c.yAxis().setColors(Chart.Transparent); c.yAxis2().setColors(Chart.Transparent); // Configure x-axis label format c.xAxis().setMultiFormat(Chart.StartOfYearFilter(), "{value|mm/yyyy} ", Chart.StartOfMonthFilter(), "{value|mm}"); // Add axis title using 10pt Arial Bold Italic font c.yAxis().setTitle("Power Usage (Watt)", "Arial Bold Italic", 10); c.yAxis2().setTitle("Effective Load (kg)", "Arial Bold Italic", 10); // Add a line layer to the chart using a line width of 2 pixels. LineLayer layer = c.addLineLayer2(); layer.setLineWidth(2); // Add 2 data series to the line layer layer.setXData(timeStamps); layer.addDataSet(data0, 0xcc0000, "Power Usage"); layer.addDataSet(data1, 0x008800, "Effective Load").setUseYAxis2(); // Output the chart viewer.Image = c.makeWebImage(Chart.PNG); // Output Javascript chart model to the browser to suppport tracking cursor viewer.ChartModel = c.getJsChartModel(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { // Data for the chart as 3 random data series RanSeries r = new RanSeries(127); double[] data0 = r.getSeries(100, 100, -15, 15); double[] data1 = r.getSeries(100, 150, -15, 15); double[] data2 = r.getSeries(100, 200, -15, 15); DateTime[] timeStamps = r.getDateSeries(100, new DateTime(2011, 1, 1), 86400); // Create a XYChart object of size 640 x 400 pixels XYChart c = new XYChart(640, 400); // Add a title to the chart using 18pt Times New Roman Bold Italic font c.addTitle(" Product Line Global Revenue", "Times New Roman Bold Italic", 18); // Set the plotarea at (50, 55) with width 70 pixels less than chart width, and height 90 pixels // less than chart height. Use a vertical gradient from light blue (f0f6ff) to sky blue (a0c0ff) // as background. Set border to transparent and grid lines to white (ffffff). c.setPlotArea(50, 55, c.getWidth() - 70, c.getHeight() - 90, c.linearGradientColor(0, 55, 0, c.getHeight() - 35, 0xf0f6ff, 0xa0c0ff), -1, Chart.Transparent, 0xffffff, 0xffffff); // Set legend icon style to use line style icon, sized for 8pt font c.getLegend().setLineStyleKey(); c.getLegend().setFontSize(8); // Set axis label style to 8pt Arial Bold c.xAxis().setLabelStyle("Arial Bold", 8); c.yAxis().setLabelStyle("Arial Bold", 8); // Set the axis stem to transparent c.xAxis().setColors(Chart.Transparent); c.yAxis().setColors(Chart.Transparent); // Configure x-axis label format c.xAxis().setMultiFormat(Chart.StartOfYearFilter(), "{value|mm/yyyy} ", Chart.StartOfMonthFilter( ), "{value|mm}"); // Add axis title using 10pt Arial Bold Italic font c.yAxis().setTitle("USD millions", "Arial Bold Italic", 10); // Add a line layer to the chart using a line width of 2 pixels. LineLayer layer = c.addLineLayer2(); layer.setLineWidth(2); // Add 3 data series to the line layer layer.setXData(timeStamps); layer.addDataSet(data0, 0xff3333, "Alpha"); layer.addDataSet(data1, 0x008800, "Beta"); layer.addDataSet(data2, 0x3333cc, "Gamma"); // Include track line with legend for the latest data values trackLineLegend(c, c.getPlotArea().getRightX()); // Assign the chart to the WPFChartViewer WPFChartViewer1.Chart = c; }
//Main code for creating charts public void createChart(WinChartViewer viewer, int chartIndex) { // The x and y coordinates of the grid double[] dataX = { -4, -3, -2, -1, 0, 1, 2, 3, 4 }; double[] dataY = { -4, -3, -2, -1, 0, 1, 2, 3, 4 }; // Use random numbers for the z values on the XY grid RanSeries r = new RanSeries(99); double[] dataZ = r.get2DSeries(dataX.Length, dataY.Length, -0.9, 0.9); // Create a XYChart object of size 420 x 360 pixels XYChart c = new XYChart(420, 360); // Set the plotarea at (30, 25) and of size 300 x 300 pixels. Use semi-transparent grey // (0xdd000000) horizontal and vertical grid lines c.setPlotArea(30, 25, 300, 300, -1, -1, -1, unchecked ((int)0xdd000000), -1); // Set the x-axis and y-axis scale c.xAxis().setLinearScale(-4, 4, 1); c.yAxis().setLinearScale(-4, 4, 1); // Add a contour layer using the given data ContourLayer layer = c.addContourLayer(dataX, dataY, dataZ); // Move the grid lines in front of the contour layer c.getPlotArea().moveGridBefore(layer); // Add a color axis (the legend) in which the top left corner is anchored at (350, 25). // Set the length to 400 300 and the labels on the right side. ColorAxis cAxis = layer.setColorAxis(350, 25, Chart.TopLeft, 300, Chart.Right); if (chartIndex == 1) { // Speicify a color gradient as a list of colors, and use it in the color axis. int[] colorGradient = { 0x0044cc, 0xffffff, 0x00aa00 }; cAxis.setColorGradient(false, colorGradient); } else if (chartIndex == 2) { // Specify the color scale to use in the color axis double[] colorScale = { -1.0, 0x1a9850, -0.75, 0x66bd63, -0.5, 0xa6d96a, -0.25, 0xd9ef8b, 0, 0xfee08b, 0.25, 0xfdae61, 0.5, 0xf46d43,0.75, 0xd73027, 1 }; cAxis.setColorScale(colorScale); } else if (chartIndex == 3) { // Specify the color scale to use in the color axis. Also specify an underflow color // 0x66ccff (blue) for regions that fall below the lower axis limit. double[] colorScale = { 0, 0xffff99, 0.2, 0x80cdc1, 0.4, 0x35978f, 0.6, 0x01665e, 0.8, 0x003c30, 1 }; cAxis.setColorScale(colorScale, 0x66ccff); } // Output the chart viewer.Chart = c; }
// // Load the data // private void loadData() { // In this example, we just use random numbers as data. RanSeries r = new RanSeries(127); timeStamps = r.getDateSeries(1827, new DateTime(2007, 1, 1), 86400); dataSeriesA = r.getSeries2(1827, 150, -10, 10); dataSeriesB = r.getSeries2(1827, 200, -10, 10); dataSeriesC = r.getSeries2(1827, 250, -8, 8); }
//Main code for creating chart. //Note: the argument chartIndex is unused because this demo only has 1 chart. public void createChart(WPFChartViewer viewer, int chartIndex) { // The random XYZ data for the first 3D scatter group RanSeries r0 = new RanSeries(7); double[] xData0 = r0.getSeries2(100, 100, -10, 10); double[] yData0 = r0.getSeries2(100, 0, 0, 20); double[] zData0 = r0.getSeries2(100, 100, -10, 10); // The random XYZ data for the second 3D scatter group RanSeries r1 = new RanSeries(4); double[] xData1 = r1.getSeries2(100, 100, -10, 10); double[] yData1 = r1.getSeries2(100, 0, 0, 20); double[] zData1 = r1.getSeries2(100, 100, -10, 10); // The random XYZ data for the third 3D scatter group RanSeries r2 = new RanSeries(8); double[] xData2 = r2.getSeries2(100, 100, -10, 10); double[] yData2 = r2.getSeries2(100, 0, 0, 20); double[] zData2 = r2.getSeries2(100, 100, -10, 10); // Create a ThreeDScatterChart object of size 800 x 520 pixels ThreeDScatterChart c = new ThreeDScatterChart(800, 520); // Add a title to the chart using 20 points Times New Roman Italic font c.addTitle("3D Scatter Groups ", "Times New Roman Italic", 20); // Set the center of the plot region at (350, 240), and set width x depth x height to // 360 x 360 x 270 pixels c.setPlotRegion(350, 240, 360, 360, 270); // Set the elevation and rotation angles to 15 and 30 degrees c.setViewAngle(15, 30); // Add a legend box at (640, 180) c.addLegend(640, 180); // Add 3 scatter groups to the chart with 9 pixels glass sphere symbols of red (ff0000), // green (00ff00) and blue (0000ff) colors c.addScatterGroup(xData0, yData0, zData0, "Alpha", Chart.GlassSphere2Shape, 9, 0xff0000) ; c.addScatterGroup(xData1, yData1, zData1, "Beta", Chart.GlassSphere2Shape, 9, 0x00ff00); c.addScatterGroup(xData2, yData2, zData2, "Gamma", Chart.GlassSphere2Shape, 9, 0x0000ff) ; // Set the x, y and z axis titles c.xAxis().setTitle("X-Axis Place Holder"); c.yAxis().setTitle("Y-Axis Place Holder"); c.zAxis().setTitle("Z-Axis Place Holder"); // Output the chart viewer.Chart = c; }
// // Create chart // private void createChart(RazorChartViewer viewer) { // Data for the chart as 3 random data series RanSeries r = new RanSeries(127); double[] data0 = r.getSeries(100, 100, -15, 15); double[] data1 = r.getSeries(100, 150, -15, 15); double[] data2 = r.getSeries(100, 200, -15, 15); DateTime[] timeStamps = r.getDateSeries(100, new DateTime(2011, 1, 1), 86400); // Create a XYChart object of size 640 x 400 pixels XYChart c = new XYChart(640, 400); // Add a title to the chart using 18pt Times New Roman Bold Italic font c.addTitle(" Product Line Global Revenue", "Times New Roman Bold Italic", 18); // Set the plotarea at (50, 55) with width 70 pixels less than chart width, and height 90 // pixels less than chart height. Use a vertical gradient from light blue (f0f6ff) to sky // blue (a0c0ff) as background. Set border to transparent and grid lines to white (ffffff). c.setPlotArea(50, 55, c.getWidth() - 70, c.getHeight() - 90, c.linearGradientColor(0, 55, 0, c.getHeight() - 35, 0xf0f6ff, 0xa0c0ff), -1, Chart.Transparent, 0xffffff, 0xffffff); // Set axis label style to 8pt Arial Bold c.xAxis().setLabelStyle("Arial Bold", 8); c.yAxis().setLabelStyle("Arial Bold", 8); // Set the axis stem to transparent c.xAxis().setColors(Chart.Transparent); c.yAxis().setColors(Chart.Transparent); // Configure x-axis label format c.xAxis().setMultiFormat(Chart.StartOfYearFilter(), "{value|mm/yyyy} ", Chart.StartOfMonthFilter(), "{value|mm}"); // Add axis title using 10pt Arial Bold Italic font c.yAxis().setTitle("USD millions", "Arial Bold Italic", 10); // Add a line layer to the chart using a line width of 2 pixels. LineLayer layer = c.addLineLayer2(); layer.setLineWidth(2); // Add 3 data series to the line layer layer.setXData(timeStamps); layer.addDataSet(data0, 0xff3333, "Alpha"); layer.addDataSet(data1, 0x008800, "Beta"); layer.addDataSet(data2, 0x3333cc, "Gamma"); // Output the chart viewer.Image = c.makeWebImage(Chart.PNG); // Output Javascript chart model to the browser to suppport tracking cursor viewer.ChartModel = c.getJsChartModel(); }
//Main code for creating chart. //Note: the argument chartIndex is unused because this demo only has 1 chart. public void createChart(WinChartViewer viewer, int chartIndex) { // The XYZ data for the 3D scatter chart as 3 random data series RanSeries r = new RanSeries(3); double[] xData = r.getSeries2(20, 100, -10, 10); double[] yData = r.getSeries2(20, 100, -10, 10); double[] zData = r.getSeries2(20, 100, -10, 10); // Create a ThreeDScatterChart object of size 720 x 520 pixels ThreeDScatterChart c = new ThreeDScatterChart(720, 520); // Add a title to the chart using 20 points Times New Roman Italic font c.addTitle("3D Scatter Chart (2) ", "Times New Roman Italic", 20); // Set the center of the plot region at (350, 240), and set width x depth x height to // 360 x 360 x 270 pixels c.setPlotRegion(350, 240, 360, 360, 270); // Set the elevation and rotation angles to 15 and 30 degrees c.setViewAngle(15, 30); // Add a scatter group to the chart using 13 pixels glass sphere symbols, in which the // color depends on the z value of the symbol ThreeDScatterGroup g = c.addScatterGroup(xData, yData, zData, "", Chart.GlassSphere2Shape, 13, Chart.SameAsMainColor); // Add grey (888888) drop lines to the symbols g.setDropLine(0x888888); // Add a color axis (the legend) in which the left center is anchored at (645, 220). Set // the length to 200 pixels and the labels on the right side. Use smooth gradient // coloring. c.setColorAxis(645, 220, Chart.Left, 200, Chart.Right).setColorGradient(); // Set the x, y and z axis titles using 10 points Arial Bold font c.xAxis().setTitle("X-Axis Place Holder", "Arial Bold", 10); c.yAxis().setTitle("Y-Axis Place Holder", "Arial Bold", 10); c.zAxis().setTitle("Z-Axis Place Holder", "Arial Bold", 10); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='(x={x|p}, y={y|p}, z={z|p}'"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // The XYZ data for the 3D scatter chart as 3 random data series RanSeries r = new RanSeries(0); double[] xData = r.getSeries2(100, 100, -10, 10); double[] yData = r.getSeries2(100, 0, 0, 20); double[] zData = r.getSeries2(100, 100, -10, 10); // Create a ThreeDScatterChart object of size 720 x 600 pixels ThreeDScatterChart c = new ThreeDScatterChart(720, 600); // Add a title to the chart using 20 points Times New Roman Italic font c.addTitle("3D Scatter Chart (1) ", "Times New Roman Italic", 20); // Set the center of the plot region at (350, 280), and set width x depth x height to 360 x // 360 x 270 pixels c.setPlotRegion(350, 280, 360, 360, 270); // Add a scatter group to the chart using 11 pixels glass sphere symbols, in which the color // depends on the z value of the symbol c.addScatterGroup(xData, yData, zData, "", Chart.GlassSphere2Shape, 11, Chart.SameAsMainColor ); // Add a color axis (the legend) in which the left center is anchored at (645, 270). Set the // length to 200 pixels and the labels on the right side. c.setColorAxis(645, 270, Chart.Left, 200, Chart.Right); // Set the x, y and z axis titles using 10 points Arial Bold font c.xAxis().setTitle("X-Axis Place Holder", "Arial Bold", 10); c.yAxis().setTitle("Y-Axis Place Holder", "Arial Bold", 10); c.zAxis().setTitle("Z-Axis Place Holder", "Arial Bold", 10); // Output the chart viewer.Image = c.makeWebImage(Chart.PNG); // Include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("", "", "title='(x={x|p}, y={y|p}, z={z|p}'"); }
//Main code for creating chart. //Note: the argument chartIndex is unused because this demo only has 1 chart. public void createChart(WinChartViewer viewer, int chartIndex) { // In this example, we simply use random data for the 3 data series. RanSeries r = new RanSeries(129); double[] data0 = r.getSeries(100, 100, -15, 15); double[] data1 = r.getSeries(100, 160, -15, 15); double[] data2 = r.getSeries(100, 220, -15, 15); DateTime[] timeStamps = r.getDateSeries(100, new DateTime(2014, 1, 1), 86400); // Create a XYChart object of size 600 x 400 pixels XYChart c = new XYChart(600, 400); // Set default text color to dark grey (0x333333) c.setColor(Chart.TextColor, 0x333333); // Add a title box using grey (0x555555) 20pt Arial font c.addTitle(" Multi-Line Chart Demonstration", "Arial", 20, 0x555555); // Set the plotarea at (70, 70) and of size 500 x 300 pixels, with transparent // background and border and light grey (0xcccccc) horizontal grid lines c.setPlotArea(70, 70, 500, 300, Chart.Transparent, -1, Chart.Transparent, 0xcccccc); // Add a legend box with horizontal layout above the plot area at (70, 35). Use 12pt // Arial font, transparent background and border, and line style legend icon. LegendBox b = c.addLegend(70, 35, false, "Arial", 12); b.setBackground(Chart.Transparent, Chart.Transparent); b.setLineStyleKey(); // Set axis label font to 12pt Arial c.xAxis().setLabelStyle("Arial", 12); c.yAxis().setLabelStyle("Arial", 12); // Set the x and y axis stems to transparent, and the x-axis tick color to grey // (0xaaaaaa) c.xAxis().setColors(Chart.Transparent, Chart.TextColor, Chart.TextColor, 0xaaaaaa); c.yAxis().setColors(Chart.Transparent); // Set the major/minor tick lengths for the x-axis to 10 and 0. c.xAxis().setTickLength(10, 0); // For the automatic axis labels, set the minimum spacing to 80/40 pixels for the x/y // axis. c.xAxis().setTickDensity(80); c.yAxis().setTickDensity(40); // Add a title to the y axis using dark grey (0x555555) 14pt Arial font c.yAxis().setTitle("Y-Axis Title Placeholder", "Arial", 14, 0x555555); // Add a line layer to the chart with 3-pixel line width LineLayer layer = c.addLineLayer2(); layer.setLineWidth(3); // Add 3 data series to the line layer layer.addDataSet(data0, 0x5588cc, "Alpha"); layer.addDataSet(data1, 0xee9944, "Beta"); layer.addDataSet(data2, 0x99bb55, "Gamma"); // The x-coordinates for the line layer layer.setXData(timeStamps); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='[{x|mm/dd/yyyy}] {dataSetName}: {value}'"); }
//Main code for creating chart. //Note: the argument chartIndex is unused because this demo only has 1 chart. public void createChart(WinChartViewer viewer, int chartIndex) { // // This example demonstrates creating a histogram with a bell curve from raw data. About // half of the code is to sort the raw data into slots and to generate the points on the // bell curve. The remaining half of the code is the actual charting code. // // Generate a random guassian distributed data series as the input data for this // example. RanSeries r = new RanSeries(66); double[] samples = r.getGaussianSeries(200, 100, 10); // // Classify the numbers into slots. In this example, the slot width is 5 units. // int slotSize = 5; // Compute the min and max values, and extend them to the slot boundary. ArrayMath m = new ArrayMath(samples); double minX = Math.Floor(m.min() / slotSize) * slotSize; double maxX = Math.Floor(m.max() / slotSize) * slotSize + slotSize; // We can now determine the number of slots int slotCount = (int)((maxX - minX + 0.5) / slotSize); double[] frequency = new double[slotCount]; // Count the data points contained in each slot for (int i = 0; i < samples.Length; ++i) { int slotIndex = (int)((samples[i] - minX) / slotSize); frequency[slotIndex] = frequency[slotIndex] + 1; } // // Compute Normal Distribution Curve // // The mean and standard deviation of the data double mean = m.avg(); double stdDev = m.stdDev(); // The normal distribution curve (bell curve) is a standard statistics curve. We need to // vertically scale it to make it proportion to the frequency count. double scaleFactor = slotSize * samples.Length / stdDev / Math.Sqrt(6.2832); // In this example, we plot the bell curve up to 3 standard deviations. double stdDevWidth = 3.0; // We generate 4 points per standard deviation to be joined with a spline curve. int bellCurveResolution = (int)(stdDevWidth * 4 + 1); double[] bellCurve = new double[bellCurveResolution]; for (int i = 0; i < bellCurveResolution; ++i) { double z = 2 * i * stdDevWidth / (bellCurveResolution - 1) - stdDevWidth; bellCurve[i] = Math.Exp(-z * z / 2) * scaleFactor; } // // At this stage, we have obtained all data and can plot the chart. // // Create a XYChart object of size 600 x 360 pixels XYChart c = new XYChart(600, 360); // Set the plotarea at (50, 30) and of size 500 x 300 pixels, with transparent // background and border and light grey (0xcccccc) horizontal grid lines c.setPlotArea(50, 30, 500, 300, Chart.Transparent, -1, Chart.Transparent, 0xcccccc); // Display the mean and standard deviation on the chart c.addTitle("Mean = " + c.formatValue(mean, "{value|1}") + ", Standard Deviation = " + c.formatValue(stdDev, "{value|2}"), "Arial"); // Set the x and y axis label font to 12pt Arial c.xAxis().setLabelStyle("Arial", 12); c.yAxis().setLabelStyle("Arial", 12); // Set the x and y axis stems to transparent, and the x-axis tick color to grey // (0x888888) c.xAxis().setColors(Chart.Transparent, Chart.TextColor, Chart.TextColor, 0x888888); c.yAxis().setColors(Chart.Transparent); // Draw the bell curve as a spline layer in red (0xdd0000) with 2-pixel line width SplineLayer bellLayer = c.addSplineLayer(bellCurve, 0xdd0000); bellLayer.setXData2(mean - stdDevWidth * stdDev, mean + stdDevWidth * stdDev); bellLayer.setLineWidth(2); // No tooltip is needed for the spline layer bellLayer.setHTMLImageMap("{disable}"); // Draw the histogram as bars in blue (0x6699bb) with dark blue (0x336688) border BarLayer histogramLayer = c.addBarLayer(frequency, 0x6699bb); histogramLayer.setBorderColor(0x336688); // The center of the bars span from minX + half_bar_width to maxX - half_bar_width histogramLayer.setXData2(minX + slotSize / 2.0, maxX - slotSize / 2.0); // Configure the bars to touch each other with no gap in between histogramLayer.setBarGap(Chart.TouchBar); // Use rounded corners for decoration histogramLayer.setRoundedCorners(); // Tool tip for the histogram histogramLayer.setHTMLImageMap("", "", "title='{value}'"); // ChartDirector by default will extend the x-axis scale by 0.5 unit to cater for the // bar width. It is because a bar plotted at x actually occupies (x +/- half_bar_width), // and the bar width is normally 1 for label based x-axis. However, this chart is using // a linear x-axis instead of label based. So we disable the automatic extension and add // a dummy layer to extend the x-axis scale to cover minX to maxX. c.xAxis().setIndent(false); c.addLineLayer2().setXData(minX, maxX); // For the automatic y-axis labels, set the minimum spacing to 40 pixels. c.yAxis().setTickDensity(40); // Output the chart viewer.Chart = c; // Include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // In this example, we simply use random data for the 2 data series. RanSeries r = new RanSeries(127); double[] data0 = r.getSeries(180, 70, -5, 5); double[] data1 = r.getSeries(180, 150, -15, 15); DateTime[] timeStamps = r.getDateSeries(180, new DateTime(2014, 3, 1), 86400); // Create a XYChart object of size 640 x 420 pixels XYChart c = new XYChart(640, 420); // Add a title to the chart using 20pt Arial font c.addTitle(" Plasma Stabilizer Energy Usage", "Arial", 20); // Set the plotarea at (55, 60) and of size 560 x 330 pixels, with transparent background and // border and light grey (0xcccccc) horizontal grid lines c.setPlotArea(55, 60, 560, 330, -1, -1, Chart.Transparent, 0xcccccc); // Add a legend box at (55, 30) using horizontal layout, with 10pt Arial Bold as font and // transparent background and border. c.addLegend(55, 30, false, "Arial Bold", 10).setBackground(Chart.Transparent); // Set axis label style to 10pt Arial c.xAxis().setLabelStyle("Arial", 10); c.yAxis().setLabelStyle("Arial", 10); // Set the x and y axis stems to transparent, and the x-axis tick color to grey (0xcccccc) c.xAxis().setColors(Chart.Transparent, Chart.TextColor, Chart.TextColor, 0xcccccc); c.yAxis().setColors(Chart.Transparent); // Configure the x-axis tick lengtht to 10 pixels internal to the plot area c.xAxis().setTickLength(-10, 0); // With the ticks internal to the plot area, the x-axis labels will come very close to the // axis stem, so we configure a wider gap. c.xAxis().setLabelGap(10); // For the automatic axis labels, set the minimum spacing to 80/40 pixels for the x/y axis. c.xAxis().setTickDensity(80); c.yAxis().setTickDensity(40); // Use "mm/yyyy" as the x-axis label format for the first plotted month of a year, and "mm" // for other months c.xAxis().setMultiFormat(Chart.StartOfYearFilter(), "{value|mm/yyyy} ", Chart.StartOfMonthFilter(), "{value|mm}"); // Add a title to the y axis using dark grey (0x555555) 12pt Arial Bold font c.yAxis().setTitle("Energy (kWh)", "Arial Bold", 14, 0x555555); // Add a line layer with 2-pixel line width LineLayer layer0 = c.addLineLayer(data0, 0xcc0000, "Power Usage"); layer0.setXData(timeStamps); layer0.setLineWidth(2); // Add an area layer using semi-transparent blue (0x7f0044cc) as the fill color AreaLayer layer1 = c.addAreaLayer(data1, 0x7f0044cc, "Effective Load"); layer1.setXData(timeStamps); layer1.setBorderColor(Chart.SameAsMainColor); // Output the chart viewer.Image = c.makeWebImage(Chart.PNG); // Output Javascript chart model to the browser to suppport tracking cursor viewer.ChartModel = c.getJsChartModel(); }
//Main code for creating chart. //Note: the argument chartIndex is unused because this demo only has 1 chart. public void createChart(WPFChartViewer viewer, int chartIndex) { // In this example, we simply use random data for the 2 data series. RanSeries r = new RanSeries(127); double[] data0 = r.getSeries(180, 70, -5, 5); double[] data1 = r.getSeries(180, 150, -15, 15); DateTime[] timeStamps = r.getDateSeries(180, new DateTime(2014, 3, 1), 86400); // Create a XYChart object of size 640 x 420 pixels XYChart c = new XYChart(640, 420); // Set default text color to dark grey (0x333333) c.setColor(Chart.TextColor, 0x333333); // Add a title box using grey (0x555555) 20pt Arial Bold font c.addTitle(" Plasma Stabilizer Energy Usage", "Arial Bold", 20, 0x555555); // Set the plotarea at (70, 70) and of size 540 x 320 pixels, with transparent // background and border and light grey (0xcccccc) horizontal grid lines c.setPlotArea(70, 70, 540, 320, -1, -1, Chart.Transparent, 0xcccccc); // Add a legend box with horizontal layout above the plot area at (70, 32). Use 12pt // Arial Bold dark grey (0x555555) font, transparent background and border, and line // style legend icon. LegendBox b = c.addLegend(70, 32, false, "Arial Bold", 12); b.setFontColor(0x555555); b.setBackground(Chart.Transparent, Chart.Transparent); b.setLineStyleKey(); // Set axis label font to 12pt Arial c.xAxis().setLabelStyle("Arial", 12); c.yAxis().setLabelStyle("Arial", 12); // Set the x and y axis stems to transparent, and the x-axis tick color to grey // (0xaaaaaa) c.xAxis().setColors(Chart.Transparent, Chart.TextColor, Chart.TextColor, 0xaaaaaa); c.yAxis().setColors(Chart.Transparent); // Set the major/minor tick lengths for the x-axis to 10 and 0. c.xAxis().setTickLength(10, 0); // For the automatic axis labels, set the minimum spacing to 80/40 pixels for the x/y // axis. c.xAxis().setTickDensity(80); c.yAxis().setTickDensity(40); // Use "mm/yyyy" as the x-axis label format for the first plotted month of a year, and // "mm" for other months c.xAxis().setMultiFormat(Chart.StartOfYearFilter(), "{value|mm/yyyy} ", Chart.StartOfMonthFilter(), "{value|mm}"); // Add a title to the y axis using dark grey (0x555555) 12pt Arial Bold font c.yAxis().setTitle("Energy (kWh)", "Arial Bold", 14, 0x555555); // Add a line layer with 2-pixel line width LineLayer layer0 = c.addLineLayer(data0, 0xcc0000, "Power Usage"); layer0.setXData(timeStamps); layer0.setLineWidth(2); // Add an area layer using semi-transparent blue (0x7f0044cc) as the fill color AreaLayer layer1 = c.addAreaLayer(data1, 0x7f0044cc, "Effective Load"); layer1.setXData(timeStamps); layer1.setBorderColor(Chart.SameAsMainColor); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='[{x|mm dd, yyyy}] {value} kWh'"); }
//Main code for creating chart. //Note: the argument chartIndex is unused because this demo only has 1 chart. public void createChart(WinChartViewer viewer, int chartIndex) { // getSeries2(int len, double startValue, double mindelta, double maxdelta) // The random XYZ data for the first 3D scatter group //빨강 RanSeries r0 = new RanSeries(1); double[] xData0 = { 0, 0, 0, 0 }; //r0.getSeries2(10, 10, -10, 10); // 첫번째 값은 double[] yData0 = { 0, 0, 0, 0 }; //r0.getSeries2(10, 0, 0, 20); double[] zData0 = { 0, 0, 0, 0 }; //r0.getSeries2(10, 10, -10, 10); //double[] xData0 = r0.getSeries2(20, 1, 0, 0); // X축 //double[] yData0 = r0.getSeries2(20, 1, 0, 0); // y축 //double[] zData0 = r0.getSeries2(20, 1, 0, 0); // z축 // The random XYZ data for the second 3D scatter group //초록 RanSeries r1 = new RanSeries(1); double[] xData1 = { 100, 100, 100, 100 }; double[] yData1 = { 100, 100, 100, 100 }; double[] zData1 = { 100, 100, 100, 100 }; // The random XYZ data for the third 3D scatter group //파랑 RanSeries r2 = new RanSeries(1); double[] xData2 = { 50, 50, 50, 50 }; double[] yData2 = { 50, 50, 50, 50 }; double[] zData2 = { 50, 50, 50, 50 }; // Create a ThreeDScatterChart object of size 800 x 520 pixels ThreeDScatterChart c = new ThreeDScatterChart(500, 300); // Add a title to the chart using 20 points Times New Roman Italic font c.addTitle("3D Scatter Groups", "Times New Roman Italic", 20); // Set the center of the plot region at (350, 240), and set width x depth x height to // 360 x 360 x 270 pixels c.setPlotRegion(210, 144, 216, 216, 144);// 차트 크기조절 // Set the elevation and rotation angles to 15 and 30 degrees c.setViewAngle(15, 30); // Add a legend box at (640, 180) c.addLegend(400, 180);//그룹박스 위치 // Add 3 scatter groups to the chart with 9 pixels glass sphere symbols of red (ff0000), // green (00ff00) and blue (0000ff) colors c.addScatterGroup(xData0, yData0, zData0, "Alpha", Chart.GlassSphere2Shape, 0, 0xff0000); // 8은 좌표에 표시되는 점 크기 표시 c.addScatterGroup(xData1, yData1, zData1, "Beta", Chart.GlassSphere2Shape, 0, 0x00ff00); c.addScatterGroup(xData2, yData2, zData2, "Gamma", Chart.GlassSphere2Shape, 8, 0x0000ff); // Set the x, y and z axis titles c.xAxis().setTitle("X-Axis Place Holder 가"); c.yAxis().setTitle("Y-Axis Place Holder 나"); c.zAxis().setTitle("Z-Axis Place Holder 다"); // Output the chart viewer.Chart = c; }
//Main code for creating chart. //Note: the argument chartIndex is unused because this demo only has 1 chart. public void createChart(WPFChartViewer viewer, int chartIndex) { // The x and y coordinates of the grid double[] dataX = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; double[] dataY = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // Use random numbers for the z values on the XY grid RanSeries r = new RanSeries(999); double[] dataZ = r.get2DSeries(dataX.Length, dataY.Length, -0.9, 1.15); // Create a XYChart object of size 640 x 460 pixels XYChart c = new XYChart(640, 460); // Set default text color to dark grey (0x333333) c.setColor(Chart.TextColor, 0x333333); // Set the plotarea at (30, 25) and of size 400 x 400 pixels. Use semi-transparent grey // (0xdd000000) horizontal and vertical grid lines c.setPlotArea(50, 25, 400, 400, -1, -1, Chart.Transparent, unchecked ((int)0xdd000000), -1); // Set the x and y axis stems to transparent and the label font to 12pt Arial c.xAxis().setColors(Chart.Transparent); c.yAxis().setColors(Chart.Transparent); c.xAxis().setLabelStyle("Arial", 12); c.yAxis().setLabelStyle("Arial", 12); // Set the x-axis and y-axis scale c.xAxis().setLinearScale(0, 10, 1); c.yAxis().setLinearScale(0, 10, 1); // Add a contour layer using the given data ContourLayer layer = c.addContourLayer(dataX, dataY, dataZ); // Move the grid lines in front of the contour layer c.getPlotArea().moveGridBefore(layer); // Define the color scale double[] colorScale = { -0.8, 0x0066ff, -0.5, 0x66ccff, -0.3, 0x66ffff, 0, 0x88ff88, 0.4, 0x00ff00, 0.7, 0xffff00, 0.9, 0xff6600, 1.0, 0xcc0000, 1.1 }; // Apply the color scale, and specify the underflow and overflow colors for regions // exceeding the color scale layer.colorAxis().setColorScale(colorScale, 0x0000cc, 0x000000); // // Instead of displaying the color axis, we use a legend box to display the colors. This // is useful for colors that are unevenly spaced on the color axis. // // Add a legend box at (460, 25) with vertical layout, with 12pt Arial font, transparent // background and border, icon size of 15 x 15 pixels, and line spacing of 8 pixels. LegendBox b = c.addLegend(460, 25, true, "Arial", 12); b.setBackground(Chart.Transparent, Chart.Transparent); b.setKeySize(15, 15); b.setKeySpacing(0, 8); // Add the legend box entries b.addKey("> 1.1 (Critical)", 0x000000); b.addKey("1.0 to 1.1 (Alert)", 0xcc0000); b.addKey("0.9 to 1.0", 0xff6600); b.addKey("0.7 to 0.9", 0xffff00); b.addKey("0.4 to 0.7", 0x00ff00); b.addKey("0.0 to 0.4", 0x88ff88); b.addKey("-0.3 to 0.0", 0x66ffff); b.addKey("-0.5 to -0.3", 0x66ccff); b.addKey("-0.8 to -0.5", 0x0066ff); b.addKey("< -0.8", 0x0000cc); // Output the chart viewer.Chart = c; }