//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'"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // 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 }; string[] labels = { "Mon", "Tue", "Wed", "Thur", "Fri" }; // Create a XYChart object of size 540 x 375 pixels XYChart c = new XYChart(540, 375); // Add a title to the chart using 18pt Times Bold Italic font c.addTitle("Average Weekly Network Load", "Times New Roman Bold Italic", 18); // Set the plotarea at (50, 55) and of 440 x 280 pixels in size. Use a vertical gradient // color from light blue (f9f9ff) to blue (6666ff) as background. Set border and grid lines // to white (ffffff). c.setPlotArea(50, 55, 440, 280, c.linearGradientColor(0, 55, 0, 335, 0xf9f9ff, 0x6666ff), -1, 0xffffff, 0xffffff); // Add a legend box at (50, 28) using horizontal layout. Use 10pt Arial Bold as font, with // transparent background. c.addLegend(50, 28, false, "Arial Bold", 10).setBackground(Chart.Transparent); // Set the x axis labels c.xAxis().setLabels(labels); // Draw the ticks between label positions (instead of at label positions) c.xAxis().setTickOffset(0.5); // Set axis label style to 8pt Arial Bold c.xAxis().setLabelStyle("Arial Bold", 8); c.yAxis().setLabelStyle("Arial Bold", 8); // Set axis line width to 2 pixels c.xAxis().setWidth(2); c.yAxis().setWidth(2); // Add axis title c.yAxis().setTitle("Throughput (MBytes Per Hour)"); // Add a multi-bar layer with 3 data sets BarLayer layer = c.addBarLayer2(Chart.Side); layer.addDataSet(data0, 0xff0000, "Server #1"); layer.addDataSet(data1, 0x00ff00, "Server #2"); layer.addDataSet(data2, 0xff8800, "Server #3"); // Set bar border to transparent. Use glass lighting effect with light direction from left. layer.setBorderColor(Chart.Transparent, Chart.glassEffect(Chart.NormalGlare, Chart.Left)); // Configure the bars within a group to touch each others (no gap) layer.setBarGap(0.2, Chart.TouchBar); // 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 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 }; double[] data1 = { 85, 156, 179, 211 }; double[] data2 = { 97, 87, 56, 267 }; string[] labels = { "1st Quarter", "2nd Quarter", "3rd Quarter", "4th Quarter" }; // Create a XYChart object of size 600 x 350 pixels XYChart c = new XYChart(600, 350); // Add a title to the chart using 14 pts Arial Bold Italic font c.addTitle("Annual Product Revenue", "Arial Bold Italic", 14); // Set the plot area at (50, 60) and of size 500 x 240. Use two // alternative background colors (f8f8f8 and ffffff) c.setPlotArea(50, 60, 500, 240, 0xf8f8f8, 0xffffff); // Add a legend box at (55, 22) using horizontal layout, with transparent // background c.addLegend(55, 22, false).setBackground(Chart.Transparent); // Set the x axis labels c.xAxis().setLabels(labels); // Draw the ticks between label positions (instead of at label positions) c.xAxis().setTickOffset(0.5); // Add a multi-bar layer with 3 data sets and 9 pixels 3D depth BarLayer layer = c.addBarLayer2(Chart.Side, 9); layer.addDataSet(data0, -1, "Product A"); layer.addDataSet(data1, -1, "Product B"); layer.addDataSet(data2, -1, "Product C"); // Set data set 1 to use a bar shape of a 6-pointed star layer.setBarShape(Chart.StarShape(6), 0); // Set data set 2 to use a bar shapre of a 6-sided polygon layer.setBarShape(Chart.PolygonShape(6), 1); // Set data set 3 to use an X bar shape layer.setBarShape(Chart.Cross2Shape(), 2); // Add a title to the y-axis c.yAxis().setTitle("Revenue (USD in millions)"); // Add a title to the x axis c.xAxis().setTitle("Year 2005"); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{dataSetName}: {xLabel} Revenue = {value} millions'"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // Data for the chart double[] data0 = { 100, 125, 245, 147, 67, 96, 160, 145, 97, 167, 220, 125 }; double[] data1 = { 85, 156, 179, 211, 123, 225, 127, 99, 111, 260, 175, 156 }; double[] data2 = { 97, 87, 56, 267, 157, 157, 67, 156, 77, 87, 197, 87 }; string[] labels = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" }; // Create a XYChart object of size 560 x 280 pixels. XYChart c = new XYChart(560, 280); // Add a title to the chart using 14pt Arial Bold Italic font c.addTitle(" Average Weekly Network Load", "Arial Bold Italic", 14); // Set the plotarea at (50, 50) and of 500 x 200 pixels in size. Use alternating light grey // (f8f8f8) / white (ffffff) background. Set border to transparent and use grey (CCCCCC) // dotted lines as horizontal and vertical grid lines c.setPlotArea(50, 50, 500, 200, 0xffffff, 0xf8f8f8, Chart.Transparent, c.dashLineColor( 0xcccccc, Chart.DotLine), c.dashLineColor(0xcccccc, Chart.DotLine)); // Add a legend box at (50, 22) using horizontal layout. Use 10 pt Arial Bold Italic font, // with transparent background c.addLegend(50, 22, false, "Arial Bold Italic", 10).setBackground(Chart.Transparent); // Set the x axis labels c.xAxis().setLabels(labels); // Draw the ticks between label positions (instead of at label positions) c.xAxis().setTickOffset(0.5); // Add axis title c.yAxis().setTitle("Throughput (MBytes Per Hour)"); // Set axis line width to 2 pixels c.xAxis().setWidth(2); c.yAxis().setWidth(2); // Add a multi-bar layer with 3 data sets BarLayer layer = c.addBarLayer2(Chart.Side); layer.addDataSet(data0, 0xff0000, "Server #1"); layer.addDataSet(data1, 0x00ff00, "Server #2"); layer.addDataSet(data2, 0x0000ff, "Server #3"); // Set bar shape to circular (cylinder) layer.setBarShape(Chart.CircleShape); // Configure the bars within a group to touch each others (no gap) layer.setBarGap(0.2, Chart.TouchBar); // Output the chart viewer.Image = c.makeWebImage(Chart.PNG); // Include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("", "", "title='{dataSetName} on {xLabel}: {value} MBytes/hour'"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // The data for the bar chart double[] data = { -6.3, 2.3, 0.7, -3.4, 2.2, -2.9, -0.1, -0.1, 3.3, 6.2, 4.3, 1.6 }; // The labels for the bar chart string[] labels = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; // Create a XYChart object of size 500 x 320 pixels XYChart c = new XYChart(500, 320); // Add a title to the chart using Arial Bold Italic font c.addTitle("Productivity Change - Year 2005", "Arial Bold Italic"); // Set the plotarea at (50, 30) and of size 400 x 250 pixels c.setPlotArea(50, 30, 400, 250); // Add a bar layer to the chart using the Overlay data combine method BarLayer layer = c.addBarLayer2(Chart.Overlay); // Select positive data and add it as data set with blue (6666ff) color layer.addDataSet(new ArrayMath(data).selectGEZ(null, Chart.NoValue).result(), 0x6666ff); // Select negative data and add it as data set with orange (ff6600) color layer.addDataSet(new ArrayMath(data).selectLTZ(null, Chart.NoValue).result(), 0xff6600); // Add labels to the top of the bar using 8 pt Arial Bold font. The font color is configured // to be red (0xcc3300) below zero, and blue (0x3333ff) above zero. layer.setAggregateLabelStyle("Arial Bold", 8, layer.yZoneColor(0, 0xcc3300, 0x3333ff)); // Set the labels on the x axis and use Arial Bold as the label font c.xAxis().setLabels(labels).setFontStyle("Arial Bold"); // Draw the y axis on the right of the plot area c.setYAxisOnRight(true); // Use Arial Bold as the y axis label font c.yAxis().setLabelStyle("Arial Bold"); // Add a title to the y axis c.yAxis().setTitle("Percentage"); // Add a light blue (0xccccff) zone for positive part of the plot area c.yAxis().addZone(0, 9999, 0xccccff); // Add a pink (0xffffcc) zone for negative part of the plot area c.yAxis().addZone(-9999, 0, 0xffcccc); // Output the chart viewer.Image = c.makeWebImage(Chart.PNG); // Include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("", "", "title='{xLabel}: {value}%'"); }
// Thread th; // bool _IsKey = true; // int icount = 0; #region Function //private void addUC() //{ // Smart_FTY.UC.UC_DWMY ucMenu = new UC.UC_DWMY(5); // pnMenu.Controls.Add(ucMenu); // ucMenu.OnDWMYClick += mnBtnClick; //} //private void mnBtnClick(string ButtonCap, string ButtonCD) //{ // switch (ButtonCap) // { // case "btnClose": // this.Close(); // break; // } //} #region Chart public void createChart(WinChartViewer viewer, int per) { Chart.setLicenseCode("DEVP-2LSU-B4LX-YCTY-2DF2-77EE"); double[] d0 = new double[DayOfMonth]; double[] d1 = new double[DayOfMonth]; double[] d2 = new double[DayOfMonth]; // The data for the bar chart // Create a XYChart object of size 580 x 280 pixels XYChart c = new XYChart(1900, 500); // Set the plot area at (50, 50) and of size 500 x 200. Use two // alternative background colors (f8f8f8 and ffffff) c.setPlotArea(50, 50, 1720, 400, 0xf8f8f8, 0xffffff); // Add a legend box at (50, 25) using horizontal layout. Use 8pts Arial // as font, with transparent background. c.addLegend(c.getWidth() - 120, 25, false, "Calibri Bold", 18).setBackground(Chart.Transparent); // Set the x axis labels c.xAxis().setLabels(labels); // Draw the ticks between label positions (instead of at label positions) c.xAxis().setTickOffset(0.5); c.xAxis().setLabelStyle("Calibri Bold", 12); c.yAxis().setLabelStyle("Calibri Bold", 12); // Add a multi-bar layer with 3 data sets BarLayer layer = c.addBarLayer2(Chart.Side); ArrayMath am0 = new ArrayMath(data0); ArrayMath am1 = new ArrayMath(data1); ArrayMath am2 = new ArrayMath(data2); c.yAxis().setLinearScale(0, am2.max()); d0 = am0.mul(percentage / 100.0).result(); d1 = am1.mul(percentage / 100.0).result(); d2 = am2.mul(percentage / 100.0).result(); layer.addDataSet(d0, 0xff8080, "1 Color"); layer.addDataSet(d1, 0x008800, "2 Color"); layer.addDataSet(d2, 0x8080ff, "Total"); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='Day:{xLabel} - {value} prs'"); }
//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, 156, 147, 87, 124, 178, 109, 140, 106, 192, 122 }; double[] data1 = { 122, 156, 179, 211, 198, 177, 160, 220, 190, 188, 220, 270 }; double[] data2 = { 167, 190, 213, 267, 250, 320, 212, 199, 245, 267, 240, 310 }; string[] labels = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" }; // Create a XYChart object of size 580 x 280 pixels XYChart c = new XYChart(580, 280); // Add a title to the chart using 14 pts Arial Bold Italic font c.addTitle("Product Revenue For Last 3 Years", "Arial Bold Italic", 14); // Set the plot area at (50, 50) and of size 500 x 200. Use two // alternative background colors (f8f8f8 and ffffff) c.setPlotArea(50, 50, 500, 200, 0xf8f8f8, 0xffffff); // Add a legend box at (50, 25) using horizontal layout. Use 8pts Arial // as font, with transparent background. c.addLegend(50, 25, false, "Arial", 8).setBackground(Chart.Transparent); // Set the x axis labels c.xAxis().setLabels(labels); // Draw the ticks between label positions (instead of at label positions) c.xAxis().setTickOffset(0.5); // Add a multi-bar layer with 3 data sets BarLayer layer = c.addBarLayer2(Chart.Side); layer.addDataSet(data0, 0xff8080, "Year 2003"); layer.addDataSet(data1, 0x80ff80, "Year 2004"); layer.addDataSet(data2, 0x8080ff, "Year 2005"); // Set 50% overlap between bars layer.setOverlapRatio(0.5); // Add a title to the y-axis c.yAxis().setTitle("Revenue (USD in millions)"); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{xLabel} Revenue on {dataSetName}: {value} millions'"); }
//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 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" }; // The colors for the bars int[] colors = { 0x5588bb, 0x66bbbb, 0xaa6644, 0x99bb55, 0xee9944, 0x444466, 0xbb5555 }; // 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 multi-color bar chart layer using the given data BarLayer layer = c.addBarLayer3(data, colors); // Use bar gradient lighting with the light intensity from 0.8 to 1.15 layer.setBorderColor(Chart.Transparent, Chart.barLighting(0.8, 1.15)); // Set rounded corners for bars layer.setRoundedCorners(); // 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 font c.yAxis().setTitle("Y-Axis Title Placeholder", "Arial", 14, 0x555555); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{xLabel}: ${value}M'"); }
// // 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; }
//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 (400, 100) c.addLegend(400, 100); // Add a title to the chart using 14 points Times Bold Itatic font c.addTitle("Weekday Network Load", "Times New Roman Bold Italic", 14); // 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 a stacked bar layer and set the layer 3D depth to 8 pixels BarLayer layer = c.addBarLayer2(Chart.Stack, 8); // Add the three data sets to the bar layer layer.addDataSet(data0, 0xff8080, "Server # 1"); layer.addDataSet(data1, 0x80ff80, "Server # 2"); layer.addDataSet(data2, 0x8080ff, "Server # 3"); // Enable bar label for the whole bar layer.setAggregateLabelStyle(); // Enable bar label for each segment of the stacked bar layer.setDataLabelStyle(); // 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'"); }
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) { } }
// // Create chart // private void createChart(RazorChartViewer viewer) { // 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 }; string[] labels = { "Mon", "Tue", "Wed", "Thu", "Fri" }; // Create a XYChart object of size 400 x 240 pixels XYChart c = new XYChart(400, 240); // Add a title to the chart using 10 pt Arial font c.addTitle(" Average Weekday Network Load", "", 10); // Set the plot area at (50, 25) and of size 320 x 180. Use two alternative background colors // (0xffffc0 and 0xffffe0) c.setPlotArea(50, 25, 320, 180, 0xffffc0, 0xffffe0); // Add a legend box at (55, 18) using horizontal layout. Use 8 pt Arial font, with // transparent background c.addLegend(55, 18, false, "", 8).setBackground(Chart.Transparent); // Add a title to the y-axis c.yAxis().setTitle("Throughput (MBytes Per Hour)"); // Reserve 20 pixels at the top of the y-axis for the legend box c.yAxis().setTopMargin(20); // Set the x axis labels c.xAxis().setLabels(labels); // Add a multi-bar layer with 3 data sets and 3 pixels 3D depth BarLayer layer = c.addBarLayer2(Chart.Side, 3); layer.addDataSet(data0, 0xff8080, "Server #1"); layer.addDataSet(data1, 0x80ff80, "Server #2"); layer.addDataSet(data2, 0x8080ff, "Server #3"); // Output the chart viewer.Image = c.makeWebImage(Chart.PNG); // Include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("", "", "title='{dataSetName} on {xLabel}: {value} MBytes/hour'"); }
private ScoreBar GetScoreBarGeomInfoForZooming(Point pointRelativeToThis, out double heightPercentage, out double height) { heightPercentage = 0; height = 0; var pt = pointRelativeToThis; pt = TranslatePoint(pt, BarLayer); var hit = VisualTreeHelper.HitTest(BarLayer, pt); var scoreBar = (hit?.VisualHit as FrameworkElement)?.FindVisualParent <ScoreBar>(); if (scoreBar == null) { return(null); } pt = BarLayer.TranslatePoint(pt, scoreBar); height = scoreBar.Height; heightPercentage = pt.Y / height; return(scoreBar); }
//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.5, 211, 123 }; // The labels for the bar chart string[] labels = { "Mon", "Tue", "Wed", "Thu", "Fri" }; // Create a XYChart object of size 400 x 240 pixels. XYChart c = new XYChart(400, 240); // Add a title to the chart using 14pt Times Bold Italic font c.addTitle("Weekly Server Load", "Times New Roman Bold Italic", 14); // Set the plotarea at (45, 40) and of 300 x 160 pixels in size. Use alternating light // grey (f8f8f8) / white (ffffff) background. c.setPlotArea(45, 40, 300, 160, 0xf8f8f8, 0xffffff); // Add a multi-color bar chart layer BarLayer layer = c.addBarLayer3(data); // Set layer to 3D with 10 pixels 3D depth layer.set3D(10); // Set bar shape to circular (cylinder) layer.setBarShape(Chart.CircleShape); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Add a title to the y axis c.yAxis().setTitle("MBytes"); // Add a title to the x axis c.xAxis().setTitle("Work Week 25"); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{xLabel}: {value} MBytes'") ; }
private void LoadDataToChart(WinChartViewer viewer, DataTable errorData, int per) { Chart.setLicenseCode("DEVP-2LSU-B4LX-YCTY-2DF2-77EE"); this.chartWidth = this.Width; plottWidth = chartWidth - 80; double[] data = null; int[] color = null; string[] labels = null; GetDataForChart(errorData, ref labels, ref data, ref color); XYChart c = new XYChart(chartWidth, chartHeight); c.setBackground(0xFFFFFF); c.setPlotArea(40, 80, plottWidth, plotHeight, 0xf8f8f8, 0xffffff); ArrayMath am = new ArrayMath(data); viewer.BorderStyle = BorderStyle.None; c.yAxis().setLinearScale(0, am.max()); BarLayer layer = c.addBarLayer3(am.mul(percentage / 100.0).result()); layer.set3D(20, 10); layer.setAggregateLabelStyle("Arial Bold", 14, layer.yZoneColor(0, 0xcc3300, 0x3333ff)); c.xAxis().setLabels(labels); c.xAxis().setLabelStyle("Calibri Bold", 12); c.yAxis().setLabelStyle("Calibri Bold", 12); viewer.Chart = c; viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{xLabel}: {value}'"); }
public void createChart(WinChartViewer viewer, double[] data, string img) { // The data for the chart Chart.setLicenseCode("DEVP-2LSU-B4LX-YCTY-2DF2-77EE"); //double[] data = {16, 15, 9.7, 5.2, 3}; // double[] data1 = { Chart.NoValue, -131, 35, 46 }; // The labels for the chart // string[] labels = _strLabel; //int[] _colors = { 3394815, 0x33ccff, 0x33ccff, 0x33ccff, 28864 }; double dMax = NulltoZeroDouble(_dt_chart.Rows[_dt_chart.Rows.Count - 3][viewer.Name.Replace("chart_", "")]); double dMin = NulltoZeroDouble(_dt_chart.Rows[_dt_chart.Rows.Count - 2][viewer.Name.Replace("chart_", "")]); double dIncr = NulltoZeroDouble(_dt_chart.Rows[_dt_chart.Rows.Count - 1][viewer.Name.Replace("chart_", "")]); // 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); // 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, _dt_chart.Rows[0][viewer.Name.Replace("chart_", "") + "_CNAME"].ToString(), "Arial Bold", 12); 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(70, 50, c.getWidth() - 110, c.getHeight() - 100, 0xffffff, -1, Chart.Transparent, c.dashLineColor(0xffffff, Chart.Transparent)); // Add a line layer for the pareto line // ArrayMath li = new ArrayMath(data1); ArrayMath am = new ArrayMath(data); //LineLayer lineLayer = c.addLineLayer2(); //lineLayer.addDataSet(li.mul(_cnt / 100.0).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(); //lineLayer.setDataLabelFormat("{value}%"); // Add a multi-color bar layer using the given data BarLayer barLayer = c.addBarLayer3(am.mul(_cnt / 100.0).result(), _colors); barLayer.setBorderColor(Chart.Transparent); barLayer.setAggregateLabelStyle(); c.xAxis().setLabelStyle("Arial Bold", 11); c.yAxis().setLabelStyle("Arial Bold", 11); // c.yAxis2().setLabelStyle("Arial Bold", 9); // Set the labels on the x axis. c.xAxis().setLabels(_strLabel); // Set the secondary (right) y-axis scale as 0 - 100 with a tick every 20 // units c.yAxis().setLinearScale(dMin, dMax, dIncr); // c.yAxis2().setLinearScale(-140, 60, 20); // Set the format of the secondary (right) y-axis label to include a // percentage sign // c.yAxis2().setLabelFormat("{value}%"); // Set the format of the primary y-axis label foramt to show no decimal // point c.yAxis().setLabelFormat("{value|0}"); c.setNumberFormat(','); // Output the chart viewer.Chart = c; }
// // 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'"); }
//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 }; string[] labels = { "Mon", "Tue", "Wed", "Thur", "Fri" }; // Create a XYChart object of size 540 x 375 pixels XYChart c = new XYChart(540, 375); // Add a title to the chart using 18 pts Times Bold Italic font c.addTitle("Average Weekly Network Load", "Times New Roman Bold Italic", 18); // Set the plotarea at (50, 55) and of 440 x 280 pixels in size. Use a // vertical gradient color from light red (ffdddd) to dark red (880000) // as background. Set border and grid lines to white (ffffff). c.setPlotArea(50, 55, 440, 280, c.linearGradientColor(0, 55, 0, 335, 0xffdddd, 0x880000), -1, 0xffffff, 0xffffff); // Add a legend box at (50, 25) using horizontal layout. Use 10pts Arial // Bold as font, with transparent background. c.addLegend(50, 25, false, "Arial Bold", 10).setBackground( Chart.Transparent); // Set the x axis labels c.xAxis().setLabels(labels); // Draw the ticks between label positions (instead of at label positions) c.xAxis().setTickOffset(0.5); // Set axis label style to 8pts Arial Bold c.xAxis().setLabelStyle("Arial Bold", 8); c.yAxis().setLabelStyle("Arial Bold", 8); // Set axis line width to 2 pixels c.xAxis().setWidth(2); c.yAxis().setWidth(2); // Add axis title c.yAxis().setTitle("Throughput (MBytes Per Hour)"); // Add a multi-bar layer with 3 data sets and 4 pixels 3D depth BarLayer layer = c.addBarLayer2(Chart.Side, 4); layer.addDataSet(data0, 0xffff00, "Server #1"); layer.addDataSet(data1, 0x00ff00, "Server #2"); layer.addDataSet(data2, 0x9999ff, "Server #3"); // Set bar border to transparent. Use soft lighting effect with light // direction from top. layer.setBorderColor(Chart.Transparent, Chart.softLighting(Chart.Top)); // Configure the bars within a group to touch each others (no gap) layer.setBarGap(0.2, Chart.TouchBar); // 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'"); }
//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[] data0 = { 100, 115, 165, 107, 67 }; double[] data1 = { 85, 106, 129, 161, 123 }; double[] data2 = { 67, 87, 86, 167, 157 }; // The labels for the bar chart string[] labels = { "Mon", "Tue", "Wed", "Thu", "Fri" }; // 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 400 x 300 pixels, with transparent // background and border and light grey (0xcccccc) horizontal grid lines c.setPlotArea(70, 20, 400, 300, Chart.Transparent, -1, Chart.Transparent, 0xcccccc); // Add a legend box at (480, 20) using vertical layout and 12pt Arial font. Set // background and border to transparent and key icon border to the same as the fill // color. LegendBox b = c.addLegend(480, 20, true, "Arial", 12); b.setBackground(Chart.Transparent, Chart.Transparent); b.setKeyBorder(Chart.SameAsMainColor); // 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 stacked bar layer BarLayer layer = c.addBarLayer2(Chart.Stack); // Add the three data sets to the bar layer layer.addDataSet(data0, 0xaaccee, "Server # 1"); layer.addDataSet(data1, 0xbbdd88, "Server # 2"); layer.addDataSet(data2, 0xeeaa66, "Server # 3"); // Set the bar border to transparent layer.setBorderColor(Chart.Transparent); // Enable labelling for the entire bar and use 12pt Arial font layer.setAggregateLabelStyle("Arial", 12); // Enable labelling for the bar segments and use 12pt Arial font with center alignment layer.setDataLabelStyle("Arial", 10).setAlignment(Chart.Center); // For a vertical stacked bar with positive data, the first data set is at the bottom. // For the legend box, by default, the first entry at the top. We can reverse the legend // order to make the legend box consistent with the stacked bar. layer.setLegendOrder(Chart.ReverseLegend); // 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='{dataSetName} on {xLabel}: {value} MBytes/hour'"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // The data for the chart double[] data = { 40, 15, 7, 5, 2 }; // The labels for the chart string[] labels = { "Hard Disk", "PCB", "Printer", "CDROM", "Keyboard" }; // 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); 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("Pareto Chart Demonstration", "Arial Italic", 15); title.setMargin2(0, 0, 12, 12); // 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)); // 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 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.addBarLayer3(data); // Set soft lighting for the bars with light direction from the right barLayer.setBorderColor(Chart.Transparent, Chart.softLighting(Chart.Right)); // 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, 20); // 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().syncAxis(c.yAxis2(), scaleFactor); // Set the format of the primary y-axis label foramt to show no decimal point c.yAxis().setLabelFormat("{value|0}"); // 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.Image = c.makeWebImage(Chart.JPG); // Include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap(""); }
//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 data for the chart double[] data0 = { 100, 125, 245, 147, 67 }; double[] data1 = { 85, 156, 179, 211, 123 }; double[] data2 = { 97, 87, 56, 267, 157 }; string[] labels = { "Mon Jun 4", "Tue Jun 5", "Wed Jun 6", "Thu Jun 7", "Fri Jun 8" }; // Create a XYChart object of size 540 x 350 pixels XYChart c = new XYChart(540, 350); // Set the plot area to start at (120, 40) and of size 280 x 240 pixels c.setPlotArea(120, 40, 280, 240); // Add a title to the chart using 20pt Times Bold Italic (timesbi.ttf) font and using a // deep blue color (0x000080) c.addTitle("Weekly Server Load", "Times New Roman Bold Italic", 20, 0x000080); // Add a legend box at (420, 100) (right of plot area) using 12pt Times Bold font. Sets // the background of the legend box to light grey 0xd0d0d0 with a 1 pixel 3D border. c.addLegend(420, 100, true, "Times New Roman Bold", 12).setBackground(0xd0d0d0, 0xd0d0d0, 1); // Add a title to the y-axis using 12pt Arial Bold/deep blue (0x000080) font. Set the // background to yellow (0xffff00) with a 2 pixel 3D border. c.yAxis().setTitle("Throughput (per hour)", "Arial Bold", 12, 0x000080).setBackground( 0xffff00, 0xffff00, 2); // Use 10pt Arial Bold/orange (0xcc6600) font for the y axis labels c.yAxis().setLabelStyle("Arial Bold", 10, 0xcc6600); // Set the axis label format to "nnn MBytes" c.yAxis().setLabelFormat("{value} MBytes"); // Use 10pt Arial Bold/green (0x008000) font for the x axis labels. Set the label angle // to 45 degrees. c.xAxis().setLabelStyle("Arial Bold", 10, 0x008000).setFontAngle(45); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Add a 3D stack bar layer with a 3D depth of 5 pixels BarLayer layer = c.addBarLayer2(Chart.Stack, 5); // Use Arial Italic as the default data label font in the bars layer.setDataLabelStyle("Arial Italic"); // Use 10pt Times Bold Italic (timesbi.ttf) as the aggregate label font. Set the // background to flesh (0xffcc66) color with a 1 pixel 3D border. layer.setAggregateLabelStyle("Times New Roman Bold Italic", 10).setBackground(0xffcc66, Chart.Transparent, 1); // Add the first data set to the stacked bar layer layer.addDataSet(data0, -1, "Server #1"); // Add the second data set to the stacked bar layer layer.addDataSet(data1, -1, "Server #2"); // Add the third data set to the stacked bar layer, and set its data label font to Arial // Bold Italic. ChartDirector.TextBox textbox = layer.addDataSet(data2, -1, "Server #3" ).setDataLabelStyle("Arial Bold Italic"); // Set the data label font color for the third data set to yellow (0xffff00) textbox.setFontColor(0xffff00); // Set the data label background color to the same color as the bar segment, with a 1 // pixel 3D border. textbox.setBackground(Chart.SameAsMainColor, Chart.Transparent, 1); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{dataSetName} on {xLabel}: {value} MBytes/hour'"); }
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 chartIndex is unused because this demo only has 1 chart. public void createChart(WPFChartViewer viewer, int chartIndex) { // The data for the bar chart double[] data = { 85, 156, 179.5, 211, 123, 176, 195 }; // The labels for the bar chart string[] labels = { "Square", "Star(8)", "Polygon(6)", "Cross", "Cross2", "Diamond", "Custom" }; // Create a XYChart object of size 500 x 280 pixels. XYChart c = new XYChart(500, 280); // Set the plotarea at (50, 40) with alternating light grey (f8f8f8) / white (ffffff) // background c.setPlotArea(50, 40, 400, 200, 0xf8f8f8, 0xffffff); // Add a title to the chart using 14pt Arial Bold Italic font c.addTitle(" Bar Shape Demonstration", "Arial Bold Italic", 14); // Add a multi-color bar chart layer BarLayer layer = c.addBarLayer3(data); // Set layer to 3D with 10 pixels 3D depth layer.set3D(10); // Set bar shape to circular (cylinder) layer.setBarShape(Chart.CircleShape); // Set the first bar (index = 0) to square shape layer.setBarShape(Chart.SquareShape, 0, 0); // Set the second bar to 8-pointed star layer.setBarShape(Chart.StarShape(8), 0, 1); // Set the third bar to 6-sided polygon layer.setBarShape(Chart.PolygonShape(6), 0, 2); // Set the next 3 bars to cross shape, X shape and diamond shape layer.setBarShape(Chart.CrossShape(), 0, 3); layer.setBarShape(Chart.Cross2Shape(), 0, 4); layer.setBarShape(Chart.DiamondShape, 0, 5); // Set the last bar to a custom shape, specified as an array of (x, y) points in // normalized coordinates layer.setBarShape2(new int[] { -500, 0, 0, 500, 500, 0, 500, 1000, 0, 500, -500, 1000 }, 0, 6); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Add a title to the y axis c.yAxis().setTitle("Frequency"); // Add a title to the x axis c.xAxis().setTitle("Shapes"); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{xLabel}: {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"); }
//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"); }
//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 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. 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(500, 320); 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. Set top/bottom margins to 15 // pixels. ChartDirector.TextBox title = c.addTitle("Weekly Product Sales", "Arial Italic", 15); title.setMargin2(0, 0, 15, 15); // Tentatively set the plotarea to 50 pixels from the left edge, and to just under the // title. Set the width to 60% of the chart width, and the height to 50 pixels from the // bottom edge. Use pale blue (e8f0f8) background, transparent border, and grey (aaaaaa) // grid lines. c.setPlotArea(50, title.getHeight(), c.getWidth() * 6 / 10, c.getHeight() - title.getHeight() - 50, 0xe8f0f8, -1, Chart.Transparent, 0xaaaaaa); // Add a legend box where the top-right corner is anchored at 10 pixels from the right // edge, and just under the title. Use vertical layout and 8 points Arial font. LegendBox legendBox = c.addLegend(c.getWidth() - 10, title.getHeight(), true, "Arial", 8 ); legendBox.setAlignment(Chart.TopRight); // Set the legend box background and border to transparent legendBox.setBackground(Chart.Transparent, Chart.Transparent); // Set the legend box icon size to 16 x 32 pixels to match with custom icon size legendBox.setKeySize(16, 32); // 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 percentage bar layer BarLayer layer = c.addBarLayer2(Chart.Percentage); // Add the three data sets to the bar layer, using icons images with labels as data set // names layer.addDataSet(data0, 0x66aaee, "<*block,valign=absmiddle*><*img=service.png*> Service<*/*>"); layer.addDataSet(data1, 0xeebb22, "<*block,valign=absmiddle*><*img=software.png*> Software<*/*>"); layer.addDataSet(data2, 0xcc88ff, "<*block,valign=absmiddle*><*img=computer.png*> Hardware<*/*>"); // Use soft lighting effect with light direction from top layer.setBorderColor(Chart.Transparent, Chart.softLighting(Chart.Top)); // Enable data label at the middle of the the bar layer.setDataLabelStyle().setAlignment(Chart.Center); // For a vertical stacked chart with positive data only, the last data set is always on // top. However, in a vertical legend box, the last data set is at the bottom. This can // be reversed by using the setLegend method. layer.setLegend(Chart.ReverseLegend); // Adjust the plot area size, such that the bounding box (inclusive of axes) is 15 // pixels from the left edge, just below the title, 10 pixels to the right of the legend // box, and 15 pixels from the bottom edge. c.packPlotArea(15, title.getHeight(), c.layoutLegend().getLeftX() - 10, c.getHeight() - 15); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{dataSetName} revenue on {xLabel}: US${value}K ({percent}%)'"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // The data for the bar chart double[] data0 = { 44, 55, 100 }; double[] data1 = { 97, 87, 167 }; double[] data2 = { 156, 78, 147 }; double[] data3 = { 125, 118, 211 }; // The labels for the bar chart. The labels contains embedded images as icons. string[] labels = { "<*img=service.png*><*br*>Service", "<*img=software.png*><*br*>Software", "<*img=computer.png*><*br*>Hardware" }; // Create a XYChart object of size 600 x 350 pixels, using 0xe0e0ff as the background color, // 0xccccff as the border color, with 1 pixel 3D border effect. XYChart c = new XYChart(600, 350, 0xe0e0ff, 0xccccff, 1); //Set default directory for loading images c.setSearchPath(Url.Content("~/Content")); // Add a title to the chart using 14 points Times Bold Itatic font and light blue (0x9999ff) // as the background color c.addTitle("Business Results 2001 vs 2002", "Times New Roman Bold Italic", 14).setBackground( 0x9999ff); // Set the plotarea at (60, 45) and of size 500 x 210 pixels, using white (0xffffff) as the // background c.setPlotArea(60, 45, 500, 210, 0xffffff); // Swap the x and y axes to create a horizontal bar chart c.swapXY(); // Add a title to the y axis using 11 pt Times Bold Italic as font c.yAxis().setTitle("Revenue (millions)", "Times New Roman Bold Italic", 11); // Set the labels on the x axis c.xAxis().setLabels(labels); // Disable x-axis ticks by setting the tick length to 0 c.xAxis().setTickLength(0); // Add a stacked bar layer to the chart BarLayer layer = c.addBarLayer2(Chart.Stack); // Add the first two data sets to the chart as a stacked bar group layer.addDataGroup("2001"); layer.addDataSet(data0, 0xaaaaff, "Local"); layer.addDataSet(data1, 0x6666ff, "International"); // Add the remaining data sets to the chart as another stacked bar group layer.addDataGroup("2002"); layer.addDataSet(data2, 0xffaaaa, "Local"); layer.addDataSet(data3, 0xff6666, "International"); // Set the sub-bar gap to 0, so there is no gap between stacked bars with a group layer.setBarGap(0.2, 0); // Set the bar border to transparent layer.setBorderColor(Chart.Transparent); // Set the aggregate label format layer.setAggregateLabelFormat("Year {dataGroupName}\n{value} millions"); // Set the aggregate label font to 8 point Arial Bold Italic layer.setAggregateLabelStyle("Arial Bold Italic", 8); // Reverse 20% space at the right during auto-scaling to allow space for the aggregate bar // labels c.yAxis().setAutoScale(0.2); // Add a legend box at (310, 300) using TopCenter alignment, with 2 column grid layout, and // use 8pt Arial Bold Italic as font LegendBox legendBox = c.addLegend2(310, 300, 2, "Arial Bold Italic", 8); legendBox.setAlignment(Chart.TopCenter); // Set the format of the text displayed in the legend box legendBox.setText("Year {dataGroupName} {dataSetName} Revenue"); // Set the background and border of the legend box to transparent legendBox.setBackground(Chart.Transparent, Chart.Transparent); // Output the chart viewer.Image = c.makeWebImage(Chart.PNG); // Include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("", "", "title='Year {dataGroupName} {dataSetName} {xLabel} Revenue: {value} millions'"); }