//Main code for creating charts public void createChart(WinChartViewer viewer, int chartIndex) { // The data for the chart double[] data = { 100, 125, 260, 147, 67 }; string[] labels = { "Mon", "Tue", "Wed", "Thu", "Fri" }; // Create a XYChart object of size 200 x 180 pixels XYChart c = new XYChart(200, 180); // Set the plot area at (30, 10) and of size 140 x 130 pixels c.setPlotArea(30, 10, 140, 130); // Ise log scale axis if required if (chartIndex == 1) { c.yAxis().setLogScale3(); } // Set the labels on the x axis c.xAxis().setLabels(labels); // Add a color bar layer using the given data. Use a 1 pixel 3D border for the bars. c.addBarLayer3(data).setBorderColor(-1, 1); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='Mileage on {xLabel}: {value} miles'"); }
//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 = { 450, 560, 630, 800, 1100, 1350, 1600, 1950, 2300, 2700 }; // The labels for the bar chart string[] labels = { "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005" }; // Create a XYChart object of size 600 x 380 pixels. Set background color // to brushed silver, with a 2 pixel 3D border. Use rounded corners of 20 // pixels radius. XYChart c = new XYChart(600, 380, Chart.brushedSilverColor(), Chart.Transparent, 2); // Add a title to the chart using 18pts Times Bold Italic font. Set // top/bottom margins to 8 pixels. c.addTitle("Annual Revenue for Star Tech", "Times New Roman Bold Italic", 18).setMargin2(0, 0, 8, 8); // Set the plotarea at (70, 55) and of size 460 x 280 pixels. Use // transparent border and black grid lines. Use rounded frame with radius // of 20 pixels. c.setPlotArea(70, 55, 460, 280, -1, -1, Chart.Transparent, 0x000000); c.setRoundedFrame(0xffffff, 20); // Add a multi-color bar chart layer using the supplied data. Set // cylinder bar shape. c.addBarLayer3(data).setBarShape(Chart.CircleShape); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Show the same scale on the left and right y-axes c.syncYAxis(); // Set the left y-axis and right y-axis title using 10pt Arial Bold font c.yAxis().setTitle("USD (millions)", "Arial Bold", 10); c.yAxis2().setTitle("USD (millions)", "Arial Bold", 10); // Set y-axes to transparent c.yAxis().setColors(Chart.Transparent); c.yAxis2().setColors(Chart.Transparent); // Disable ticks on the x-axis by setting the tick color to transparent c.xAxis().setTickColor(Chart.Transparent); // Set the label styles of all axes to 8pt Arial Bold font c.xAxis().setLabelStyle("Arial Bold", 8); c.yAxis().setLabelStyle("Arial Bold", 8); c.yAxis2().setLabelStyle("Arial Bold", 8); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='Year {xLabel}: US$ {value}M'"); }
//Main code for creating charts public void createChart(WinChartViewer viewer, string img) { // The data for the chart double[] data = { 5.5, 3.5, -3.7, 1.7, -1.4, 3.3 }; string[] labels = { "Jan", "Feb", "Mar", "Apr", "May", "Jun" }; // Create a XYChart object of size 200 x 190 pixels XYChart c = new XYChart(200, 190); // Set the plot area at (30, 20) and of size 140 x 140 pixels c.setPlotArea(30, 20, 140, 140); // Configure the axis as according to the input parameter if (img == "0") { c.addTitle("No Axis Extension", "Arial", 8); } else if (img == "1") { c.addTitle("Top/Bottom Extensions = 0/0", "Arial", 8); // Reserve 20% margin at top of plot area when auto-scaling c.yAxis().setAutoScale(0, 0); } else if (img == "2") { c.addTitle("Top/Bottom Extensions = 0.2/0.2", "Arial", 8); // Reserve 20% margin at top and bottom of plot area when // auto-scaling c.yAxis().setAutoScale(0.2, 0.2); } else if (img == "3") { c.addTitle("Axis Top Margin = 15", "Arial", 8); // Reserve 15 pixels at top of plot area c.yAxis().setMargin(15); } else { c.addTitle("Manual Scale -5 to 10", "Arial", 8); // Set the y axis to scale from -5 to 10, with ticks every 5 units c.yAxis().setLinearScale(-5, 10, 5); } // Set the labels on the x axis c.xAxis().setLabels(labels); // Add a color bar layer using the given data. Use a 1 pixel 3D border // for the bars. c.addBarLayer3(data).setBorderColor(-1, 1); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='ROI for {xLabel}: {value}%'"); }
//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 = { 450, 560, 630, 800, 1100, 1350, 1600, 1950, 2300, 2700 }; // The labels for the bar chart string[] labels = { "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005" }; // Create a XYChart object of size 600 x 360 pixels XYChart c = new XYChart(600, 360); // Set the plotarea at (60, 40) and of size 480 x 280 pixels. Use a // vertical gradient color from light blue (eeeeff) to deep blue (0000cc) // as background. Set border and grid lines to white (ffffff). c.setPlotArea(60, 40, 480, 280, c.linearGradientColor(60, 40, 60, 280, 0xeeeeff, 0x0000cc), -1, 0xffffff, 0xffffff); // Add a title to the chart using 18pts Times Bold Italic font c.addTitle("Annual Revenue for Star Tech", "Times New Roman Bold Italic", 18); // Add a multi-color bar chart layer using the supplied data. Use glass // lighting effect with light direction from the left. c.addBarLayer3(data).setBorderColor(Chart.Transparent, Chart.glassEffect( Chart.NormalGlare, Chart.Left)); // Set the x axis labels c.xAxis().setLabels(labels); // Show the same scale on the left and right y-axes c.syncYAxis(); // Set the left y-axis and right y-axis title using 10pt Arial Bold font c.yAxis().setTitle("USD (millions)", "Arial Bold", 10); c.yAxis2().setTitle("USD (millions)", "Arial Bold", 10); // Set all axes to transparent c.xAxis().setColors(Chart.Transparent); c.yAxis().setColors(Chart.Transparent); c.yAxis2().setColors(Chart.Transparent); // Set the label styles of all axes to 8pt Arial Bold font c.xAxis().setLabelStyle("Arial Bold", 8); c.yAxis().setLabelStyle("Arial Bold", 8); c.yAxis2().setLabelStyle("Arial Bold", 8); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='Year {xLabel}: US$ {value}M'"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // The data for the bar chart double[] data = { 450, 560, 630, 800, 1100, 1350, 1600, 1950, 2300, 2700 }; // The labels for the bar chart string[] labels = { "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005" }; // Create a XYChart object of size 600 x 360 pixels XYChart c = new XYChart(600, 360); // Add a title to the chart using 18pt Times Bold Italic font c.addTitle("Annual Revenue for Star Tech", "Times New Roman Bold Italic", 18); // Set the plotarea at (60, 40) and of size 500 x 280 pixels. Use a vertical gradient color // from light blue (eeeeff) to deep blue (0000cc) as background. Set border and grid lines to // white (ffffff). c.setPlotArea(60, 40, 500, 280, c.linearGradientColor(60, 40, 60, 280, 0xeeeeff, 0x0000cc), -1, 0xffffff, 0xffffff); // Add a multi-color bar chart layer using the supplied data. Use soft lighting effect with // light direction from top. c.addBarLayer3(data).setBorderColor(Chart.Transparent, Chart.softLighting(Chart.Top)); // Set x axis labels using the given labels c.xAxis().setLabels(labels); // Draw the ticks between label positions (instead of at label positions) c.xAxis().setTickOffset(0.5); // When auto-scaling, use tick spacing of 40 pixels as a guideline c.yAxis().setTickDensity(40); // Add a title to the y axis with 12pt Times Bold Italic font c.yAxis().setTitle("USD (millions)", "Times New Roman Bold Italic", 12); // 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); // Create the image and save it in a temporary location viewer.Image = c.makeWebImage(Chart.PNG); // Create an image map for the chart viewer.ImageMap = c.getHTMLImageMap(Url.Action("", "clickline"), "", "title='{xLabel}: US$ {value|0}M'"); }
//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'"); }
//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 = { 450, 560, 630, 800, 1100, 1350, 1600, 1950, 2300, 2700 }; // The labels for the bar chart string[] labels = { "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005" }; // Create a XYChart object of size 600 x 360 pixels XYChart c = new XYChart(600, 360); // Add a title to the chart using 18pts Times Bold Italic font c.addTitle("Annual Revenue for Star Tech", "Times New Roman Bold Italic", 18); // Set the plotarea at (60, 40) and of size 500 x 280 pixels. Use a // vertical gradient color from light blue (eeeeff) to deep blue (0000cc) // as background. Set border and grid lines to white (ffffff). c.setPlotArea(60, 40, 500, 280, c.linearGradientColor(60, 40, 60, 280, 0xeeeeff, 0x0000cc), -1, 0xffffff, 0xffffff); // Add a multi-color bar chart layer using the supplied data. Use soft // lighting effect with light direction from left. c.addBarLayer3(data).setBorderColor(Chart.Transparent, Chart.softLighting(Chart.Left)); // Set x axis labels using the given labels c.xAxis().setLabels(labels); // Draw the ticks between label positions (instead of at label positions) c.xAxis().setTickOffset(0.5); // Add a title to the y axis with 10pts Arial Bold font c.yAxis().setTitle("USD (millions)", "Arial Bold", 10); // 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); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='Year {xLabel}: US$ {value}M'"); }
//Main code for creating charts public void createChart(WinChartViewer viewer, string img) { // The data for the chart double[] data = { 85, 156, 179.5, 211, 123 }; string[] labels = { "Mon", "Tue", "Wed", "Thu", "Fri" }; // Create a XYChart object of size 270 x 270 pixels XYChart c = new XYChart(270, 270); // Set the plot area at (40, 32) and of size 200 x 200 pixels PlotArea plotarea = c.setPlotArea(40, 32, 200, 200); // Set the background style based on the input parameter if (img == "0") { // Has wallpaper image c.setWallpaper("tile.gif"); } else if (img == "1") { // Use a background image as the plot area background plotarea.setBackground2("bg.png"); } else if (img == "2") { // Use white (0xffffff) and grey (0xe0e0e0) as two alternate plotarea // background colors plotarea.setBackground(0xffffff, 0xe0e0e0); } else { // Use a dark background palette c.setColors(Chart.whiteOnBlackPalette); } // Set the labels on the x axis c.xAxis().setLabels(labels); // Add a color bar layer using the given data. Use a 1 pixel 3D border // for the bars. c.addBarLayer3(data).setBorderColor(-1, 1); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='Revenue for {xLabel}: US${value}K'"); }
// // 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" }; // The colors for the bars int[] colors = { 0x5588bb, 0x66bbbb, 0xaa6644, 0x99bb55, 0xee9944, 0x444466, 0xbb5555 }; // 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 font c.addTitle("Multi-Color Bar Chart", "Arial", 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 multi-color bar chart layer with transparent border using the given data c.addBarLayer3(data, colors).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 font c.yAxis().setTitle("Y-Axis Title Placeholder", "Arial", 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'"); }
//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}'"); }
//Main code for creating charts public void createChart(WinChartViewer viewer, string img) { // The data for the chart double[] data = { 100, 125, 265, 147, 67, 105 }; string[] labels = { "Jan", "Feb", "Mar", "Apr", "May", "Jun" }; // Create a XYChart object of size 250 x 250 pixels XYChart c = new XYChart(250, 250); // Set the plot area at (27, 25) and of size 200 x 200 pixels c.setPlotArea(27, 25, 200, 200); if (img == "1") { // High tick density, uses 10 pixels as tick spacing c.addTitle("Tick Density = 10 pixels"); c.yAxis().setTickDensity(10); } else { // Normal tick density, just use the default setting c.addTitle("Default Tick Density"); } // Set the labels on the x axis c.xAxis().setLabels(labels); // Add a color bar layer using the given data. Use a 1 pixel 3D border // for the bars. c.addBarLayer3(data).setBorderColor(-1, 1); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='Revenue for {xLabel}: US${value}M'"); }
//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" }; // The colors for the bar chart int[] colors = { 0xb8bc9c, 0xa0bdc4, 0x999966, 0x333366, 0xc3c3e6 }; // Create a XYChart object of size 300 x 220 pixels. Use golden // background color. Use a 2 pixel 3D border. XYChart c = new XYChart(300, 220, Chart.goldColor(), -1, 2); // Add a title box using 10 point Arial Bold font. Set the background // color to metallic blue (9999FF) Use a 1 pixel 3D border. c.addTitle("Daily Network Load", "Arial Bold", 10).setBackground( Chart.metalColor(0x9999ff), -1, 1); // Set the plotarea at (40, 40) and of 240 x 150 pixels in size c.setPlotArea(40, 40, 240, 150); // Add a multi-color bar chart layer using the given data and colors. Use // a 1 pixel 3D border for the bars. c.addBarLayer3(data, colors).setBorderColor(-1, 1); // 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}: {value} GBytes'"); }
// // 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 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}'"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // The data for the bar chart double[] data = { 1350, 1600, 1950, 2300, 2700 }; // The labels for the bar chart string[] labels = { "2001", "2002", "2003", "2004", "2005" }; // The colors for the bars int[] colors = { 0xcc0000, 0x66aaee, 0xeebb22, 0xcccccc, 0xcc88ff }; // Create a PieChart object of size 600 x 380 pixels. XYChart c = new XYChart(600, 380); // Use the white on black palette, which means the default text and line colors are white c.setColors(Chart.whiteOnBlackPalette); // Use a vertical gradient color from blue (0000cc) to deep blue (000044) as background. Use // rounded corners of 30 pixels radius for the top-left and bottom-right corners. c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight(), 0x0000cc, 0x000044)); c.setRoundedFrame(0xffffff, 30, 0, 30, 0); // Add a title using 18pt Times New Roman Bold Italic font. Add 6 pixels top and bottom // margins to the title. ChartDirector.TextBox title = c.addTitle("Annual Revenue for Star Tech", "Times New Roman Bold Italic", 18); title.setMargin2(0, 0, 6, 6); // Add a separator line in white color just under the title c.addLine(20, title.getHeight(), c.getWidth() - 21, title.getHeight(), 0xffffff); // Tentatively set the plotarea at (70, 80) and of 480 x 240 pixels in size. Use transparent // border and white grid lines c.setPlotArea(70, 80, 480, 240, -1, -1, Chart.Transparent, 0xffffff); // Swap the axis so that the bars are drawn horizontally c.swapXY(); // Add a multi-color bar chart layer using the supplied data. Use bar gradient lighting with // the light intensity from 0.75 to 2.0 c.addBarLayer3(data, colors).setBorderColor(Chart.Transparent, Chart.barLighting(0.75, 2.0)); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Show the same scale on the left and right y-axes c.syncYAxis(); // Set the bottom y-axis title using 10pt Arial Bold font c.yAxis().setTitle("USD (millions)", "Arial Bold", 10); // Set y-axes to transparent c.yAxis().setColors(Chart.Transparent); c.yAxis2().setColors(Chart.Transparent); // Disable ticks on the x-axis by setting the tick color to transparent c.xAxis().setTickColor(Chart.Transparent); // Set the label styles of all axes to 8pt Arial Bold font c.xAxis().setLabelStyle("Arial Bold", 8); c.yAxis().setLabelStyle("Arial Bold", 8); c.yAxis2().setLabelStyle("Arial Bold", 8); // Adjust the plot area size, such that the bounding box (inclusive of axes) is 30 pixels // from the left edge, 25 pixels below the title, 50 pixels from the right edge, and 25 // pixels from the bottom edge. c.packPlotArea(30, title.getHeight() + 25, c.getWidth() - 50, c.getHeight() - 25); // Output the chart viewer.Image = c.makeWebImage(Chart.PNG); // Include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("", "", "title='Year {xLabel}: US$ {value}M'"); }
public byte[] CreateBar(double[] dateItem, string[] labels, string title, string bottom_text, string left_text, string scaleFromat) { string font_1 = "微軟正黑體"; string font_2 = "新細明體"; int CanvasWidth = CommWebSetup.Chart_Canvas_Width; int DiagramWidth = CommWebSetup.Chart_Diagram_Width; XYChart xyCht = new XYChart(CanvasWidth, CommWebSetup.Chart_Canvas_Height, 0xffffff, 0xffffff, 0); //設定畫布區大小 //parm 5:奇數列顏色 //parm 6:偶數列顏色 //parm 7:外框顏色 xyCht.setPlotArea(60, 72, DiagramWidth, CommWebSetup.Chart_Diagram_Height, 0xffffff, 0xffffff, 0xffffff, 0x999999, 0xffffff); //繪制圖表的位置及大小 xyCht.setRoundedFrame(); TextBox getTitleText = xyCht.addTitle(title, CommWebSetup.Chart_Title_FontFamily, CommWebSetup.Chart_Title_FontSize, CommWebSetup.Chart_Title_FontColor, 0xffffff); getTitleText.setHeight(CommWebSetup.Chart_Title_Height); getTitleText.setAlignment(Chart.Center); //設定上方資訊綜合區 LegendBox legendBox = xyCht.addLegend(72, getTitleText.getHeight(), false, font_1, 10); legendBox.setAlignment(Chart.TopLeft); legendBox.setBackground(Chart.Transparent, Chart.Transparent); //左側處理 TextBox getY = xyCht.yAxis().setTitle(left_text, font_2, 14); getY.setFontAngle(0, true); xyCht.yAxis().setWidth(2); getY.setHeight(CommWebSetup.Chart_Diagram_Height); var getScaleText = xyCht.yAxis().setLabelStyle(font_2, 9); if (scaleFromat != null) { xyCht.yAxis().setLabelFormat(scaleFromat); //設定左邊刻度格式 //xyCht.yAxis().setLabelFormat("{value}度"); } //底部處理 var getBottomText = xyCht.xAxis().setTitle(bottom_text, font_1, 14); var getBottomlabel = xyCht.xAxis().setLabels(labels); getBottomlabel.setFontSize(9); getBottomlabel.setFontStyle(font_2); //xyCht.xAxis().setLabelStep(3); //設定Label間隔(橫向) 如果Label太密集可在此設定 var col1 = Convert.ToInt32("EA8D8D", 16); var col2 = Convert.ToInt32("FFE699", 16); var col3 = Convert.ToInt32("9DC3E6", 16); var col4 = Convert.ToInt32("70AD47", 16); var col5 = Convert.ToInt32("ED7D31", 16); var colors = new int[] { col1, col2, col3, col4, col5 }; //var names = new string[] { "紅一", "紅二", "紅三", "紅四", "紅五" }; var layer = xyCht.addBarLayer3(dateItem, colors); layer.setAggregateLabelStyle("Arial", 8); layer.setBarWidth(32); return xyCht.makeChart(Chart.PNG); }
private void createBarChart() { int offset = 10; BarChartData data = (BarChartData)this.chartData; this.Label = data.Title; // Create a XYChart object. Use a 2 pixel 3D border. XYChart c = new XYChart(this.chartPanel.Size.Width, this.chartPanel.Size.Height, 0xeeeeff, -1, 2); // Set the plotarea c.setPlotArea(offset, offset, this.chartPanel.Size.Width - (2 * offset), this.chartPanel.Size.Height - (2 * offset), 0xffffff, -1, -1, 0xcccccc, 0xcccccc); // Add a multi-color bar chart layer using the given data and colors. Use // a 1 pixel 3D border for the bars. ChartDirector.BarLayer layer = c.addBarLayer3(data.Data, data.Colors); layer.setBorderColor(-1, 1); layer.set3D(); // Set the labels on the x axis to null => no labels c.yAxis().setLabelFormat(null); // output the chart this.chartPanel.Image = c.makeImage(); }
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; }
private void buildBarChart() { int topMargin = 30; int bottomnMargin = 70; int leftMargin = 50; int rightMargin = 30; BarChartData data = (BarChartData)this.chartData; this.Text = data.Title; XYChart barChart = new XYChart(this.chartPanel.Size.Width, this.chartPanel.Size.Height, 0xeeeeff, -1, 2); barChart.setPlotArea(leftMargin, topMargin, this.chartPanel.Size.Width - (leftMargin + rightMargin), this.chartPanel.Size.Height - (topMargin + bottomnMargin), 0xffffff, -1, -1, 0xcccccc, 0xcccccc); barChart.addTitle(data.Title); // Set the labels on the x axis. barChart.xAxis().setLabels(data.Labels); ChartDirector.BarLayer layer = barChart.addBarLayer3(data.Data, data.Colors, data.Labels); layer.setBorderColor(-1, 1); layer.set3D(); // output the chart this.chartPanel.Image = barChart.makeImage(); }
//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 List <double> data = new List <double>(); // The labels for the bar chart List <string> labels = new List <string>(); foreach (KeyValuePair <string, Tuple <int, DateTime> > d in lotoResults) { int[] nums = d.Key.Split(',').Select(int.Parse).ToArray(); int diff = nums[5] - nums[0]; if (diff == m_diffToShow || m_diffToShow == 1000) { labels.Add(d.Value.Item2.ToShortDateString()); data.Add(diff); } } int width = this.Width; int width1 = this.Width; if (data.Count > 880 && data.Count < 1000) { width = this.Width * 10 + 100; width1 = this.Width * 10; } else if (data.Count > 280 && data.Count < 1000) { width = this.Width * 5 + 100; width1 = this.Width * 5; } else if (data.Count > 1000) { width = this.Width * 20 + 100; width1 = this.Width * 20; } else if (data.Count < 200) { width = this.Width * 2 + 100; width1 = this.Width * 2; } // Create a XYChart object of size 600 x 380 pixels. Set background color to brushed // silver, with a 2 pixel 3D border. Use rounded corners of 20 pixels radius. XYChart c = new XYChart(width, this.Height, Chart.brushedSilverColor(), Chart.Transparent, 2); // Add a title to the chart using 18pt Times Bold Italic font. Set top/bottom margins to // 8 pixels. c.addTitle("Loto Max Min all over years", "Times New Roman Bold Italic", 18 ).setMargin2(0, 0, 8, 8); // Set the plotarea at (70, 55) and of size 460 x 280 pixels. Use transparent border and // black grid lines. Use rounded frame with radius of 20 pixels. c.setPlotArea(70, 55, width1, 480, -1, -1, Chart.Transparent, 0x000000); c.setRoundedFrame(0xffffff, 20); // Add a multi-color bar chart layer using the supplied data. Set cylinder bar shape. c.addBarLayer3(data.ToArray()).setBarShape(Chart.CircleShape); // Set the labels on the x axis. c.xAxis().setLabels(labels.ToArray()); // Show the same scale on the left and right y-axes c.syncYAxis(); // Set the left y-axis and right y-axis title using 10pt Arial Bold font c.yAxis().setTitle("Max - Min", "Arial Bold", 10); c.yAxis2().setTitle("Max - Min", "Arial Bold", 10); // Set y-axes to transparent c.yAxis().setColors(Chart.Transparent); c.yAxis2().setColors(Chart.Transparent); // Disable ticks on the x-axis by setting the tick color to transparent c.xAxis().setTickColor(Chart.Transparent); // Set the label styles of all axes to 8pt Arial Bold font c.xAxis().setLabelStyle("Arial Bold", 8, 90, 90); c.yAxis().setLabelStyle("Arial Bold", 8); c.yAxis2().setLabelStyle("Arial Bold", 8); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='Year {xLabel}: US$ {value}M'"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // // For demo purpose, we use hard coded data. In real life, the following data could come from // a database. // double[] revenue = { 4500, 5600, 6300, 8000, 12000, 14000, 16000, 20000, 24000, 28000 }; double[] grossMargin = { 62, 65, 63, 60, 55, 56, 57, 53, 52, 50 }; double[] backLog = { 563, 683, 788, 941, 1334, 1522, 1644, 1905, 2222, 2544 }; string[] labels = { "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005" }; // Create a XYChart object of size 600 x 360 pixels XYChart c = new XYChart(600, 360); // Add a title to the chart using 18pt Times Bold Italic font c.addTitle("Annual Revenue for Star Tech", "Times New Roman Bold Italic", 18); // Set the plotarea at (60, 40) and of size 480 x 280 pixels. Use a vertical gradient color // from light green (eeffee) to dark green (008800) as background. Set border and grid lines // to white (ffffff). c.setPlotArea(60, 40, 480, 280, c.linearGradientColor(60, 40, 60, 280, 0xeeffee, 0x008800), -1, 0xffffff, 0xffffff); // Add a multi-color bar chart layer using the revenue data. BarLayer layer = c.addBarLayer3(revenue); // Set cylinder bar shape layer.setBarShape(Chart.CircleShape); // Add extra field to the bars. These fields are used for showing additional information. layer.addExtraField2(grossMargin); layer.addExtraField2(backLog); // Set the labels on the x axis. c.xAxis().setLabels(labels); // In this example, we show the same scale using both axes c.syncYAxis(); // Set the axis line to transparent c.xAxis().setColors(Chart.Transparent); c.yAxis().setColors(Chart.Transparent); c.yAxis2().setColors(Chart.Transparent); // Set the axis label to using 8pt Arial Bold as font c.yAxis().setLabelStyle("Arial Bold", 8); c.yAxis2().setLabelStyle("Arial Bold", 8); c.xAxis().setLabelStyle("Arial Bold", 8); // Add title to the y axes c.yAxis().setTitle("USD (millions)", "Arial Bold", 10); c.yAxis2().setTitle("USD (millions)", "Arial Bold", 10); // Create the image and save it in a temporary location viewer.Image = c.makeWebImage(Chart.PNG); // Client side Javascript to show detail information "onmouseover" string showText = "onmouseover='showInfo(\"{xLabel}\", {value}, {field0}, {field1});' "; // Client side Javascript to hide detail information "onmouseout" string hideText = "onmouseout='showInfo(null);' "; // "title" attribute to show tool tip string toolTip = "title='{xLabel}: US$ {value|0}M'"; // Create an image map for the chart viewer.ImageMap = c.getHTMLImageMap(Url.Action("", "xystub"), "", showText + hideText + toolTip); }