//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 area chart double[] data0 = { 42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56, 60, 70, 76, 63, 67, 75, 64, 51 }; double[] data1 = { 50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58, 59, 73, 77, 84, 82, 80, 84, 89 }; double[] data2 = { 87, 89, 85, 66, 53, 39, 24, 21, 37, 56, 37, 22, 21, 33, 13, 17, 4, 23, 16, 25, 9, 10, 5, 7, 6 }; string[] labels = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19","20", "21", "22", "23", "24" }; // Create a XYChart object of size 350 x 230 pixels XYChart c = new XYChart(350, 230); // Set the plotarea at (50, 30) and of size 250 x 150 pixels. c.setPlotArea(50, 30, 250, 150); // Add a legend box at (55, 0) (top of the chart) using 8 pts Arial Font. // Set background and border to Transparent. c.addLegend(55, 0, false, "", 8).setBackground(Chart.Transparent); // Add a title to the x axis c.xAxis().setTitle("Network Load for Jun 12"); // Add a title to the y axis c.yAxis().setTitle("MBytes"); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Display 1 out of 2 labels on the x-axis. Show minor ticks for // remaining labels. c.xAxis().setLabelStep(2, 1); // Add three area layers, each representing one data set. The areas are // drawn in semi-transparent colors. c.addAreaLayer(data2, unchecked ((int)0x808080ff), "Server #1", 3); c.addAreaLayer(data0, unchecked ((int)0x80ff0000), "Server #2", 3); c.addAreaLayer(data1, unchecked ((int)0x8000ff00), "Server #3", 3); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{dataSetName} load at hour {xLabel}: {value} MBytes'"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // The data for the area chart double[] data = { 30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89, 60, 55, 53, 35, 50, 66, 56, 48, 52, 65, 62 }; // The labels for the area chart string[] labels = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24" }; // Create a XYChart object of size 250 x 250 pixels XYChart c = new XYChart(250, 250); // Set the plotarea at (30, 20) and of size 200 x 200 pixels c.setPlotArea(30, 20, 200, 200); // Add an area chart layer using the given data c.addAreaLayer(data); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Display 1 out of 3 labels on the x-axis. c.xAxis().setLabelStep(3); // Output the chart viewer.Image = c.makeWebImage(Chart.PNG); // Include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("", "", "title='Hour {xLabel}: Traffic {value} GBytes'"); }
//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 area chart double[] data = { 3.0, 2.8, 4.0, 5.5, 7.5, 6.8, 5.4, 6.0, 5.0, 6.2, 7.5, 6.5, 7.5, 8.1, 6.0, 5.5, 5.3, 3.5, 5.0, 6.6, 5.6, 4.8, 5.2, 6.5, 6.2 } ; // The labels for the area chart string[] labels = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19","20", "21", "22", "23", "24" }; // Create a XYChart object of size 300 x 180 pixels. Set the background // to pale yellow (0xffffa0) with a black border (0x0) XYChart c = new XYChart(300, 180, 0xffffa0, 0x000000); // Set the plotarea at (45, 35) and of size 240 x 120 pixels. Set the // background to white (0xffffff). Set both horizontal and vertical grid // lines to black (&H0&) dotted lines (pattern code 0x0103) c.setPlotArea(45, 35, 240, 120, 0xffffff, -1, -1, c.dashLineColor( 0x000000, 0x000103), c.dashLineColor(0x000000, 0x000103)); // Add a title to the chart using 10 pts Arial Bold font. Use a 1 x 2 // bitmap pattern as the background. Set the border to black (0x0). c.addTitle("Snow Percipitation (Dec 12)", "Arial Bold", 10 ).setBackground(c.patternColor(new int[] { 0xb0b0f0, 0xe0e0ff }, 2), 0x000000); // Add a title to the y axis c.yAxis().setTitle("mm per hour"); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Display 1 out of 3 labels on the x-axis. c.xAxis().setLabelStep(3); // Add an area layer to the chart AreaLayer layer = c.addAreaLayer(); // Load a snow pattern from an external file "snow.png". int snowPattern = c.patternColor2("snow.png"); // Add a data set to the area layer using the snow pattern as the fill // color. Use deep blue (0x0000ff) as the area border line color // (&H0000ff&) layer.addDataSet(data).setDataColor(snowPattern, 0x0000ff); // Set the line width to 2 pixels to highlight the line layer.setLineWidth(2); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{xLabel}:00 - {value} mm/hour'"); }
//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 area chart double[] data0 = { 42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56, 60, 70, 76, 63, 67, 75, 64, 51 }; double[] data1 = { 50, 45, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58, 59, 73, 77, 84, 82, 80, 84, 89 }; double[] data2 = { 61, 79, 85, 66, 53, 39, 24, 21, 37, 56, 37, 22, 21, 33, 13, 17, 4, 23, 16, 25, 9, 10, 5, 7, 16 }; string[] labels = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19","20", "21", "22", "23", "24" }; // Create a XYChart object of size 500 x 300 pixels XYChart c = new XYChart(500, 300); // Set the plotarea at (90, 30) and of size 300 x 240 pixels. c.setPlotArea(90, 30, 300, 240); // Add a legend box at (405, 100) c.addLegend(405, 100); // Add a title to the chart c.addTitle("Daily System Load"); // Add a title to the y axis. Draw the title upright (font angle = 0) c.yAxis().setTitle("Database\nQueries\n(per sec)").setFontAngle(0); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Display 1 out of 2 labels on the x-axis. Show minor ticks for // remaining labels. c.xAxis().setLabelStep(2, 1); // Add an area layer AreaLayer layer = c.addAreaLayer(); // Draw the area layer in 3D layer.set3D(); // Add the three data sets to the area layer layer.addDataSet(data0, -1, "Server # 1"); layer.addDataSet(data1, -1, "Server # 2"); layer.addDataSet(data2, -1, "Server # 3"); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{dataSetName} load at hour {xLabel}: {value} queries/sec'"); }
//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 area chart double[] data = { 30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89, 60, 55, 53, 35, 50, 66, 56, 48, 52, 65, 62 }; // The labels for the area chart double[] labels = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; // Create a XYChart object of size 320 x 320 pixels XYChart c = new XYChart(320, 320); // Swap the x and y axis to become a rotated chart c.swapXY(); // Set the y axis on the top side (right + rotated = top) c.setYAxisOnRight(); // Reverse the x axis so it is pointing downwards c.xAxis().setReverse(); // Set the plotarea at (50, 50) and of size 200 x 200 pixels. Enable // horizontal and vertical grids by setting their colors to grey // (0xc0c0c0). c.setPlotArea(50, 50, 250, 250).setGridColor(0xc0c0c0, 0xc0c0c0); // Add a line chart layer using the given data c.addAreaLayer(data, c.gradientColor(50, 0, 300, 0, 0xffffff, 0x0000ff)); // Set the labels on the x axis. Append "m" after the value to show the // unit. c.xAxis().setLabels2(labels, "{value} m"); // Display 1 out of 3 labels. c.xAxis().setLabelStep(3); // Add a title to the x axis c.xAxis().setTitle("Depth"); // Add a title to the y axis c.yAxis().setTitle("Carbon Dioxide Concentration (ppm)"); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='Carbon dioxide concentration at {xLabel}: {value} ppm'"); }
//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 area chart double[] data = { 30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89, 60, 55, 53, 35, 50, 66, 56, 48, 52, 65, 62 }; // The labels for the area chart string[] labels = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19","20", "21", "22", "23", "24" }; // Create a XYChart object of size 300 x 300 pixels XYChart c = new XYChart(300, 300); // Set the plotarea at (45, 30) and of size 200 x 200 pixels c.setPlotArea(45, 30, 200, 200); // Add a title to the chart using 12 pts Arial Bold Italic font c.addTitle("Daily Server Utilization", "Arial Bold Italic", 12); // Add a title to the y axis c.yAxis().setTitle("MBytes"); // Add a title to the x axis c.xAxis().setTitle("June 12, 2001"); // Add a green (0x00ff00) 3D area chart layer using the give data c.addAreaLayer(data, 0x00ff00).set3D(); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Display 1 out of 3 labels on the x-axis. c.xAxis().setLabelStep(3); // Output the chart viewer.Image = c.makeImage(); //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='Hour {xLabel}: Traffic {value} MBytes'"); }
//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 chart double[] data = { 30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89, 60, 55, 53, 35, 50, 66, 56, 48, 52, 65, 62 }; // The labels for the chart string[] labels = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24" }; // Create a XYChart object of size 500 x 300 pixels, with a pale yellow (0xffffc0) // background, a black border, and 1 pixel 3D border effect XYChart c = new XYChart(500, 300, 0xffffc0, 0x000000, 1); // Set the plotarea at (55, 50) and of size 420 x 205 pixels, with white background. // Turn on both horizontal and vertical grid lines with light grey color (0xc0c0c0) c.setPlotArea(55, 50, 420, 205, 0xffffff).setGridColor(0xc0c0c0, 0xc0c0c0); // Add a legend box at (55, 25) (top of the chart) with horizontal layout. Use 8pt Arial // font. Set the background and border color to Transparent. LegendBox legendBox = c.addLegend(55, 25, false, "", 8); legendBox.setBackground(Chart.Transparent); // Add keys to the legend box to explain the color zones legendBox.addKey("Normal Zone", unchecked ((int)0x8033ff33)); legendBox.addKey("Alert Zone", unchecked ((int)0x80ff3333)); // Add a title box to the chart using 13pt Arial Bold Italic font. The title is in CDML // and includes embedded images for highlight. The text is white (0xffffff) on a black // background, with a 1 pixel 3D border. c.addTitle( "<*block,valign=absmiddle*><*img=@/images/star.png*><*img=@/images/star.png*> Y " + "Zone Color Demo <*img=@/images/star.png*><*img=@/images/star.png*><*/*>", "Arial Bold Italic", 13, 0xffffff).setBackground(0x000000, -1, 1); // Add a title to the y axis c.yAxis().setTitle("Energy Concentration (KJ per liter)"); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Display 1 out of 3 labels on the x-axis. c.xAxis().setLabelStep(3); // Add a title to the x axis using CDML c.xAxis().setTitle( "<*block,valign=absmiddle*><*img=@/images/clock.png*> Elapsed Time (hour)<*/*>"); // Set the axes width to 2 pixels c.xAxis().setWidth(2); c.yAxis().setWidth(2); // Add an area layer to the chart. The area is using a y zone color, where the color is // semi-transparent green below 60, and semi-transparent red above 60. c.addAreaLayer(data, c.yZoneColor(60, unchecked ((int)0x8033ff33), unchecked ((int)0x80ff3333))); // Add a custom CDML text at the bottom right of the plot area as the logo c.addText(475, 255, "<*block,valign=absmiddle*><*img=@/images/small_molecule.png*> <*block*>" + "<*font=Times New Roman Bold Italic,size=10,color=804040*>Molecular\nEngineering" + "<*/*>").setAlignment(Chart.BottomRight); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='Hour {xLabel}: {value} KJ/liter'"); }
// // Create chart // private void createChart(RazorChartViewer viewer) { // In this example, we simply use random data for the 2 data series. RanSeries r = new RanSeries(127); double[] data0 = r.getSeries(180, 70, -5, 5); double[] data1 = r.getSeries(180, 150, -15, 15); DateTime[] timeStamps = r.getDateSeries(180, new DateTime(2014, 3, 1), 86400); // Create a XYChart object of size 640 x 420 pixels XYChart c = new XYChart(640, 420); // Add a title to the chart using 20pt Arial font c.addTitle(" Plasma Stabilizer Energy Usage", "Arial", 20); // Set the plotarea at (55, 60) and of size 560 x 330 pixels, with transparent background and // border and light grey (0xcccccc) horizontal grid lines c.setPlotArea(55, 60, 560, 330, -1, -1, Chart.Transparent, 0xcccccc); // Add a legend box at (55, 30) using horizontal layout, with 10pt Arial Bold as font and // transparent background and border. c.addLegend(55, 30, false, "Arial Bold", 10).setBackground(Chart.Transparent); // Set axis label style to 10pt Arial c.xAxis().setLabelStyle("Arial", 10); c.yAxis().setLabelStyle("Arial", 10); // Set the x and y axis stems to transparent, and the x-axis tick color to grey (0xcccccc) c.xAxis().setColors(Chart.Transparent, Chart.TextColor, Chart.TextColor, 0xcccccc); c.yAxis().setColors(Chart.Transparent); // Configure the x-axis tick lengtht to 10 pixels internal to the plot area c.xAxis().setTickLength(-10, 0); // With the ticks internal to the plot area, the x-axis labels will come very close to the // axis stem, so we configure a wider gap. c.xAxis().setLabelGap(10); // For the automatic axis labels, set the minimum spacing to 80/40 pixels for the x/y axis. c.xAxis().setTickDensity(80); c.yAxis().setTickDensity(40); // Use "mm/yyyy" as the x-axis label format for the first plotted month of a year, and "mm" // for other months c.xAxis().setMultiFormat(Chart.StartOfYearFilter(), "{value|mm/yyyy} ", Chart.StartOfMonthFilter(), "{value|mm}"); // Add a title to the y axis using dark grey (0x555555) 12pt Arial Bold font c.yAxis().setTitle("Energy (kWh)", "Arial Bold", 14, 0x555555); // Add a line layer with 2-pixel line width LineLayer layer0 = c.addLineLayer(data0, 0xcc0000, "Power Usage"); layer0.setXData(timeStamps); layer0.setLineWidth(2); // Add an area layer using semi-transparent blue (0x7f0044cc) as the fill color AreaLayer layer1 = c.addAreaLayer(data1, 0x7f0044cc, "Effective Load"); layer1.setXData(timeStamps); layer1.setBorderColor(Chart.SameAsMainColor); // Output the chart viewer.Image = c.makeWebImage(Chart.PNG); // Output Javascript chart model to the browser to suppport tracking cursor viewer.ChartModel = c.getJsChartModel(); }
//Main code for creating chart. //Note: the argument chartIndex is unused because this demo only has 1 chart. public void createChart(WPFChartViewer viewer, int chartIndex) { // In this example, we simply use random data for the 2 data series. RanSeries r = new RanSeries(127); double[] data0 = r.getSeries(180, 70, -5, 5); double[] data1 = r.getSeries(180, 150, -15, 15); DateTime[] timeStamps = r.getDateSeries(180, new DateTime(2014, 3, 1), 86400); // Create a XYChart object of size 640 x 420 pixels XYChart c = new XYChart(640, 420); // Set default text color to dark grey (0x333333) c.setColor(Chart.TextColor, 0x333333); // Add a title box using grey (0x555555) 20pt Arial Bold font c.addTitle(" Plasma Stabilizer Energy Usage", "Arial Bold", 20, 0x555555); // Set the plotarea at (70, 70) and of size 540 x 320 pixels, with transparent // background and border and light grey (0xcccccc) horizontal grid lines c.setPlotArea(70, 70, 540, 320, -1, -1, Chart.Transparent, 0xcccccc); // Add a legend box with horizontal layout above the plot area at (70, 32). Use 12pt // Arial Bold dark grey (0x555555) font, transparent background and border, and line // style legend icon. LegendBox b = c.addLegend(70, 32, false, "Arial Bold", 12); b.setFontColor(0x555555); b.setBackground(Chart.Transparent, Chart.Transparent); b.setLineStyleKey(); // Set axis label font to 12pt Arial c.xAxis().setLabelStyle("Arial", 12); c.yAxis().setLabelStyle("Arial", 12); // Set the x and y axis stems to transparent, and the x-axis tick color to grey // (0xaaaaaa) c.xAxis().setColors(Chart.Transparent, Chart.TextColor, Chart.TextColor, 0xaaaaaa); c.yAxis().setColors(Chart.Transparent); // Set the major/minor tick lengths for the x-axis to 10 and 0. c.xAxis().setTickLength(10, 0); // For the automatic axis labels, set the minimum spacing to 80/40 pixels for the x/y // axis. c.xAxis().setTickDensity(80); c.yAxis().setTickDensity(40); // Use "mm/yyyy" as the x-axis label format for the first plotted month of a year, and // "mm" for other months c.xAxis().setMultiFormat(Chart.StartOfYearFilter(), "{value|mm/yyyy} ", Chart.StartOfMonthFilter(), "{value|mm}"); // Add a title to the y axis using dark grey (0x555555) 12pt Arial Bold font c.yAxis().setTitle("Energy (kWh)", "Arial Bold", 14, 0x555555); // Add a line layer with 2-pixel line width LineLayer layer0 = c.addLineLayer(data0, 0xcc0000, "Power Usage"); layer0.setXData(timeStamps); layer0.setLineWidth(2); // Add an area layer using semi-transparent blue (0x7f0044cc) as the fill color AreaLayer layer1 = c.addAreaLayer(data1, 0x7f0044cc, "Effective Load"); layer1.setXData(timeStamps); layer1.setBorderColor(Chart.SameAsMainColor); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='[{x|mm dd, yyyy}] {value} kWh'"); }
protected void Generate_Forecast(int productid) { int totalCount = 0; Product info = ControllerManager.Product.GetById(productid); IList <ProductInformation> prodinfolist = ControllerManager.Product.GetProductInformation(info.ProductCode, "N/A", 0, 0, 1, 1, out totalCount, false); if (prodinfolist == null || prodinfolist.Count == 0) { return; } ProductInformation prodinfo = prodinfolist[0]; leadtime = prodinfo.LeadTime + 10; //IList<TransactionHistoryWeekly> history = ControllerManager.TransactionHistoryWeekly.GetInfo(prodinfo.Id, Config.CurrentWeek, Config.CurrentDate.Year, 1); List <TransactionHistoryMonthly> historym = ControllerManager.TransactionHistoryMonthly.GetInfo(prodinfo.Id); this.Label12.Text = prodinfo.ProductCode; this.Label3.Text = prodinfo.Description; this.Label5.Text = prodinfo.Provider; this.Label7.Text = prodinfo.Stock.ToString() + "/" + prodinfo.ReservedStock.ToString() + "/" + prodinfo.OrderedStock.ToString(); this.Label9.Text = prodinfo.RepositionLevel.ToString(); this.Label11.Text = prodinfo.RepositionPoint.ToString(); this.Label16.Text = prodinfo.LeadTime.ToString(); this.Label1.Text = prodinfo.Safety.ToString(); this.Label01.Text = GetTransactionMonthly(historym, 1).Sale.ToString(); this.lblY01.Text = GetTransactionMonthly(historym, 1).Year.ToString(); this.Label02.Text = GetTransactionMonthly(historym, 2).Sale.ToString(); this.lblY02.Text = GetTransactionMonthly(historym, 2).Year.ToString(); this.Label03.Text = GetTransactionMonthly(historym, 3).Sale.ToString(); this.lblY03.Text = GetTransactionMonthly(historym, 3).Year.ToString(); this.Label04.Text = GetTransactionMonthly(historym, 4).Sale.ToString(); this.lblY04.Text = GetTransactionMonthly(historym, 4).Year.ToString(); this.Label05.Text = GetTransactionMonthly(historym, 5).Sale.ToString(); this.lblY05.Text = GetTransactionMonthly(historym, 5).Year.ToString(); this.Label06.Text = GetTransactionMonthly(historym, 6).Sale.ToString(); this.lblY06.Text = GetTransactionMonthly(historym, 6).Year.ToString(); this.Label07.Text = GetTransactionMonthly(historym, 7).Sale.ToString(); this.lblY07.Text = GetTransactionMonthly(historym, 7).Year.ToString(); this.Label08.Text = GetTransactionMonthly(historym, 8).Sale.ToString(); this.lblY08.Text = GetTransactionMonthly(historym, 8).Year.ToString(); this.Label09.Text = GetTransactionMonthly(historym, 9).Sale.ToString(); this.lblY09.Text = GetTransactionMonthly(historym, 9).Year.ToString(); this.Label010.Text = GetTransactionMonthly(historym, 10).Sale.ToString(); this.lblY10.Text = GetTransactionMonthly(historym, 10).Year.ToString(); this.Label011.Text = GetTransactionMonthly(historym, 11).Sale.ToString(); this.lblY11.Text = GetTransactionMonthly(historym, 11).Year.ToString(); this.Label012.Text = GetTransactionMonthly(historym, 12).Sale.ToString(); this.lblY12.Text = GetTransactionMonthly(historym, 12).Year.ToString(); IList <Forecast> forecast = ControllerManager.Forecast.GetForecast(info, Config.CurrentWeek, Config.CurrentDate.Year); this.GridView1.DataSource = forecast; this.GridView1.DataBind(); //------GRAFICO------------------------------------------- if (forecast.Count > 0) { string[] Titulos = new string[forecast.Count]; double[] Stock = new double[forecast.Count]; double[] Ventas = new double[forecast.Count]; double[] Compras = new double[forecast.Count]; for (int cont = 0; cont < forecast.Count; cont++) { Stock.SetValue(forecast[cont].FinalStock, cont); Ventas.SetValue(forecast[cont].Sale, cont); Compras.SetValue(forecast[cont].Purchase, cont); Titulos.SetValue(forecast[cont].Week.ToString(), cont); } XYChart c = new XYChart(480, 300, 0xeeeeff, 0x000000, 3); c.setPlotArea(50, 70, 410, 180, 0xffffff, -1, -1, 0xcccccc, 0xcccccc); c.addLegend(50, 50, false, "Arial Bold", 8).setBackground(Chart.Transparent); c.addTitle("Gráficos Estadísticos", "Verdana Bold", 12).setBackground(0xccccff, 0x000000, Chart.glassEffect()); c.xAxis().setTitle("Semanas"); c.yAxis().setTitle("Cantidad"); Mark actual = c.xAxis().addMark(10, 0x000000, "SEMANA ACTUAL"); actual.setLineWidth(1); actual.setAlignment(Chart.TopRight); actual.setFontAngle(90); Mark actual0 = c.xAxis().addMark(10 + prodinfo.LeadTime, 0x000000, "LEADTIME"); actual0.setLineWidth(1); actual0.setAlignment(Chart.TopLeft); actual0.setFontAngle(90); LineLayer linea = c.addLineLayer(); linea.setLineWidth(3); linea.addDataSet(Stock, 0x000000, "Stock Final"); linea.addDataSet(Ventas, 0x00ff00, "Ventas"); linea.addDataSet(Compras, 0x0000FF, "Compras"); c.addAreaLayer(Stock, c.yZoneColor(forecast[10].Safety, unchecked ((int)0x50ff3c3c), unchecked ((int)0x500080c0))); c.xAxis().addZone(10, 10 + prodinfo.LeadTime, 0xdcdcdc); c.xAxis().setLabels(Titulos); c.xAxis().setLabelStep(2); WebChartViewer1.Image = c.makeWebImage(Chart.PNG); WebChartViewer1.ImageMap = c.getHTMLImageMap("", "", "title='Semana {xLabel}: {value}'"); WebChartViewer1.Visible = true; } Product pfrom = ControllerManager.Product.GetAlternativeFrom(info); if (pfrom != null) { btnAlternativeFrom.Text = pfrom.ProductCode; btnAlternativeFrom.CommandArgument = pfrom.Id.ToString(); lblAlternativeFrom.Visible = true; } Product pto = ControllerManager.Product.GetAlternativeTo(info); if (pto != null) { btnAlternativeTo.Text = pto.ProductCode; btnAlternativeTo.CommandArgument = pto.Id.ToString(); lblAlternativeTo.Visible = true; } }
//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 chart double[] data0 = { 42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56, 60, 70, 76, 63, 67, 75, 64, 51 }; double[] data1 = { 50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58, 59, 73, 77, 84, 82, 80, 84, 98 }; // The labels for the bottom x axis. Note the "-" means a minor tick. string[] labels0 = { "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" }; // The labels for the top x axis. Note that "-" means a minor tick. string[] labels1 = { "Jun 3\n12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "Jun 4\n0", "1", "2", "3", "4", "5", "6", "7", "8","9", "10", "11", "12" }; // Create a XYChart object of size 310 x 310 pixels XYChart c = new XYChart(310, 310); // Set the plotarea at (50, 50) and of size 200 x 200 pixels c.setPlotArea(50, 50, 200, 200); // Add a title to the primary (left) y axis c.yAxis().setTitle("US Dollars"); // Set the tick length to -4 pixels (-ve means ticks inside the plot area) c.yAxis().setTickLength(-4); // Add a title to the secondary (right) y axis c.yAxis2().setTitle("HK Dollars (1 USD = 7.8 HKD)"); // Set the tick length to -4 pixels (-ve means ticks inside the plot area) c.yAxis2().setTickLength(-4); // Synchronize the y-axis such that y2 = 7.8 x y1 c.syncYAxis(7.8); // Add a title to the bottom x axis c.xAxis().setTitle("Hong Kong Time"); // Set the labels on the x axis. c.xAxis().setLabels(labels0); // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels. c.xAxis().setLabelStep(3, 1); // Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means // ticks inside the plot area) c.xAxis().setTickLength2(-4, -2); // Set the distance between the axis labels and the axis to 6 pixels c.xAxis().setLabelGap(6); // Add a title to the top x-axis c.xAxis2().setTitle("New York Time"); // Set the labels on the x axis. c.xAxis2().setLabels(labels1); // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels. c.xAxis2().setLabelStep(3, 1); // Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means // ticks inside the plot area) c.xAxis2().setTickLength2(-4, -2); // Set the distance between the axis labels and the axis to 6 pixels c.xAxis2().setLabelGap(6); // Add a line layer to the chart with a line width of 2 pixels c.addLineLayer(data0, -1, "Red Transactions").setLineWidth(2); // Add an area layer to the chart with no area boundary line c.addAreaLayer(data1, -1, "Green Transactions").setLineWidth(0); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{dataSetName}\nHKT Jun {=3.5+{x}/24|0} {={x}%24}:00 (NYT Jun " + "{=3+{x}/24|0} {=({x}+12)%24}:00)\nHKD {={value}*7.8} (USD {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) { // The data for the chart double[] data = { 800, 600, 1000, 1400 }; double[] widths = { 250, 500, 960, 460 }; string[] labels = { "Wind", "Hydro", "Coal", "Natural Gas" }; // The colors to use int[] colors = { 0x00aa00, 0x66aaee, 0xee6622, 0xffbb00 }; // Create a XYChart object of size 500 x 350 pixels XYChart c = new XYChart(500, 350); // Add a title to the chart using 15pt Arial Italic font c.addTitle("Energy Generation Breakdown", "Arial Italic", 15); // Set the plotarea at (60, 60) and of (chart_width - 90) x (chart_height - 100) in // size. Use a vertical gradient color from light blue (f9f9ff) to sky blue (aaccff) as // background. Set grid lines to white (ffffff). int plotAreaBgColor = c.linearGradientColor(0, 60, 0, c.getHeight() - 40, 0xaaccff, 0xf9fcff); c.setPlotArea(60, 60, c.getWidth() - 90, c.getHeight() - 100, plotAreaBgColor, -1, -1, 0xffffff); // Add a legend box at (50, 30) using horizontal layout and transparent background. c.addLegend(55, 30, false).setBackground(Chart.Transparent); // Add titles to x/y axes with 10 points Arial Bold font c.xAxis().setTitle("Mega Watts", "Arial Bold", 10); c.yAxis().setTitle("Cost per MWh (dollars)", "Arial Bold", 10); // Set the x axis rounding to false, so that the x-axis will fit the data exactly c.xAxis().setRounding(false, false); // In ChartDirector, there is no bar layer that can have variable bar widths, but you // may create a bar using an area layer. (A bar can be considered as the area under a // rectangular outline.) So by using a loop to create one bar per area layer, we can // achieve a variable width bar chart. // starting position of current bar double currentX = 0; for (int i = 0; i < data.Length; ++i) { // ending position of current bar double nextX = currentX + widths[i]; // outline of the bar double[] dataX = { currentX, currentX, nextX, nextX }; double[] dataY = { 0, data[i], data[i], 0 }; // create the area layer to fill the bar AreaLayer layer = c.addAreaLayer(dataY, colors[i], labels[i]); layer.setXData(dataX); // Tool tip for the layer layer.setHTMLImageMap("", "", "title='" + labels[i] + ": " + widths[i] + " MW at $" + data[i] + " per MWh'"); // the ending position becomes the starting position of the next bar currentX = nextX; } // 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(WinChartViewer viewer, int chartIndex) { // The data for the area chart double[] data = { 30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89, 60, 55, 53, 35, 50, 66, 56, 48, 52, 65, 62 }; // The labels for the area chart string[] labels = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24" }; // Create a XYChart object of size 600 x 360 pixels, with a brushed silver background, 1 // pixel 3D border effect, rounded corners and soft drop shadow. XYChart c = new XYChart(600, 360, Chart.brushedSilverColor(), Chart.Transparent, 1); c.setRoundedFrame(); c.setDropShadow(); // Add a title box to the chart using 18pt Times Bold Italic font. ChartDirector.TextBox title = c.addTitle( "<*block,valign=absmiddle*><*img=@/images/star.png*><*img=@/images/star.png*> " + "Performance Enhancer <*img=@/images/star.png*><*img=@/images/star.png*><*/*>", "Times New Roman Bold Italic", 18); // // Use a text box with a depressed 3D border to create the inner depressed region // // The width of the frame border int frameWidth = 5; // Set the depressed region position ChartDirector.TextBox contentBox = c.addText(frameWidth, title.getHeight(), ""); contentBox.setSize(c.getDrawArea().getWidth() - 1 - frameWidth * 2, c.getDrawArea( ).getHeight() - title.getHeight() - frameWidth - 1); // Use -1 as the rasied effect to create a depressed region contentBox.setBackground(Chart.Transparent, Chart.Transparent, -1); // Set rounded corners, and put the text box at the back of the chart contentBox.setRoundedCorners(10); contentBox.setZOrder(Chart.ChartBackZ); // Tentatively set the plotarea to 50 pixels from the left depressed edge, and 25 pixels // under the top depressed edge. Set the width to 75 pixels less than the depressed // region width, and the height to 75 pixels less than the depressed region height. Use // white (ffffff) background, transparent border, and grey (cccccc) horizontal and // vertical grid lines. PlotArea plotArea = c.setPlotArea(50 + contentBox.getLeftX(), contentBox.getTopY() + 25, contentBox.getWidth() - 75, contentBox.getHeight() - 75, 0xffffff, -1, -1, 0xcccccc, -1); // Add a title to the y axis c.yAxis().setTitle("Energy Concentration (KJ per liter)"); // Set the labels on the x axis. c.xAxis().setLabels(labels); // Display 1 out of 3 labels on the x-axis. c.xAxis().setLabelStep(3); // Add a title to the x axis using CDML c.xAxis().setTitle( "<*block,valign=absmiddle*><*img=@/images/clock.png*> Elapsed Time (hour)<*/*>"); // Set the axes width to 2 pixels c.xAxis().setWidth(2); c.yAxis().setWidth(2); // Add an area layer to the chart using a gradient color that changes vertically from // semi-transparent red (60ff0000) to semi-transparent white (60ffffff) c.addAreaLayer(data, c.linearGradientColor(0, contentBox.getTopY() + 20, 0, contentBox.getTopY() + contentBox.getHeight() - 50, 0x60ff0000, 0x60ffffff)); // Adjust the plot area size, such that the bounding box (inclusive of axes) is 15 // pixels from the left depressed edge, 25 pixels below the top depressed edge, 25 // pixels from the right depressed edge, and 15 pixels above the bottom depressed edge. c.packPlotArea(contentBox.getLeftX() + 15, contentBox.getTopY() + 25, contentBox.getLeftX() + contentBox.getWidth() - 25, contentBox.getTopY() + contentBox.getHeight() - 15); // Add a custom CDML text with the bottom right corner is anchored to the bootom right // corner of the plot area, with 5 pixels margin. c.addText(plotArea.getLeftX() + plotArea.getWidth() - 5, plotArea.getTopY() + plotArea.getHeight() - 5, "<*block,valign=absmiddle*><*img=@/images/small_molecule.png*> <*block*>" + "<*font=Times New Roman Bold Italic,size=10,color=804040*>Molecular\nEngineering" + "<*/*>").setAlignment(Chart.BottomRight); // Output the chart viewer.Chart = c; //include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='Hour {xLabel}: {value} KJ/liter'"); }
protected void Generate_Forecast(int productid) { Product info = ControllerManager.Product.GetById(productid); IList <TransactionHistoryWeekly> history = ControllerManager.TransactionHistoryWeekly.GetInfo(info.Id, Config.CurrentWeek, Config.CurrentDate.Year, 1); this.Label12.Text = info.ProductCode.ToString(); this.Label3.Text = info.Description.ToString(); this.Label5.Text = info.Provider.Name; this.Label7.Text = (history[0].Stock + history[0].Purchase - history[0].Sale).ToString(); this.Label9.Text = info.RepositionLevel.ToString(); this.Label11.Text = info.RepositionPoint.ToString(); this.Label16.Text = info.LeadTime.ToString(); this.Label1.Text = info.Safety.ToString(); IList <Forecast> forecast = ControllerManager.Forecast.GetForecast(info, Config.CurrentWeek, Config.CurrentDate.Year); this.GridView1.DataSource = forecast; this.GridView1.DataBind(); //------GRAFICO------------------------------------------- if (forecast.Count > 0) { string[] Titulos = new string[forecast.Count]; double[] Stock = new double[forecast.Count]; double[] Ventas = new double[forecast.Count]; double[] Compras = new double[forecast.Count]; for (int cont = 0; cont < forecast.Count; cont++) { Stock.SetValue(forecast[cont].FinalStock, cont); Ventas.SetValue(forecast[cont].Sale, cont); Compras.SetValue(forecast[cont].Purchase, cont); Titulos.SetValue(forecast[cont].Week.ToString(), cont); } XYChart c = new XYChart(480, 300, 0xeeeeff, 0x000000, 3); c.setPlotArea(50, 70, 410, 180, 0xffffff, -1, -1, 0xcccccc, 0xcccccc); c.addLegend(50, 50, false, "Arial Bold", 8).setBackground(Chart.Transparent); c.addTitle("Graficos Estadisticos", "Verdana Bold", 12).setBackground(0xccccff, 0x000000, Chart.glassEffect()); c.xAxis().setTitle("Semanas"); c.yAxis().setTitle("Cantidad"); Mark actual = c.xAxis().addMark(10, 0x000000, "SEMANA ACTUAL"); actual.setLineWidth(1); actual.setAlignment(Chart.TopRight); actual.setFontAngle(90); Mark actual0 = c.xAxis().addMark(10 + info.LeadTime, 0x000000, "LEADTIME"); actual0.setLineWidth(1); actual0.setAlignment(Chart.TopLeft); actual0.setFontAngle(90); LineLayer linea = c.addLineLayer(); linea.setLineWidth(3); linea.addDataSet(Stock, 0x000000, "Stock Final"); linea.addDataSet(Ventas, 0x00ff00, "Ventas"); linea.addDataSet(Compras, 0x0000FF, "Compras"); c.addAreaLayer(Stock, c.yZoneColor(forecast[10].Safety, unchecked ((int)0x50ff3c3c), unchecked ((int)0x500080c0))); c.xAxis().addZone(10, 10 + info.LeadTime, 0xdcdcdc); c.xAxis().setLabels(Titulos); c.xAxis().setLabelStep(2); WebChartViewer1.Image = c.makeWebImage(Chart.PNG); WebChartViewer1.ImageMap = c.getHTMLImageMap("", "", "title='Semana {xLabel}: {value}'"); WebChartViewer1.Visible = true; } }