private void metroButton1_Click(object sender, EventArgs e) { string[] lbls = textBox2.Text.Split(','); string[] vals = textBox1.Text.Split(','); double[] newdata = new double[vals.Length]; for (int i = 0; i < vals.Length; i++) { newdata[i] = double.Parse(vals[i]); } //Create a XYChart object of size 250 x 250 pixels XYChart c = new XYChart(int.Parse(textBox3.Text), int.Parse(textBox4.Text)); //Set the plotarea at (30, 20) and of size 200 x 200 pixels c.setPlotArea(30, 20, int.Parse(textBox3.Text) - 50, int.Parse(textBox4.Text) - 50); //Add a bar chart layer using the given data c.addBarLayer(newdata); //Set the x axis labels using the given labels c.xAxis().setLabels(lbls); //output the chart winChartViewer1.Chart = c; }
// // Create chart // private void createChart(RazorChartViewer viewer) { // The data for the bar chart double[] data = { 85, 156, 179.5, 211, 123 }; // The labels for the bar chart string[] labels = { "Mon", "Tue", "Wed", "Thu", "Fri" }; // Create a XYChart object of size 300 x 280 pixels XYChart c = new XYChart(300, 280); // Set the plotarea at (45, 30) and of size 200 x 200 pixels c.setPlotArea(45, 30, 200, 200); // Add a title to the chart c.addTitle("Weekly Server Load"); // Add a title to the y axis c.yAxis().setTitle("MBytes"); // Add a title to the x axis c.xAxis().setTitle("Work Week 25"); // Add a bar chart layer with green (0x00ff00) bars using the given data c.addBarLayer(data, 0x00ff00).set3D(); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Output the chart viewer.Image = c.makeWebImage(Chart.PNG); // Include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("", "", "title='{xLabel}: {value} MBytes'"); }
//Main code for creating chart. //Note: the argument img is unused because this demo only has 1 chart. public void createChart(WinChartViewer viewer, string img) { // The data for the bar chart double[] data = { 3.9, 8.1, 10.9, 14.2, 18.1, 19.0, 21.2, 23.2, 25.7, 36 }; // The labels for the bar chart string[] labels = { "Bastic Group", "Simpa", "YG Super", "CID", "Giga Tech", "Indo Digital", "Supreme", "Electech","THP Thunder", "Flash Light" }; // Create a XYChart object of size 600 x 250 pixels XYChart c = new XYChart(600, 250); // Add a title to the chart using Arial Bold Italic font c.addTitle("Revenue Estimation - Year 2002", "Arial Bold Italic"); // Set the plotarea at (100, 30) and of size 400 x 200 pixels. Set the // plotarea border, background and grid lines to Transparent c.setPlotArea(100, 30, 400, 200, Chart.Transparent, Chart.Transparent, Chart.Transparent, Chart.Transparent, Chart.Transparent); // Add a bar chart layer using the given data. Use a gradient color for // the bars, where the gradient is from dark green (0x008000) to white // (0xffffff) BarLayer layer = c.addBarLayer(data, c.gradientColor(100, 0, 500, 0, 0x008000, 0xffffff)); // Swap the axis so that the bars are drawn horizontally c.swapXY(true); // Set the bar gap to 10% layer.setBarGap(0.1); // Use the format "US$ xxx millions" as the bar label layer.setAggregateLabelFormat("US$ {value} millions"); // Set the bar label font to 10 pts Times Bold Italic/dark red (0x663300) layer.setAggregateLabelStyle("Times New Roman Bold Italic", 10, 0x663300) ; // Set the labels on the x axis ChartDirector.TextBox textbox = c.xAxis().setLabels(labels); // Set the x axis label font to 10pt Arial Bold Italic textbox.setFontStyle("Arial Bold Italic"); textbox.setFontSize(10); // Set the x axis to Transparent, with labels in dark red (0x663300) c.xAxis().setColors(Chart.Transparent, 0x663300); // Set the y axis and labels to Transparent c.yAxis().setColors(Chart.Transparent, Chart.Transparent); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{xLabel}: US${value} millions'"); }
//Main code for creating chart. //Note: the argument img is unused because this demo only has 1 chart. public void createChart(WinChartViewer viewer, string img) { // The data for the bar chart double[] data = { 85, 156, 179.5, 211, 123 }; // The labels for the bar chart string[] labels = { "Mon", "Tue", "Wed", "Thu", "Fri" }; // Create a XYChart object of size 250 x 250 pixels XYChart c = new XYChart(250, 250); // Set the plotarea at (30, 20) and of size 200 x 200 pixels c.setPlotArea(30, 20, 200, 200); // Add a bar chart layer using the given data c.addBarLayer(data); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{xLabel}: US${value}K'"); }
//Main code for creating chart. //Note: the argument img is unused because this demo only has 1 chart. public void createChart(WinChartViewer viewer, string img) { // The data for the chart double[] data0 = { 0.05, 0.06, 0.48, 0.1, 0.01, 0.05 }; double[] data1 = { 100, 125, 265, 147, 67, 105 }; string[] labels = { "Jan", "Feb", "Mar", "Apr", "May", "Jun" }; // Create a XYChart object of size 300 x 180 pixels XYChart c = new XYChart(300, 180); // Set the plot area at (50, 20) and of size 200 x 130 pixels c.setPlotArea(50, 20, 200, 130); // Add a title to the chart using 8 pts Arial Bold font c.addTitle("Independent Y-Axis Demo", "Arial Bold", 8); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Add a title to the primary (left) y axis c.yAxis().setTitle("Packet Drop Rate (pps)"); // Set the axis, label and title colors for the primary y axis to red // (0xc00000) to match the first data set c.yAxis().setColors(0xc00000, 0xc00000, 0xc00000); // Add a title to the secondary (right) y axis c.yAxis2().setTitle("Throughtput (MBytes)"); // set the axis, label and title colors for the primary y axis to green // (0x008000) to match the second data set c.yAxis2().setColors(0x008000, 0x008000, 0x008000); // Add a line layer to for the first data set using red (0xc00000) color // with a line width to 3 pixels LineLayer lineLayer = c.addLineLayer(data0, 0xc00000); lineLayer.setLineWidth(3); // tool tip for the line layer lineLayer.setHTMLImageMap("", "", "title='Packet Drop Rate on {xLabel}: {value} pps'"); // Add a bar layer to for the second data set using green (0x00C000) // color. Bind the second data set to the secondary (right) y axis BarLayer barLayer = c.addBarLayer(data1, 0x00c000); barLayer.setUseYAxis2(); // tool tip for the bar layer barLayer.setHTMLImageMap("", "", "title='Throughput on {xLabel}: {value} MBytes'"); // Output the chart viewer.Image = c.makeImage(); // include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable"); }
//Main code for creating chart. //Note: the argument img is unused because this demo only has 1 chart. public void createChart(WinChartViewer viewer, string img) { // The data for the bar chart double[] data0 = { 100, 125, 245, 147, 67 }; double[] data1 = { 85, 156, 179, 211, 123 }; double[] data2 = { 97, 87, 56, 267, 157 }; // The labels for the bar chart string[] labels = { "Mon", "Tue", "Wed", "Thu", "Fri" }; // Create a XYChart object of size 500 x 320 pixels XYChart c = new XYChart(500, 320); // Set the plotarea at (100, 40) and of size 280 x 240 pixels c.setPlotArea(100, 40, 280, 240); // Add a legend box at (405, 100) c.addLegend(405, 100); // Add a title to the chart c.addTitle("Weekday Network Load"); // Add a title to the y axis. Draw the title upright (font angle = 0) c.yAxis().setTitle("Average\nWorkload\n(MBytes\nPer Hour)").setFontAngle( 0); // Set the labels on the x axis c.xAxis().setLabels(labels); // Add three bar layers, each representing one data set. The bars are // drawn in semi-transparent colors. c.addBarLayer(data0, unchecked ((int)0x808080ff), "Server # 1", 5); c.addBarLayer(data1, unchecked ((int)0x80ff0000), "Server # 2", 5); c.addBarLayer(data2, unchecked ((int)0x8000ff00), "Server # 3", 5); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{dataSetName} on {xLabel}: {value} MBytes/hour'"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // The data for the bar chart double[] data = { 85, 156, 179, 211, 123, 189, 166 }; // The labels for the bar chart string[] labels = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; // Create a XYChart object of size 600 x 360 pixels XYChart c = new XYChart(600, 360); // Set default text color to dark grey (0x333333) c.setColor(Chart.TextColor, 0x333333); // Set the plotarea at (70, 20) and of size 500 x 300 pixels, with transparent background and // border and light grey (0xcccccc) horizontal grid lines c.setPlotArea(70, 20, 500, 300, Chart.Transparent, -1, Chart.Transparent, 0xcccccc); // 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); // Add a blue (0x6699bb) bar chart layer using the given data BarLayer layer = c.addBarLayer(data, 0x6699bb); // Use bar gradient lighting with the light intensity from 0.8 to 1.3 layer.setBorderColor(Chart.Transparent, Chart.barLighting(0.8, 1.3)); // Set rounded corners for bars layer.setRoundedCorners(); // Display labela on top of bars using 12pt Arial font layer.setAggregateLabelStyle("Arial", 12); // Set the labels on the x axis. c.xAxis().setLabels(labels); // For the automatic y-axis labels, set the minimum spacing to 40 pixels. c.yAxis().setTickDensity(40); // Add a title to the y axis using dark grey (0x555555) 14pt Arial Bold font c.yAxis().setTitle("Y-Axis Title Placeholder", "Arial Bold", 14, 0x555555); // Output the chart viewer.Image = c.makeWebImage(Chart.PNG); // Include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("", "", "title='{xLabel}: ${value}M'"); }
/// <summary> /// This method uses the Chart Director API to plot the histogram /// </summary> /// <param name="chartWidth"></param> /// <param name="chartHeight"></param> /// <param name="data"></param> /// <param name="labels"></param> /// <param name="title"></param> /// <param name="xAxisLabel"></param> /// <param name="yAxisLabel"></param> private void plot(int chartWidth, int chartHeight, double[] data, string[] labels, string title, string xAxisLabel, string yAxisLabel) { // Create a XYChart object of size chartWidth x chartHeight pixels XYChart chart = new XYChart(chartWidth, chartHeight); // Set default text color to dark grey (0x333333) chart.setColor(Chart.TextColor, 0x333333); // Add a title box using grey (0x555555) 24pt Arial Bold font chart.addTitle(title, "Arial Bold", 24, 0x555555); // Set the plotarea at (70, 60) and of size 500 x 200 pixels, with transparent // background and border and light grey (0xcccccc) horizontal grid lines chart.setPlotArea(chartXLocation, chartYLocation, plotWidth, plotHeight, Chart.Transparent, -1, Chart.Transparent, 0xcccccc); // Set the x and y axis stems to transparent and the label font to 10pt Arial chart.xAxis().setColors(Chart.Transparent); chart.yAxis().setColors(Chart.Transparent); // Use 10 points Arial rotated by 45 degrees as the x-axis label font chart.xAxis().setLabelStyle("Arial", 10, Chart.TextColor, 45); chart.yAxis().setLabelStyle("Arial", 10); // Add a blue (0x6699bb) bar chart layer using the given data BarLayer layer = chart.addBarLayer(data, 0x6699bb); // Use bar gradient lighting with the light intensity from 0.8 to 1.3 layer.setBorderColor(Chart.Transparent, Chart.barLighting(0.8, 1.3)); // Set rounded corners for bars layer.setRoundedCorners(); // Display labela on top of bars using 10pt Arial font layer.setAggregateLabelStyle("Arial", 10); // Set the labels on the x axis. chart.xAxis().setLabels(labels); // For the automatic y-axis labels, set the minimum spacing to 40 pixelcharts. chart.yAxis().setTickDensity(40); // Add a title to the y axis using dark grey (0x555555) 12pt Arial Bold font chart.yAxis().setTitle(yAxisLabel, "Arial Bold", 12, 0x555555); // Add a title to the x axis using dark grey (0x555555) 12pt Arial Bold font chart.xAxis().setTitle(xAxisLabel, "Arial Bold", 12, 0x555555); //output the chart chartViewer.Chart = chart; }
private void createChartModel(WinChartViewer viewer, DataTable errorData, int per) { try { Chart.setLicenseCode("DEVP-2LSU-B4LX-YCTY-2DF2-77EE"); this.chartWidth = this.Width; // plottWidth = chartWidth - 80; double[] data = null; //int[] color = null; string[] labels = null; GetDataFChartModel(errorData, ref labels, ref data); XYChart c = new XYChart(viewer.Width, viewer.Height); c.setBorder(10); //c.setBackground(0xFFFFFF); c.setPlotArea(70, 90, viewer.Width - 100, viewer.Height - 270, Chart.Transparent, -1, Chart.Transparent, c.dashLineColor(0xffffff, Chart.Transparent)); ArrayMath am = new ArrayMath(data); viewer.BorderStyle = BorderStyle.None; c.yAxis().setLinearScale(0, am.max() + 10); BarLayer layer = c.addBarLayer(am.mul(percentage / 100.0).result(), 0x30c2f7); c.addTitle(" BY MODEL", "Calibri Bold", 30).setBackground(Chart.metalColor(0xff9999)); //title.setMargin2(10, 10, 12, 12); layer.setBarShape(Chart.CircleShape, 0); layer.set3D(20, 10); layer.setAggregateLabelStyle("Arial Bold", 14, layer.yZoneColor(0, 0xcc3300, 0x3333ff)); c.xAxis().setLabels(labels); c.xAxis().setLabelStyle("Arial Bold", 9).setFontAngle(45); c.yAxis().setLabelStyle("Arial Bold", 12); viewer.Chart = c; //viewer.ImageMap = c.getHTMLImageMap("clickable", "", // "title='{xLabel}: {value}'"); } catch (Exception) { } }
//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 data for the bar chart double[] data = { 85, 156, 179, 211, 123, 189, 166 }; // The labels for the bar chart string[] labels = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; // 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) 24pt Arial Bold font c.addTitle(" Bar Chart Demonstration", "Arial Bold", 24, 0x555555); // Set the plotarea at (70, 60) and of size 500 x 300 pixels, with transparent // background and border and light grey (0xcccccc) horizontal grid lines c.setPlotArea(70, 60, 500, 300, Chart.Transparent, -1, Chart.Transparent, 0xcccccc); // 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); // Add a blue (0x6699bb) bar chart layer with transparent border using the given data c.addBarLayer(data, 0x6699bb).setBorderColor(Chart.Transparent); // Set the labels on the x axis. c.xAxis().setLabels(labels); // For the automatic y-axis labels, set the minimum spacing to 40 pixels. c.yAxis().setTickDensity(40); // Add a title to the y axis using dark grey (0x555555) 14pt Arial Bold font c.yAxis().setTitle("Y-Axis Title Placeholder", "Arial Bold", 14, 0x555555); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{xLabel}: {value} kg'"); }
//Main code for creating charts public void createChart(WinChartViewer viewer, int chartIndex) { double bargap = chartIndex * 0.25 - 0.25; // The data for the bar chart double[] data = { 100, 125, 245, 147, 67 }; // The labels for the bar chart string[] labels = { "Mon", "Tue", "Wed", "Thu", "Fri" }; // Create a XYChart object of size 150 x 150 pixels XYChart c = new XYChart(150, 150); // Set the plotarea at (27, 20) and of size 120 x 100 pixels c.setPlotArea(27, 20, 120, 100); // Set the labels on the x axis c.xAxis().setLabels(labels); if (bargap >= 0) { // Add a title to display to bar gap using 8pt Arial font c.addTitle(" Bar Gap = " + bargap, "Arial", 8); } else { // Use negative value to mean TouchBar c.addTitle(" Bar Gap = TouchBar", "Arial", 8); bargap = Chart.TouchBar; } // Add a bar chart layer using the given data and set the bar gap c.addBarLayer(data).setBarGap(bargap); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='Production on {xLabel}: {value} kg'"); }
//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"); }
public void createChart4(WinChartViewer viewer, string img) { // The data for the chart Chart.setLicenseCode("DEVP-2LSU-B4LX-YCTY-2DF2-77EE"); double[] data = data_w4; // The labels for the chart string[] labels = label_w4; // In the pareto chart, the line data are just the accumulation of the // raw data, scaled to a range of 0 - 100% ArrayMath lineData = new ArrayMath(data); lineData.acc(); double scaleFactor = lineData.max() / 100; if (scaleFactor == 0) { // Avoid division by zero error for zero data scaleFactor = 1; } lineData.div2(scaleFactor); // Create a XYChart object of size 480 x 300 pixels. Set background color // to brushed silver, with a grey (bbbbbb) border and 2 pixel 3D raised // effect. Use rounded corners. Enable soft drop shadow. // XYChart c = new XYChart(400, 300, Chart.brushedSilverColor(), 0xbbbbbb, 2); XYChart c = new XYChart(viewer.Width, viewer.Height); c.setBorder(10); // c.setRoundedFrame(); // c.setDropShadow(); // Add a title to the chart using 15 points Arial Italic. Set top/bottom // margins to 12 pixels. ChartDirector.TextBox title = c.addTitle(Chart.Top, _txtTit4, "Arial Bold", 12, 0xffffff, 0x1c86ee); title.setMargin2(10, 10, 6, 12); title.setPos(10, 3); title.setSize(viewer.Width - 20, 30); // Tentatively set the plotarea at (50, 40). Set the width to 100 pixels // less than the chart width, and the height to 80 pixels less than the // chart height. Use pale grey (f4f4f4) background, transparent border, // and dark grey (444444) dotted grid lines. //c.setPlotArea(50, 40, c.getWidth() - 100, c.getHeight() - 80, 0xf4f4f4, // -1, Chart.Transparent, c.dashLineColor(0x444444, Chart.DotLine)); c.setPlotArea(50, 50, c.getWidth() - 110, c.getHeight() - 250, 0xf4f4f4, -1, Chart.Transparent, c.dashLineColor(0xffffff, Chart.Transparent)); // Add a line layer for the pareto line LineLayer lineLayer = c.addLineLayer2(); // Add the pareto line using deep blue (0000ff) as the color, with circle // symbols ArrayMath li = new ArrayMath(lineData.result()); ArrayMath am = new ArrayMath(data); //lineLayer.addDataSet(li.mul(_cnt / 100.0).result(), 0x0000ff).setDataSymbol( // Chart.CircleShape, 9, 0x0000ff, 0x0000ff); lineLayer.addDataSet(lineData.result(), 0x0000ff).setDataSymbol( Chart.CircleShape, 9, 0x0000ff, 0x0000ff); // Set the line width to 2 pixel lineLayer.setLineWidth(2); // Bind the line layer to the secondary (right) y-axis. lineLayer.setUseYAxis2(); // Tool tip for the line layer lineLayer.setHTMLImageMap("", "", "title='Top {={x}+1} items: {value|2}%'"); // Add a multi-color bar layer using the given data. BarLayer barLayer = c.addBarLayer(data, 0xfc8a8a); // BarLayer barLayer = c.addBarLayer(am.mul(_cnt / 100.0).result(), 0xfc8a8a); // Set soft lighting for the bars with light direction from the right barLayer.setBorderColor(Chart.Transparent, Chart.softLighting(Chart.Right )); c.xAxis().setLabelStyle("Arial Bold", 8).setFontAngle(70); c.yAxis().setLabelStyle("Arial Bold", 9); c.yAxis2().setLabelStyle("Arial Bold", 9); // Tool tip for the bar layer // barLayer.setHTMLImageMap("", "", "title='{xLabel}: {value} pieces'"); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Set the secondary (right) y-axis scale as 0 - 100 with a tick every 20 // units c.yAxis2().setLinearScale(0, 100, 10); // Set the format of the secondary (right) y-axis label to include a // percentage sign c.yAxis2().setLabelFormat("{value}%"); // Set the relationship between the two y-axes, which only differ by a // scaling factor c.yAxis().setLinearScale(0, 1600, 160); //c.yAxis().syncAxis(c.yAxis2(), scaleFactor); // Set the format of the primary y-axis label foramt to show no decimal // point c.yAxis().setLabelFormat("{value|0}"); c.setNumberFormat(','); // Add a title to the primary y-axis // c.yAxis().setTitle("Frequency"); // Set all axes to transparent // c.xAxis().setColors(Chart.Transparent); // c.yAxis().setColors(Chart.Transparent); // c.yAxis2().setColors(Chart.Transparent); // Adjust the plot area size, such that the bounding box (inclusive of // axes) is 10 pixels from the left edge, just below the title, 10 pixels // from the right edge, and 20 pixels from the bottom edge. //c.packPlotArea(10, title.getHeight(), c.getWidth() - 10, c.getHeight() - // 20); // Output the chart viewer.Chart = c; // Include tool tip for the chart // viewer.ImageMap = c.getHTMLImageMap("clickable"); }
private void INV_Chart(int percentage) { try { string[] labels = new string[dt.Rows.Count - 1]; double[] data_inv = new double[dt.Rows.Count - 1]; double[] data_lt = new double[dt.Rows.Count - 1]; for (int x = 1; x < dt.Rows.Count; x++) { labels[x - 1] = dt.Rows[x]["MODEL_NM"].ToString(); data_inv[x - 1] = double.Parse(dt.Rows[x]["TOT_INV"].ToString()); data_lt[x - 1] = double.Parse(dt.Rows[x]["TOT_LT"].ToString()); } dt.Dispose(); // Show ChartDirector Chart.setLicenseCode("DEVP-2LSU-B4LX-YCTY-2DF2-77EE"); // Create a XYChart object of size 400 x 240 pixels. XYChart c = new XYChart(1900, 500); c.setBackground(0xFFFFFF); c.setPlotArea(50, 50, 1790, 250, c.linearGradientColor(0, 0, 0, 280, 0xffffff, 0xffffff), -1, 0xffffff, 0xffffff); c.xAxis().setLabels(labels).setFontAngle(45); c.addLegend(50, 5, false, "Calibri Bold", 15).setBackground(Chart.Transparent); ArrayMath am1 = new ArrayMath(data_lt); c.yAxis2().setLinearScale(am1.min(), am1.max(), 5000); LineLayer layer0 = c.addLineLayer2(); layer0.setUseYAxis2(); layer0.setDataLabelFormat("{value|,}"); //dataValueINV layer0.addDataSet(data_lt, 0xff6347, "LeadTime (Days)").setDataSymbol(Chart.GlassSphere2Shape, 11); layer0.setLineWidth(3); BarLayer layer = c.addBarLayer(Chart.CircleShape); // Set the labels on the x axis. c.xAxis().setLabels(labels); c.yAxis().setLabelStyle("Calibri Bold", 10); c.yAxis2().setLabelStyle("Calibri Bold", 10); // Add a bar chart layer using the given data //data_lt ArrayMath am = new ArrayMath(dataValueINV); //ArrayMath am = new ArrayMath(data_inv); c.yAxis().setLinearScale(0, am.max() + 2); layer.addDataSet(am.mul(percentage / 100.0).result(), 0x00bfff, "Inventory (Prs)"); layer.setDataLabelFormat("{value|,}"); //layer.set3D(1); c.setNumberFormat(','); // Output the chart Chart_INV.Chart = c; //include tool tip for the chart Chart_INV.ImageMap = c.getHTMLImageMap("clickable", "", "title='{xLabel}: {value} '"); } catch {} }
//Main code for creating chart. //Note: the argument img is unused because this demo only has 1 chart. public void createChart(WinChartViewer viewer, string img) { // The age groups string[] labels = { "0 - 4", "5 - 9", "10 - 14", "15 - 19", "20 - 24", "24 - 29", "30 - 34", "35 - 39", "40 - 44", "44 - 49","50 - 54", "55 - 59", "60 - 64", "65 - 69", "70 - 74", "75 - 79","80+" }; // The male population (in thousands) double[] male = { 215, 238, 225, 236, 235, 260, 286, 340, 363, 305, 259, 164, 135, 127, 102, 68, 66 }; // The female population (in thousands) double[] female = { 194, 203, 201, 220, 228, 271, 339, 401, 384, 304, 236, 137, 116, 122, 112, 85, 110 }; //============================================================= // Draw the right bar chart //============================================================= // Create a XYChart object of size 320 x 300 pixels XYChart c = new XYChart(320, 300); // Set the plotarea at (50, 0) and of size 250 x 255 pixels. Use pink // (0xffdddd) as the background. c.setPlotArea(50, 0, 250, 255, 0xffdddd); // Add a custom text label at the top right corner of the right bar chart c.addText(300, 0, "Female", "Times New Roman Bold Italic", 12, 0xa07070 ).setAlignment(Chart.TopRight); // Add the pink (0xf0c0c0) bar chart layer using the female data BarLayer femaleLayer = c.addBarLayer(female, 0xf0c0c0, "Female"); // Swap the axis so that the bars are drawn horizontally c.swapXY(true); // Set the bar to touch each others femaleLayer.setBarGap(Chart.TouchBar); // Set the border style of the bars to 1 pixel 3D border femaleLayer.setBorderColor(-1, 1); // Add a Transparent line layer to the chart using the male data. As it // is Transparent, only the female bar chart can be seen. We need to put // both male and female data in both left and right charts, because we // want auto-scaling to produce the same scale for both chart. c.addLineLayer(male, Chart.Transparent); // Set the y axis label font to Arial Bold c.yAxis().setLabelStyle("Arial Bold"); // Set the labels between the two bar charts, which can be considered as // the x-axis labels for the right chart ChartDirector.TextBox tb = c.xAxis().setLabels(labels); // Use a fix width of 50 for the labels (height = automatic) with center // alignment tb.setSize(50, 0); tb.setAlignment(Chart.Center); // Set the label font to Arial Bold tb.setFontStyle("Arial Bold"); // Disable ticks on the x-axis by setting the tick length to 0 c.xAxis().setTickLength(0); //============================================================= // Draw the left bar chart //============================================================= // Create a XYChart object of size 280 x 300 pixels with a transparent // background. XYChart c2 = new XYChart(280, 300, Chart.Transparent); // Set the plotarea at (20, 0) and of size 250 x 255 pixels. Use pale // blue (0xddddff) as the background. c2.setPlotArea(20, 0, 250, 255, 0xddddff); // Add a custom text label at the top left corner of the left bar chart c2.addText(20, 0, "Male", "Times New Roman Bold Italic", 12, 0x7070a0); // Add the pale blue (0xaaaaff) bar chart layer using the male data BarLayer maleLayer = c2.addBarLayer(male, 0xaaaaff, "Male"); // Swap the axis so that the bars are drawn horizontally c2.swapXY(true); // Reverse the direction of the y-axis so it runs from right to left c2.yAxis().setReverse(); // Set the bar to touch each others maleLayer.setBarGap(Chart.TouchBar); // Set the border style of the bars to 1 pixel 3D border maleLayer.setBorderColor(-1, 1); // Add a Transparent line layer to the chart using the female data. As it // is Transparent, only the male bar chart can be seen. We need to put // both male and female data in both left and right charts, because we // want auto-scaling to produce the same scale for both chart. c2.addLineLayer(female, Chart.Transparent); // Set the y axis label font to Arial Bold c2.yAxis().setLabelStyle("Arial Bold"); // Set the x-axis labels for tool tip purposes. c2.xAxis().setLabels(labels); // Hide the x-axis labels by setting them to Transparent. We only need to // display the x-axis labels for the right chart. c2.xAxis().setColors(0x000000, Chart.Transparent, -1, Chart.Transparent); //============================================================= // Use a MultiChart to contain both bar charts //============================================================= // Create a MultiChart object of size 590 x 320 pixels. MultiChart m = new MultiChart(590, 320); // Add a title to the chart using Arial Bold Italic font m.addTitle("Demographics Hong Kong Year 2002", "Arial Bold Italic"); // Add another title at the bottom using Arial Bold Italic font m.addTitle2(Chart.Bottom, "Population (in thousands)", "Arial Bold Italic", 10); // Put the right chart at (270, 25) m.addChart(270, 25, c); // Put the left chart at (0, 25) m.addChart(0, 25, c2); // Output the chart viewer.Image = m.makeImage(); //include tool tip for the chart viewer.ImageMap = m.getHTMLImageMap("clickable", "", "title='{dataSetName} (Age {xLabel}): Population {value}K'"); }
//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 data for the bars and the marks double[] barData = { 100, 125, 245, 147, 67, 96, 160, 145, 97, 167, 220, 125 }; double[] markData = { 85, 156, 220, 120, 80, 110, 140, 130, 111, 180, 175, 100 }; // The labels for the bar chart string[] labels = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" }; // Create a XYChart object of size 480 x 360 pixels. Use a vertical gradient color from // pale blue (e8f0f8) to sky blue (aaccff) spanning half the chart height as background. // Set border to blue (88aaee). Use rounded corners. Enable soft drop shadow. XYChart c = new XYChart(480, 360); c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight() / 2, 0xe8f0f8, 0xaaccff), 0x88aaee); c.setRoundedFrame(); c.setDropShadow(); // Add a title to the chart using 15 points Arial Italic font. Set top/bottom margins to // 12 pixels. ChartDirector.TextBox title = c.addTitle("Bars with Marks Demonstration", "Arial Italic", 15); title.setMargin2(0, 0, 12, 12); // Tentatively set the plotarea to 50 pixels from the left edge to allow for the y-axis, // and to just under the title. Set the width to 65 pixels less than the chart width, // and the height to reserve 90 pixels at the bottom for the x-axis and the legend box. // Use pale blue (e8f0f8) background, transparent border, and grey (888888) dotted // horizontal grid lines. c.setPlotArea(50, title.getHeight(), c.getWidth() - 65, c.getHeight() - title.getHeight( ) - 90, 0xe8f0f8, -1, Chart.Transparent, c.dashLineColor(0x888888, Chart.DotLine)); // Add a legend box where the bottom-center is anchored to the 15 pixels above the // bottom-center of the chart. Use horizontal layout and 8 points Arial font. LegendBox legendBox = c.addLegend(c.getWidth() / 2, c.getHeight() - 15, false, "Arial", 8); legendBox.setAlignment(Chart.BottomCenter); // Set the legend box background and border to pale blue (e8f0f8) and bluish grey // (445566) legendBox.setBackground(0xe8f0f8, 0x445566); // Use rounded corners of 5 pixel radius for the legend box legendBox.setRoundedCorners(5); // Use line style legend key legendBox.setLineStyleKey(); // Set axes to transparent c.xAxis().setColors(Chart.Transparent); c.yAxis().setColors(Chart.Transparent); // Set the labels on the x axis c.xAxis().setLabels(labels); // Add a box-whisker layer with just the middle mark visible for the marks. Use red // (ff0000) color for the mark, with a line width of 2 pixels and 10% horizontal gap BoxWhiskerLayer markLayer = c.addBoxWhiskerLayer(null, null, null, null, markData, -1, 0xff0000); markLayer.setLineWidth(2); markLayer.setDataGap(0.1); // Add the legend key for the mark line legendBox.addKey("Target", 0xff0000, 2); // Tool tip for the mark layer markLayer.setHTMLImageMap("", "", "title='Target at {xLabel}: {med}'"); // Add a blue (0066cc) bar layer using the given data. BarLayer barLayer = c.addBarLayer(barData, 0x0066cc, "Actual"); // Use soft lighting effect for the bars with light direction from left. barLayer.setBorderColor(Chart.Transparent, Chart.softLighting(Chart.Left)); // Tool tip for the bar layer barLayer.setHTMLImageMap("", "", "title='{dataSetName} at {xLabel}: {value}'"); // Adjust the plot area size, such that the bounding box (inclusive of axes) is 10 // pixels from the left edge, just below the title, 15 pixels from the right edge, and // 10 pixels above the legend box. c.packPlotArea(10, title.getHeight(), c.getWidth() - 15, c.layoutLegend().getTopY() - 10 ); // Output the chart viewer.Chart = c; // Include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // The data for the chart double[] data = { 40, 45, 37, 24, 32, 39, 53, 52, 63, 49, 46, 40, 54, 50, 57, 57, 48, 49, 63, 67, 74, 72, 70, 89, 74 }; string[] labels = { "0\nJun 4", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "0\nJun 5" }; // Create a XYChart object of size 400 x 270 pixels XYChart c = new XYChart(400, 270); // Set the plotarea at (80, 60) and of size 300 x 200 pixels. Turn off the grid lines by // setting their colors to Transparent. c.setPlotArea(80, 28, 300, 200).setGridColor(Chart.Transparent); // Add a title to the y axis ChartDirector.TextBox textbox = c.yAxis().setTitle("Temperature"); // Set the y axis title upright (font angle = 0) textbox.setFontAngle(0); // Put the y axis title on top of the axis textbox.setAlignment(Chart.TopLeft2); // Add green (0x99ff99), yellow (0xffff99) and red (0xff9999) zones to the y axis to // represent the ranges 0 - 50, 50 - 80, and 80 - max. c.yAxis().addZone(0, 50, 0x99ff99); c.yAxis().addZone(50, 80, 0xffff99); c.yAxis().addZone(80, 9999, 0xff9999); // Add a purple (0x800080) mark at y = 70 using a line width of 2. c.yAxis().addMark(70, 0x800080, "Alert = 70").setLineWidth(2); // Add a green (0x008000) mark at y = 40 using a line width of 2. c.yAxis().addMark(40, 0x008000, "Watch = 40").setLineWidth(2); // Add a legend box at (165, 0) (top right of the chart) using 8pt Arial font. and horizontal // layout. LegendBox legend = c.addLegend(165, 0, false, "Arial Bold", 8); // Disable the legend box boundary by setting the colors to Transparent legend.setBackground(Chart.Transparent, Chart.Transparent); // Add 3 custom entries to the legend box to represent the 3 zones legend.addKey("Normal", 0x80ff80); legend.addKey("Warning", 0xffff80); legend.addKey("Critical", 0xff8080); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels. c.xAxis().setLabelStep(3, 1); // Add a 3D bar layer with the given data BarLayer layer = c.addBarLayer(data, 0xbbbbff); // Set the bar gap to 0 so that the bars are packed tightly layer.setBarGap(0); // Set the border color of the bars same as the fill color, with 1 pixel 3D border effect. layer.setBorderColor(Chart.SameAsMainColor, 1); // Output the chart viewer.Image = c.makeWebImage(Chart.PNG); // Include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("", "", "title='Temperature at {x}:00 = {value} C'"); }
public void createChart(WinChartViewer viewer, DateTime beginDate, Double dateRange) { //dateRange = dateRange / 3600.0; DateTime viewPortStartDate = beginDate.AddSeconds(Math.Round(viewer.ViewPortLeft * dateRange)); DateTime viewPortEndDate = viewPortStartDate.AddSeconds(Math.Round(viewer.ViewPortWidth * dateRange)); Double vpStart = Math.Round(viewer.ViewPortLeft * dateRange); Double vpEnd = vpStart + Math.Round(viewer.ViewPortWidth * dateRange); //TimeSpan hoursCalc = viewPortEndDate.Subtract(viewPortStartDate); //int hours = (hoursCalc.Days * 24) + hoursCalc.Hours; //viewPortEndDate = viewPortEndDate.AddMinutes(12 * hours); // hack to show hour labels //Double axisLowerLimit = 0 + viewer.ViewPortTop * rowRange; //Double axisUpperLimit = axisLowerLimit + viewer.ViewPortHeight * (rowRange); XYChart c = new XYChart(viewer.Width - 5, viewer.Height - 5); // Add a title to the chart c.addTitle(chartName); // Set the plotarea at (50, 20) and of size 200 x 5200 pixels c.setPlotArea(50, 20, viewer.Width - 70, viewer.Height - 75); c.setClipping(); // Add a bar chart layer using the given data if (chartOutputType.Equals(OutputType.INFO_ELEMENT)) { c.addBarLayer(chartData.HighData.ToArray(), -1, chartOutputSubType); } else { c.addScatterLayer(new double[0], new ArrayMath(chartData.HighData.ToArray()).selectNEZ(chartData.IconType.ToArray(), ChartDirector.Chart.NoValue).result(), chartOutputSubType, ChartDirector.Chart.CircleShape, 6, ChartDirector.Chart.CColor(Color.DarkOrange)); LineLayer ll = c.addStepLineLayer(); ll.addDataSet(chartData.HighData.ToArray(), ChartDirector.Chart.CColor(Color.DarkGray), ""); ll.setLineWidth(3); } c.yAxis().setTitle(chartYAxis); c.yAxis().setLinearScale(0, 1.25, 0.25); ChartDirector.Mark mark = c.yAxis().addMark(1.0, 0x008000, "Max"); mark.setLineWidth(2); mark.setDrawOnTop(false); // Set the labels on the x axis. //c.xAxis().setDateScale(viewPortStartDate, viewPortEndDate); c.xAxis().setLinearScale(vpStart, vpEnd, 1.0); c.xAxis().setMargin(10, 10); if (chartOutputType.Equals(OutputType.INFO_ELEMENT)) { ChartDirector.BarLayer bl = c.addBarLayer(); List<Double> barData = new List<Double>(); int whiteColor = ChartDirector.Chart.CColor(Color.White); int redColor = ChartDirector.Chart.CColor(Color.Red); // add marks to the bar chart so we can see if a value should be there (even if it's zero) for (int i = 0; i < chartData.RealDataAtThisPoint.Count; i++) { if (chartData.RealDataAtThisPoint[i]) { barData.Add(0.05); //c.xAxis().addMark(i, redColor); } else { barData.Add(0.0); } } bl.setBorderColor(redColor); bl.setBarWidth(0); bl.addDataSet(barData.ToArray(), whiteColor); } // begin time in chart director format String beginCD = ""+ChartDirector.Chart.CTime(beginDate); // chart director uses seconds, convert our timeincrement to seconds and add them to the start time String partialTimeString = "{=("+beginCD+"+{value}*"+ChartExplorer.TimeIncrementInSecondsString+")|"; c.xAxis().setMultiFormat(ChartDirector.Chart.StartOfDayFilter(), "<*font=bold*>"+partialTimeString+"m/d hhnn}", // show the day text once for each day ChartDirector.Chart.AllPassFilter(), partialTimeString+"hhnn}"); // military time for all others //c.xAxis().setLabels(chartData.TimeStamps.ToArray()); c.xAxis().setTitle("Time Period: Hours"); //c.xAxis().setLabelStep(4); //c.yAxis().setMultiFormat(ChartDirector.Chart.StartOfHourFilter(), "<*font=bold*>{value|w hhnn}", ChartDirector.Chart.AllPassFilter(), "{value|w hhnn}"); // output the chart try { viewer.Image = c.makeImage(); String query = "x={x}&xLabel={xLabel}&dataSet={dataSet}&dataSetName={dataSetName}&value={value}"; viewer.ImageMap = c.getHTMLImageMap(query, query); } catch (Exception) // occasionally c.makeImage(); crashes - some sort of drawing exception? // if we catch, the next redraw/resize should be fine... { } }