Example #1
0
        //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)
        {
            // Data for the chart
            double[] data0 = { 5, 3, 10, 4, 3, 5, 2, 5 };
            double[] data1 = { 12, 6, 17, 6, 7, 9, 4, 7 };
            double[] data2 = { 17, 7, 22, 7, 18, 13, 5, 11 };

            double[] angles = { 0, 45, 90, 135, 180, 225, 270, 315 };
            string[] labels = { "North", "North\nEast", "East", "South\nEast",
                                "South", "South\nWest", "West", "North\nWest" };

            // Create a PolarChart object of size 460 x 500 pixels, with a grey
            // (e0e0e0) background and a 1 pixel 3D border
            PolarChart c = new PolarChart(460, 500, 0xe0e0e0, 0x000000, 1);

            // Add a title to the chart at the top left corner using 15pts Arial Bold
            // Italic font. Use white text on deep blue background.
            c.addTitle("Wind Direction", "Arial Bold Italic", 15, 0xffffff
                       ).setBackground(0x000080);

            LegendBox legendBox = c.addLegend(230, 35, false, "Arial Bold", 9);

            legendBox.setAlignment(Chart.TopCenter);
            legendBox.setBackground(Chart.Transparent, Chart.Transparent, 1);

            legendBox.addKey("5 m/s or above", 0xff3333);
            legendBox.addKey("1 - 5 m/s", 0x33ff33);
            legendBox.addKey("less than 1 m/s", 0x3333ff);

            // Set plot area center at (230, 280) with radius 180 pixels and white
            // background
            c.setPlotArea(230, 280, 180, 0xffffff);

            // Set the grid style to circular grid
            c.setGridStyle(false);

            // Set angular axis as 0 - 360, with a spoke every 30 units
            c.angularAxis().setLinearScale2(0, 360, labels);

            for (int i = 0; i < angles.Length; ++i)
            {
                c.angularAxis().addZone(angles[i] - 10, angles[i] + 10, 0, data0[i],
                                        0x3333ff, 0);
                c.angularAxis().addZone(angles[i] - 10, angles[i] + 10, data0[i],
                                        data1[i], 0x33ff33, 0);
                c.angularAxis().addZone(angles[i] - 10, angles[i] + 10, data1[i],
                                        data2[i], 0xff3333, 0);
            }

            // Add an Transparent invisible layer to ensure the axis is auto-scaled
            // using the data
            c.addLineLayer(data2, Chart.Transparent);

            // Output the chart
            viewer.Image = c.makeImage();
        }
        //
        // 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'");
        }
Example #3
0
        //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'");
        }
        //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[] data = { 5.1, 1.5, 5.1, 4.0, 1.7, 8.7, 9.4, 2.1, 3.5, 8.8, 5.0, 6.0 };

            // The labels for the chart
            string[] labels = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept",
                                "Oct", "Nov", "Dec" };

            // Create a PolarChart object of size 400 x 420 pixels. with a metallic blue (9999ff)
            // background color and 1 pixel 3D border
            PolarChart c = new PolarChart(400, 420, Chart.metalColor(0x9999ff), 0x000000, 1);

            // Add a title to the chart using 16pt Arial Bold Italic font. The title text is white
            // (0xffffff) on deep blue (000080) background
            c.addTitle("Chemical Concentration", "Arial Bold Italic", 16, 0xffffff).setBackground(
                0x000080);

            // Set center of plot area at (200, 240) with radius 145 pixels. Set background color to
            // green (0x33ff33)
            c.setPlotArea(200, 240, 145, 0x33ff33);

            // Set the labels to the angular axis
            c.angularAxis().setLabels(labels);

            // Color the sector between label index = 5.5 to 7.5 as red (ff3333) zone
            c.angularAxis().addZone(5.5, 7.5, 0xff3333);

            // Color the sector between label index = 4.5 to 5.5, and also between 7.5 to 8.5, as
            // yellow (ff3333) zones
            c.angularAxis().addZone(4.5, 5.5, 0xffff00);
            c.angularAxis().addZone(7.5, 8.5, 0xffff00);

            // Set the grid style to circular grid
            c.setGridStyle(false);

            // Use semi-transparent (40ffffff) label background so as not to block the data
            c.radialAxis().setLabelStyle().setBackground(0x40ffffff, 0x40000000);

            // Add a legend box at (200, 30) top center aligned, using 9pt Arial Bold font. with a
            // black border.
            LegendBox legendBox = c.addLegend(200, 30, false, "Arial Bold", 9);

            legendBox.setAlignment(Chart.TopCenter);

            // Add legend keys to represent the red/yellow/green zones
            legendBox.addKey("Very Dry", 0xff3333);
            legendBox.addKey("Critical", 0xffff00);
            legendBox.addKey("Moderate", 0x33ff33);

            // Add a blue (0x80) line layer with line width set to 3 pixels and use purple (ff00ff)
            // cross symbols for the data points
            PolarLineLayer layer = c.addLineLayer(data, 0x000080);

            layer.setLineWidth(3);
            layer.setDataSymbol(Chart.Cross2Shape(), 15, 0xff00ff);

            // Output the chart
            viewer.Chart = c;

            // Include tool tip for the chart.
            viewer.ImageMap = layer.getHTMLImageMap("clickable", "",
                                                    "title='Concentration on {label}: {value} ppm'");
        }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The XY data of the first data series
            double[] dataX = { 50, 55, 37, 24, 42, 49, 63, 72, 83, 59 };
            double[] dataY = { 3.6, 2.8, 2.5, 2.3, 3.8, 3.0, 3.8, 5.0, 6.0, 3.3 };

            // Create a XYChart object of size 520 x 490 pixels
            XYChart c = new XYChart(520, 490);

            // Set the plotarea at (60, 40) and of size 450 x 400 pixels, with white background and a
            // light grey border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light
            // grey color (0xc0c0c0)
            c.setPlotArea(60, 40, 450, 400, 0xffffff, -1, 0xc0c0c0, 0xc0c0c0, -1);

            // Add a title to the chart using 18 point Times Bold Itatic font.
            c.addTitle("      Chemical X Thermal Conductivity", "Times New Roman Bold Italic", 18);

            // Add titles to the axes using 12pt Arial Bold Italic font
            c.yAxis().setTitle("Thermal Conductivity (W/K)", "Arial Bold Italic", 12);
            c.xAxis().setTitle("Concentration (g/liter)", "Arial Bold Italic", 12);

            // Set the axes line width to 3 pixels
            c.yAxis().setWidth(3);
            c.xAxis().setWidth(3);

            // Add a scatter layer using (dataX, dataY)
            ScatterLayer scatterLayer = c.addScatterLayer(dataX, dataY, "", Chart.GlassSphereShape, 13,
                                                          0xcc0000);

            // Show custom Javascript tooltip for the scatter layer
            scatterLayer.setHTMLImageMap("", "",
                                         "onmouseover='showDataPointToolTip({x}, {value})' onmouseout='hideToolTip()'");

            // Add a trend line layer for (dataX, dataY)
            TrendLayer trendLayer = c.addTrendLayer2(dataX, dataY, 0xcc0000);

            // Set the line width to 3 pixels
            trendLayer.setLineWidth(3);

            // Add a 95% confidence band for the line
            trendLayer.addConfidenceBand(0.95, unchecked ((int)0x806666ff));

            // Add a 95% confidence band (prediction band) for the points
            trendLayer.addPredictionBand(0.95, unchecked ((int)0x8066ff66));

            // Show custom Javascript tooltip for the trend layer
            trendLayer.setHTMLImageMap("", "",
                                       "onmouseover='showTrendLineToolTip({slope}, {intercept})' onmouseout='hideToolTip()'");

            // Add a legend box at (60, 35) (top of the chart) with horizontal layout. Use 10pt Arial
            // Bold Italic font. Set the background and border color to Transparent and use line style
            // legend icons.
            LegendBox legendBox = c.addLegend(60, 35, false, "Arial Bold Italic", 9);

            legendBox.setBackground(Chart.Transparent);
            legendBox.setLineStyleKey(true);

            // Add entries to the legend box
            legendBox.addKey("95% Line Confidence", unchecked ((int)0x806666ff));
            legendBox.addKey("95% Point Confidence", unchecked ((int)0x8066ff66));
            legendBox.addKey(String.Format("Trend Line: y = {0:0.0000} x + {1:0.0000}",
                                           trendLayer.getSlope(), trendLayer.getIntercept()), 0xcc0000, 3);

            // Output the chart
            viewer.Image = c.makeWebImage(Chart.PNG);

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("");

            // Output Javascript chart model to the browser to suppport tracking cursor
            viewer.ChartModel = c.getJsChartModel();
        }
        private void createChart()
        {
            string[] xLabels = null;
            if (lst_data.Count != 0)
            {
                xLabels = new string[lst_data.Count];

                for (int i = 0; i < xLabels.Length; i++)
                {
                    xLabels[i] = (i + 1).ToString();
                }
            }

            XYChart chart = new XYChart(795, 455);//(857, 448);

            chart.setBackground(chart.linearGradientColor(0, 0, 0, 100, 0x99ccff, 0xffffff), 0x888888);

            ChartDirector.TextBox title1_txt = chart.addTitle("能量强度变化分析", "Arial Bold", 13);
            title1_txt.setPos(0, 20);

            chart.setPlotArea(50, 60, 620, 340, 0xffffff, -1, -1, chart.dashLineColor(Chart.CColor(Color.AliceBlue), Chart.DotLine), -1);
            chart.xAxis().setLabels(xLabels);
            chart.xAxis().setLabelStep(1);
            chart.xAxis().setIndent(true);
            chart.xAxis().setTitle("点数");

            chart.yAxis().setTitle("噪声强度");

            LineLayer layer;

            layer = chart.addLineLayer();
            layer.addDataSet(lst_data.ToArray(), Chart.CColor(Color.Green), "噪声强度");
            layer.setLineWidth(2);
            layer.setFastLineMode(true);

            layer = chart.addLineLayer();
            layer.addDataSet(lst_stdev.ToArray(), Chart.CColor(Color.DarkViolet), "绝对差");
            layer.setLineWidth(2);
            layer.setFastLineMode(true);

            //标准平均值
            Mark standAMPmark = chart.yAxis().addMark(Standard_average, Chart.CColor(Color.Crimson), "", "Arial Bold");

            standAMPmark.setLineWidth(2);
            standAMPmark.setPos(-15, 10);
            standAMPmark.setFontAngle(90);

            //静态漏水标准幅度值
            Mark standAVmark = chart.yAxis().addMark(StandardAMP, Chart.CColor(Color.Cyan), "", "Arial Bold");

            standAVmark.setLineWidth(2);
            standAVmark.setPos(-15, 10);
            standAVmark.setFontAngle(90);

            Mark energymark = chart.yAxis().addMark(energyvalue, Chart.CColor(Color.Chartreuse), "", "Arial Bold");

            LegendBox legendbox = chart.addLegend(672, 60);

            legendbox.addKey("标准平均值", Chart.CColor(Color.Crimson));
            legendbox.addKey("静态漏水标准", Chart.CColor(Color.Cyan));
            legendbox.addKey("能量强度", Chart.CColor(Color.Chartreuse));
            //legendbox.addKey("噪声强度", Chart.CColor(Color.Green));
            //legendbox.addKey("绝对差", Chart.CColor(Color.DarkViolet));

            chart.layout();

            winChartViewer1.Chart    = chart;
            winChartViewer1.ImageMap =
                winChartViewer1.Chart.getHTMLImageMap("clickable", "", "title='点数: {xLabel},强度: {value}'");
        }
Example #7
0
        //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 tasks for the gantt chart
            string[] labels = { "Market Research",  "Define Specifications", "Overall Archiecture",
                                "Project Planning", "Detail Design",         "Software Development","Test Plan",
                                "Testing and QA",   "User Documentation" };

            // The task index, start date, end date and color for each bar
            double[]   taskNo    = { 0, 0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 8 };
            DateTime[] startDate = { new DateTime(2004,  8, 16), new DateTime(2004, 10,  4),
                                     new DateTime(2004,  8, 30), new DateTime(2004,  9, 13),new DateTime(2004,   9, 20),
                                     new DateTime(2004,  9, 27), new DateTime(2004, 10,  4),new DateTime(2004,  10,  4),
                                     new DateTime(2004, 10, 25), new DateTime(2004, 11,  1),new DateTime(2004,  10, 18),
                                     new DateTime(2004, 11, 8) };
            DateTime[] endDate = { new DateTime(2004,  8, 30), new DateTime(2004, 10, 18),
                                   new DateTime(2004,  9, 13), new DateTime(2004,  9, 27),new DateTime(2004,  10,  4),
                                   new DateTime(2004, 10, 11), new DateTime(2004, 11,  8),new DateTime(2004,  10, 18),
                                   new DateTime(2004, 11,  8), new DateTime(2004, 11, 22),new DateTime(2004,  11,  1),
                                   new DateTime(2004, 11, 22) };
            int[]      colors = { 0x00cc00, 0x00cc00, 0x00cc00, 0x0000cc, 0x0000cc, 0xcc0000, 0xcc0000,
                                  0x0000cc,      0xcc0000, 0xcc0000, 0x00cc00, 0xcc0000 };

            // Create a XYChart object of size 620 x 325 pixels. Set background color to light red
            // (0xffcccc), with 1 pixel 3D border effect.
            XYChart c = new XYChart(620, 325, 0xffcccc, 0x000000, 1);

            // Add a title to the chart using 15 points Times Bold Itatic font, with white (ffffff)
            // text on a dark red (800000) background
            c.addTitle("Mutli-Color Gantt Chart Demo", "Times New Roman Bold Italic", 15, 0xffffff
                       ).setBackground(0x800000);

            // Set the plotarea at (140, 55) and of size 460 x 200 pixels. Use alternative
            // white/grey background. Enable both horizontal and vertical grids by setting their
            // colors to grey (c0c0c0). Set vertical major grid (represents month boundaries) 2
            // pixels in width
            c.setPlotArea(140, 55, 460, 200, 0xffffff, 0xeeeeee, Chart.LineColor, 0xc0c0c0, 0xc0c0c0
                          ).setGridWidth(2, 1, 1, 1);

            // swap the x and y axes to create a horziontal box-whisker chart
            c.swapXY();

            // Set the y-axis scale to be date scale from Aug 16, 2004 to Nov 22, 2004, with ticks
            // every 7 days (1 week)
            c.yAxis().setDateScale(new DateTime(2004, 8, 16), new DateTime(2004, 11, 22), 86400 * 7)
            ;

            // Set multi-style axis label formatting. Month labels are in Arial Bold font in "mmm d"
            // format. Weekly labels just show the day of month and use minor tick (by using '-' as
            // first character of format string).
            c.yAxis().setMultiFormat(Chart.StartOfMonthFilter(), "<*font=Arial Bold*>{value|mmm d}",
                                     Chart.StartOfDayFilter(), "-{value|d}");

            // Set the y-axis to shown on the top (right + swapXY = top)
            c.setYAxisOnRight();

            // Set the labels on the x axis
            c.xAxis().setLabels(labels);

            // Reverse the x-axis scale so that it points downwards.
            c.xAxis().setReverse();

            // Set the horizontal ticks and grid lines to be between the bars
            c.xAxis().setTickOffset(0.5);

            // Add some symbols to the chart to represent milestones. The symbols are added using
            // scatter layers. We need to specify the task index, date, name, symbol shape, size and
            // color.
            c.addScatterLayer(new double[] { 1 }, Chart.CTime(new DateTime[] { new DateTime(2004, 9, 13
                                                                                            ) }), "Milestone 1", Chart.Cross2Shape(), 13, 0xffff00).setHTMLImageMap("{disable}");
            c.addScatterLayer(new double[] { 3 }, Chart.CTime(new DateTime[] { new DateTime(2004, 10, 4
                                                                                            ) }), "Milestone 2", Chart.StarShape(5), 15, 0xff00ff).setHTMLImageMap("{disable}");
            c.addScatterLayer(new double[] { 5 }, Chart.CTime(new DateTime[] { new DateTime(2004, 11, 8
                                                                                            ) }), "Milestone 3", Chart.TriangleSymbol, 13, 0xff9933).setHTMLImageMap("{disable}")
            ;

            // Add a multi-color box-whisker layer to represent the gantt bars
            BoxWhiskerLayer layer = c.addBoxWhiskerLayer2(Chart.CTime(startDate),
                                                          Chart.CTime(endDate), null, null, null, colors);

            layer.setXData(taskNo);
            layer.setBorderColor(Chart.SameAsMainColor);

            // Divide the plot area height ( = 200 in this chart) by the number of tasks to get the
            // height of each slot. Use 80% of that as the bar height.
            layer.setDataWidth((int)(200 * 4 / 5 / labels.Length));

            // Add a legend box at (140, 265) - bottom of the plot area. Use 8pt Arial Bold as the
            // font with auto-grid layout. Set the width to the same width as the plot area. Set the
            // backgorund to grey (dddddd).
            LegendBox legendBox = c.addLegend2(140, 265, Chart.AutoGrid, "Arial Bold", 8);

            legendBox.setWidth(461);
            legendBox.setBackground(0xdddddd);

            // The keys for the scatter layers (milestone symbols) will automatically be added to
            // the legend box. We just need to add keys to show the meanings of the bar colors.
            legendBox.addKey("Market Team", 0x00cc00);
            legendBox.addKey("Planning Team", 0x0000cc);
            legendBox.addKey("Development Team", 0xcc0000);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{xLabel}: {top|mmm dd, yyyy} to {bottom|mmm dd, yyyy}'");
        }
Example #8
0
        //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[] data = { 51, 15, 51, 40, 17, 87, 94, 21, 35, 88, 50, 60 };

            // The labels for the chart
            string[] labels = { "Jan", "Feb",  "Mar", "Apr", "May", "Jun", "Jul",
                                "Aug", "Sept", "Oct", "Nov", "Dec" };

            // Create a PolarChart object of size 400 x 420 pixels
            PolarChart c = new PolarChart(400, 420);

            // Set background color to a 2 pixel pattern color, with a black border
            // and 1 pixel 3D border effect
            c.setBackground(c.patternColor(new int[] { 0xffffff, 0xe0e0e0 }, 2), 0, 1);

            // Add a title to the chart using 16 pts Arial Bold Italic font. The
            // title text is white (0xffffff) on 2 pixel pattern background
            c.addTitle("Chemical Concentration", "Arial Bold Italic", 16, 0xffffff
                       ).setBackground(c.patternColor(new int[] { 0x000000, 0x000080 }, 2));

            // Set center of plot area at (200, 240) with radius 145 pixels. Set
            // background color to blue (9999ff)
            c.setPlotArea(200, 240, 145, 0x9999ff);

            // Color the region between radius = 40 to 80 as green (99ff99)
            c.radialAxis().addZone(40, 80, 0x99ff99);

            // Color the region with radius > 80 as red (ff9999)
            c.radialAxis().addZone(80, 999, 0xff9999);

            // Set the grid style to circular grid
            c.setGridStyle(false);

            // Set the radial axis label format
            c.radialAxis().setLabelFormat("{value} ppm");

            // Use semi-transparent (40ffffff) label background so as not to block
            // the data
            c.radialAxis().setLabelStyle().setBackground(0x40ffffff, 0x40000000);

            // Add a legend box at (200, 30) top center aligned, using 9 pts Arial
            // Bold font. with a black border.
            LegendBox legendBox = c.addLegend(200, 30, false, "Arial Bold", 9);

            legendBox.setAlignment(Chart.TopCenter);

            // Add legend keys to represent the red/green/blue zones
            legendBox.addKey("Under-Absorp", 0x9999ff);
            legendBox.addKey("Normal", 0x99ff99);
            legendBox.addKey("Over-Absorp", 0xff9999);

            // Add a blue (000080) spline line layer with line width set to 3 pixels
            // and using yellow (ffff00) circles to represent the data points
            PolarSplineLineLayer layer = c.addSplineLineLayer(data, 0x000080);

            layer.setLineWidth(3);
            layer.setDataSymbol(Chart.CircleShape, 11, 0xffff00);

            // Set the labels to the angular axis as spokes.
            c.angularAxis().setLabels(labels);

            // Output the chart
            viewer.Image = c.makeImage();

            // Include tool tip for the chart.
            viewer.ImageMap = layer.getHTMLImageMap("clickable", "",
                                                    "title='Concentration on {label}: {value} ppm'");
        }
Example #9
0
        //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");
        }
Example #10
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The XY data of the first data series
            double[] dataX = {50, 55, 37, 24, 42, 49, 63, 72, 83, 59};
            double[] dataY = {3.6, 2.8, 2.5, 2.3, 3.8, 3.0, 3.8, 5.0, 6.0, 3.3};

            // Create a XYChart object of size 450 x 420 pixels
            XYChart c = new XYChart(450, 420);

            // Set the plotarea at (55, 65) and of size 350 x 300 pixels, with white background and a
            // light grey border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light
            // grey color (0xc0c0c0)
            c.setPlotArea(55, 65, 350, 300, 0xffffff, -1, 0xc0c0c0, 0xc0c0c0, -1);

            // Add a title to the chart using 18 point Times Bold Itatic font.
            c.addTitle("Server Performance", "Times New Roman Bold Italic", 18);

            // Add titles to the axes using 12pt Arial Bold Italic font
            c.yAxis().setTitle("Response Time (sec)", "Arial Bold Italic", 12);
            c.xAxis().setTitle("Server Load (TPS)", "Arial Bold Italic", 12);

            // Set the axes line width to 3 pixels
            c.yAxis().setWidth(3);
            c.xAxis().setWidth(3);

            // Add a scatter layer using (dataX, dataY)
            ScatterLayer scatterLayer = c.addScatterLayer(dataX, dataY, "", Chart.DiamondSymbol, 11,
                0x008000);

            // tool tip for scatter layer
            scatterLayer.setHTMLImageMap("", "", "title='Response time at {x} TPS: {value} sec'");

            // Add a trend line layer for (dataX, dataY)
            TrendLayer trendLayer = c.addTrendLayer2(dataX, dataY, 0x008000);

            // Set the line width to 3 pixels
            trendLayer.setLineWidth(3);

            // Add a 95% confidence band for the line
            trendLayer.addConfidenceBand(0.95, unchecked((int)0x806666ff));

            // Add a 95% confidence band (prediction band) for the points
            trendLayer.addPredictionBand(0.95, unchecked((int)0x8066ff66));

            // tool tip for trend layer
            trendLayer.setHTMLImageMap("", "",
                "title='Slope = {slope|4} sec/TPS; Intercept = {intercept|4} sec'");

            // Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 10pt Arial
            // Bold Italic font. Set the background and border color to Transparent.
            LegendBox legendBox = c.addLegend(50, 30, false, "Arial Bold Italic", 10);
            legendBox.setBackground(Chart.Transparent);

            // Add entries to the legend box
            legendBox.addKey("95% Line Confidence", unchecked((int)0x806666ff));
            legendBox.addKey("95% Point Confidence", unchecked((int)0x8066ff66));

            // Display the trend line parameters as a text table formatted using CDML
            ChartDirector.TextBox textbox = c.addText(56, 65, String.Format(
                "<*block*>Slope\nIntercept\nCorrelation\nStd Error<*/*>   <*block*>{0:0.0000} " +
                "sec/tps\n{1:0.0000} sec\n{2:0.0000}\n{3:0.0000} sec<*/*>", trendLayer.getSlope(),
                trendLayer.getIntercept(), trendLayer.getCorrelation(), trendLayer.getStdError()),
                "Arial Bold", 8);

            // Set the background of the text box to light grey, with a black border, and 1 pixel 3D
            // border
            textbox.setBackground(0xc0c0c0, 0, 1);

            // Output the chart
            viewer.Image = c.makeWebImage(Chart.PNG);

            // 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 x and y coordinates of the grid
            double[] dataX = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            double[] dataY = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            // Use random numbers for the z values on the XY grid
            RanSeries r = new RanSeries(999);

            double[] dataZ = r.get2DSeries(dataX.Length, dataY.Length, -0.9, 1.15);

            // Create a XYChart object of size 640 x 460 pixels
            XYChart c = new XYChart(640, 460);

            // Set default text color to dark grey (0x333333)
            c.setColor(Chart.TextColor, 0x333333);

            // Set the plotarea at (30, 25) and of size 400 x 400 pixels. Use semi-transparent grey
            // (0xdd000000) horizontal and vertical grid lines
            c.setPlotArea(50, 25, 400, 400, -1, -1, Chart.Transparent, unchecked ((int)0xdd000000),
                          -1);

            // Set the x and y axis stems to transparent and the label font to 12pt Arial
            c.xAxis().setColors(Chart.Transparent);
            c.yAxis().setColors(Chart.Transparent);
            c.xAxis().setLabelStyle("Arial", 12);
            c.yAxis().setLabelStyle("Arial", 12);

            // Set the x-axis and y-axis scale
            c.xAxis().setLinearScale(0, 10, 1);
            c.yAxis().setLinearScale(0, 10, 1);

            // Add a contour layer using the given data
            ContourLayer layer = c.addContourLayer(dataX, dataY, dataZ);

            // Move the grid lines in front of the contour layer
            c.getPlotArea().moveGridBefore(layer);

            // Define the color scale
            double[] colorScale = { -0.8,     0x0066ff,     -0.5, 0x66ccff,     -0.3, 0x66ffff,        0, 0x88ff88, 0.4,
                                    0x00ff00,      0.7, 0xffff00,      0.9, 0xff6600,      1.0, 0xcc0000, 1.1 };
            // Apply the color scale, and specify the underflow and overflow colors for regions
            // exceeding the color scale
            layer.colorAxis().setColorScale(colorScale, 0x0000cc, 0x000000);

            //
            // Instead of displaying the color axis, we use a legend box to display the colors. This
            // is useful for colors that are unevenly spaced on the color axis.
            //

            // Add a legend box at (460, 25) with vertical layout, with 12pt Arial font, transparent
            // background and border, icon size of 15 x 15 pixels, and line spacing of 8 pixels.
            LegendBox b = c.addLegend(460, 25, true, "Arial", 12);

            b.setBackground(Chart.Transparent, Chart.Transparent);
            b.setKeySize(15, 15);
            b.setKeySpacing(0, 8);

            // Add the legend box entries
            b.addKey("> 1.1 (Critical)", 0x000000);
            b.addKey("1.0 to 1.1 (Alert)", 0xcc0000);
            b.addKey("0.9 to 1.0", 0xff6600);
            b.addKey("0.7 to 0.9", 0xffff00);
            b.addKey("0.4 to 0.7", 0x00ff00);
            b.addKey("0.0 to 0.4", 0x88ff88);
            b.addKey("-0.3 to 0.0", 0x66ffff);
            b.addKey("-0.5 to -0.3", 0x66ccff);
            b.addKey("-0.8 to -0.5", 0x0066ff);
            b.addKey("< -0.8", 0x0000cc);

            // Output the chart
            viewer.Chart = c;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // The XY data of the first data series
            double[] dataX = { 50, 55, 37, 24, 42, 49, 63, 72, 83, 59 };
            double[] dataY = { 3.6, 2.8, 2.5, 2.3, 3.8, 3.0, 3.8, 5.0, 6.0, 3.3 };

            // Create a XYChart object of size 520 x 490 pixels
            XYChart c = new XYChart(520, 490);

            // Set the plotarea at (60, 40) and of size 450 x 400 pixels, with white background and a light
            // grey border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light grey color
            // (0xc0c0c0)
            c.setPlotArea(60, 40, 450, 400, 0xffffff, -1, 0xc0c0c0, 0xc0c0c0, -1);

            // Add a title to the chart using 18 point Times Bold Itatic font.
            c.addTitle("      Chemical X Thermal Conductivity", "Times New Roman Bold Italic", 18);

            // Add titles to the axes using 12pt Arial Bold Italic font
            c.yAxis().setTitle("Thermal Conductivity (W/K)", "Arial Bold Italic", 12);
            c.xAxis().setTitle("Concentration (g/liter)", "Arial Bold Italic", 12);

            // Set the axes line width to 3 pixels
            c.yAxis().setWidth(3);
            c.xAxis().setWidth(3);

            // Add a scatter layer using (dataX, dataY)
            ScatterLayer scatterLayer = c.addScatterLayer(dataX, dataY, "", Chart.GlassSphereShape, 13,
                                                          0xcc0000);

            // Tooltip for the scatter layer
            scatterLayer.setHTMLImageMap("", "",
                                         "title='Concentration: {x} g/liter, Conductivity: {value} W/K'");

            // Add a trend line layer for (dataX, dataY)
            TrendLayer trendLayer = c.addTrendLayer2(dataX, dataY, 0xcc0000);

            // Set the line width to 3 pixels
            trendLayer.setLineWidth(3);

            // Add a 95% confidence band for the line
            trendLayer.addConfidenceBand(0.95, unchecked ((int)0x806666ff));

            // Add a 95% confidence band (prediction band) for the points
            trendLayer.addPredictionBand(0.95, unchecked ((int)0x8066ff66));

            // Tool tip for the trend layer
            trendLayer.setHTMLImageMap("", "", "title='Trend Line: y = {slope|P4} x + {intercept|P4}'");

            // Add a legend box at (60, 35) (top of the chart) with horizontal layout. Use 10pt Arial Bold
            // Italic font. Set the background and border color to Transparent and use line style legend
            // icons.
            LegendBox legendBox = c.addLegend(60, 35, false, "Arial Bold Italic", 9);

            legendBox.setBackground(Chart.Transparent);
            legendBox.setLineStyleKey(true);

            // Add entries to the legend box
            legendBox.addKey("95% Line Confidence", unchecked ((int)0x806666ff));
            legendBox.addKey("95% Point Confidence", unchecked ((int)0x8066ff66));
            legendBox.addKey(String.Format("Trend Line: y = {0:0.0000} x + {1:0.0000}", trendLayer.getSlope(),
                                           trendLayer.getIntercept()), 0xcc0000, 3);

            // Assign the chart to the WPFChartViewer
            WPFChartViewer1.Chart = c;

            // Include tool tip for the chart
            WPFChartViewer1.ImageMap = c.getHTMLImageMap("");
        }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // 4 data points to represent the cash flow for the Q1 - Q4
            double[] data = { 230, -140, 220, 330 };

            // We want to plot a waterfall chart showing the 4 quarters as well as the total
            string[] labels = { "1st Quarter", "2nd Quarter", "3rd Quarter", "4th Quarter", "Total" };

            // The top side of the bars in a waterfall chart is the accumulated data. We use the
            // ChartDirector ArrayMath utility to accumulate the data. The "total" is handled by
            // inserting a zero point at the end before accumulation (after accumulation it will become
            // the total).
            double[] boxTop = new ArrayMath(data).insert2(0, 1, data.Length).acc().result();

            // The botom side of the bars is just the top side of the previous bar. So we shifted the top
            // side data to obtain the bottom side data.
            double[] boxBottom = new ArrayMath(boxTop).shift(1, 0).result();

            // The last point (total) is different. Its bottom side is always 0.
            boxBottom[boxBottom.Length - 1] = 0;

            // In this example, we want to use different colors depending on the data is positive or
            // negative.
            int posColor = 0x00ff00;
            int negColor = 0xff0000;

            // Create a XYChart object of size 500 x 280 pixels. Set background color to light blue
            // (ccccff), with 1 pixel 3D border effect.
            XYChart c = new XYChart(500, 300, 0xccccff, 0x000000, 1);

            // Add a title to the chart using 13 points Arial Bold Itatic font, with white (ffffff) text
            // on a deep blue (0x80) background
            c.addTitle("Corporate Cash Flow - Year 2004", "Arial Bold Italic", 13, 0xffffff
                       ).setBackground(0x000080);

            // Set the plotarea at (55, 50) and of size 430 x 215 pixels. Use alternative white/grey
            // background.
            c.setPlotArea(55, 50, 430, 215, 0xffffff, 0xeeeeee);

            // Add a legend box at (55, 25) using 8pt Arial Bold font with horizontal layout, with
            // transparent background and border color.
            LegendBox b = c.addLegend(55, 25, false, "Arial Bold", 8);

            b.setBackground(Chart.Transparent, Chart.Transparent);

            // Add keys to show the colors for positive and negative cash flows
            b.addKey("Positive Cash Flow", posColor);
            b.addKey("Negative Cash Flow", negColor);

            // Set the labels on the x axis using Arial Bold font
            c.xAxis().setLabels(labels).setFontStyle("Arial Bold");

            // Set the x-axis ticks and grid lines to be between the bars
            c.xAxis().setTickOffset(0.5);

            // Use Arial Bold as the y axis label font
            c.yAxis().setLabelStyle("Arial Bold");

            // Add a title to the y axis
            c.yAxis().setTitle("USD (in millions)");

            // Add a box-whisker layer to represent the waterfall bars
            BoxWhiskerLayer layer = c.addBoxWhiskerLayer(boxTop, boxBottom);

            // Color the bars depending on whether it is positive or negative
            for (int i = 0; i < boxTop.Length; ++i)
            {
                if (boxTop[i] >= boxBottom[i])
                {
                    layer.setBoxColor(i, posColor);
                }
                else
                {
                    layer.setBoxColor(i, negColor);
                }
            }

            // Put data labels on the bars to show the cash flow using Arial Bold font
            layer.setDataLabelFormat("{={top}-{bottom}}M");
            layer.setDataLabelStyle("Arial Bold").setAlignment(Chart.Center);

            // Output the chart
            viewer.Image = c.makeWebImage(Chart.PNG);

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "", "title='{xLabel}: {={top}-{bottom}} millions'");
        }
Example #14
0
        //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 = { 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 };

            // The error data representing the error band around the data points
            double[] errData = { 5,     6, 5.1, 6.5, 6.6,    8,  5.4,  5.1,  4.6, 5.0, 5.2, 6.0, 4.9, 5.6, 4.8,
                                 6.2, 7.4, 7.1, 6.5, 9.6, 12.1, 15.3, 18.5, 20.9, 24.1 };

            // The timestamps for the data
            DateTime[] labels = { new DateTime(2001,                                                                                       1, 1), new DateTime(2001,                 2, 1), new DateTime(
                                      2001,                                                                                                3, 1), new DateTime(2001,                 4, 1), new DateTime(2001,                 5, 1), new DateTime(2001,
                                                                                                                                                                                                                                                   6,                    1), new DateTime(2001,  7,                1), new DateTime(2001,  8,                1),new DateTime(2001,9, 1),
                                  new DateTime(2001,                                                                                      10, 1), new DateTime(2001,                11, 1), new DateTime(2001,                12, 1),
                                  new DateTime(2002,                                                                                       1, 1), new DateTime(2002,                 2, 1), new DateTime(2002,                 3, 1),
                                  new DateTime(2002,                                                                                       4, 1), new DateTime(2002,                 5, 1), new DateTime(2002,                 6, 1),
                                  new DateTime(2002,                                                                                       7, 1), new DateTime(2002,                 8, 1), new DateTime(2002,                 9, 1),
                                  new DateTime(2002,                                                                                      10, 1), new DateTime(2002,                11, 1), new DateTime(2002,                12, 1),
                                  new DateTime(2003,                                                                                       1, 1) };

            // Create a XYChart object of size 550 x 220 pixels
            XYChart c = new XYChart(550, 220);

            // Set the plot area at (50, 10) and of size 480 x 180 pixels. Enabled both vertical and
            // horizontal grids by setting their colors to light grey (cccccc)
            c.setPlotArea(50, 10, 480, 180).setGridColor(0xcccccc, 0xcccccc);

            // Add a legend box (50, 10) (top of plot area) using horizontal layout. Use 8pt Arial
            // font. Disable bounding box (set border to transparent).
            LegendBox legendBox = c.addLegend(50, 10, false, "", 8);

            legendBox.setBackground(Chart.Transparent);

            // Add keys to the legend box to explain the color zones
            legendBox.addKey("Historical", 0x9999ff);
            legendBox.addKey("Forecast", 0xff9966);

            // Add a title to the y axis.
            c.yAxis().setTitle("Energy Consumption");

            // Set the labels on the x axis
            c.xAxis().setLabels2(labels);

            // Set multi-style axis label formatting. Use Arial Bold font for yearly labels and
            // display them as "yyyy". Use default font for monthly labels and display them as
            // "mmm". Replace some labels with minor ticks to ensure the labels are at least 3 units
            // apart.
            c.xAxis().setMultiFormat(Chart.StartOfYearFilter(), "<*font=Arial Bold*>{value|yyyy}",
                                     Chart.StartOfMonthFilter(), "{value|mmm}", 3);

            // Add a line layer to the chart
            LineLayer layer = c.addLineLayer2();

            // Create the color to draw the data line. The line is blue (0x333399) to the left of x
            // = 18, and become a red (0xd04040) dash line to the right of x = 18.
            int lineColor = layer.xZoneColor(18, 0x333399, c.dashLineColor(0xd04040, Chart.DashLine)
                                             );

            // Add the data line
            layer.addDataSet(data, lineColor, "Average");

            // We are not showing the data set name in the legend box. The name is for showing in
            // tool tips only.
            layer.setLegend(Chart.NoLegend);

            // Create the color to draw the err zone. The color is semi-transparent blue
            // (0x809999ff) to the left of x = 18, and become semi-transparent red (0x80ff9966) to
            // the right of x = 18.
            int errColor = layer.xZoneColor(18, unchecked ((int)0x809999ff),
                                            unchecked ((int)0x80ff9966));

            // Add the upper border of the err zone
            layer.addDataSet(new ArrayMath(data).add(errData).result(), errColor, "Upper bound");

            // Add the lower border of the err zone
            layer.addDataSet(new ArrayMath(data).sub(errData).result(), errColor, "Lower bound");

            // Set the default line width to 2 pixels
            layer.setLineWidth(2);

            // In this example, we are not showing the data set name in the legend box
            layer.setLegend(Chart.NoLegend);

            // Color the region between the err zone lines
            c.addInterLineLayer(layer.getLine(1), layer.getLine(2), errColor);

            // Output the chart
            viewer.Chart = c;

            // Include tool tip for the chart.
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} on {xLabel|mmm yyyy}: {value} MJoule'");
        }