Esempio n. 1
0
        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", 8).setFontAngle(70);
            c.xAxis().setLabelStyle("Arial Bold", 8);
            c.yAxis().setLabelStyle("Arial   Bold", 9);
            // 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;
        }
        public void createChart2(WinChartViewer viewer, string img)
        {
            // The data for the chart
            Chart.setLicenseCode("DEVP-2LSU-B4LX-YCTY-2DF2-77EE");
            double[] data = data_w2;

            // The labels for the chart
            string[] labels = label_w2;

            // In the pareto chart, the line data are just the accumulation of the
            // raw data, scaled to a range of 0 - 100%
            ArrayMath lineData = new ArrayMath(data);


            lineData.acc();
            double scaleFactor = lineData.max() / 100;

            if (scaleFactor == 0)
            {
                // Avoid division by zero error for zero data
                scaleFactor = 1;
            }
            lineData.div2(scaleFactor);

            // Create a XYChart object of size 480 x 300 pixels. Set background color
            // to brushed silver, with a grey (bbbbbb) border and 2 pixel 3D raised
            // effect. Use rounded corners. Enable soft drop shadow.
            // XYChart c = new XYChart(400, 300, Chart.brushedSilverColor(), 0xbbbbbb, 2);
            XYChart c = new XYChart(viewer.Width, viewer.Height);

            c.setBorder(10);
            // c.setRoundedFrame();
            // c.setDropShadow();

            // Add a title to the chart using 15 points Arial Italic. Set top/bottom
            // margins to 12 pixels.

            ChartDirector.TextBox title = c.addTitle(Chart.Top, _txtTit2,
                                                     "Arial Bold", 12, 0xffffff, 0x1c86ee);
            title.setMargin2(10, 10, 6, 12);
            title.setPos(10, 3);
            title.setSize(viewer.Width - 20, 30);

            // Tentatively set the plotarea at (50, 40). Set the width to 100 pixels
            // less than the chart width, and the height to 80 pixels less than the
            // chart height. Use pale grey (f4f4f4) background, transparent border,
            // and dark grey (444444) dotted grid lines.
            //c.setPlotArea(50, 40, c.getWidth() - 100, c.getHeight() - 80, 0xf4f4f4,
            //    -1, Chart.Transparent, c.dashLineColor(0x444444, Chart.DotLine));
            c.setPlotArea(50, 50, c.getWidth() - 110, c.getHeight() - 250, 0xf4f4f4,
                          -1, Chart.Transparent, c.dashLineColor(0xffffff, Chart.Transparent));

            // Add a line layer for the pareto line
            LineLayer lineLayer = c.addLineLayer2();

            // Add the pareto line using deep blue (0000ff) as the color, with circle
            // symbols
            ArrayMath li = new ArrayMath(lineData.result());
            ArrayMath am = new ArrayMath(data);

            //lineLayer.addDataSet(li.mul(_cnt / 100.0).result(), 0x0000ff).setDataSymbol(
            //    Chart.CircleShape, 9, 0x0000ff, 0x0000ff);

            lineLayer.addDataSet(lineData.result(), 0x0000ff).setDataSymbol(
                Chart.CircleShape, 9, 0x0000ff, 0x0000ff);

            // Set the line width to 2 pixel
            lineLayer.setLineWidth(2);

            // Bind the line layer to the secondary (right) y-axis.
            lineLayer.setUseYAxis2();

            // Tool tip for the line layer
            lineLayer.setHTMLImageMap("", "",
                                      "title='Top {={x}+1} items: {value|2}%'");

            // Add a multi-color bar layer using the given data.
            //BarLayer barLayer = c.addBarLayer(am.mul(_cnt / 100.0).result(), 0x2dff64);
            BarLayer barLayer = c.addBarLayer(data, 0x2dff64);

            // Set soft lighting for the bars with light direction from the right
            barLayer.setBorderColor(Chart.Transparent, Chart.softLighting(Chart.Right
                                                                          ));


            c.xAxis().setLabelStyle("Arial Bold", 8).setFontAngle(70);
            c.yAxis().setLabelStyle("Arial Bold", 9);
            c.yAxis2().setLabelStyle("Arial Bold", 9);

            // Tool tip for the bar layer
            // barLayer.setHTMLImageMap("", "", "title='{xLabel}: {value} pieces'");

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

            // Set the secondary (right) y-axis scale as 0 - 100 with a tick every 20
            // units
            c.yAxis2().setLinearScale(0, 100, 10);

            // Set the format of the secondary (right) y-axis label to include a
            // percentage sign
            c.yAxis2().setLabelFormat("{value}%");

            // Set the relationship between the two y-axes, which only differ by a
            // scaling factor
            c.yAxis().setLinearScale(0, 1600, 160);
            //c.yAxis().syncAxis(c.yAxis2(), scaleFactor);

            // Set the format of the primary y-axis label foramt to show no decimal
            // point
            c.yAxis().setLabelFormat("{value|0}");
            c.setNumberFormat(',');

            // Add a title to the primary y-axis
            // c.yAxis().setTitle("Frequency");



            // Set all axes to transparent
            //  c.xAxis().setColors(Chart.Transparent);
            //  c.yAxis().setColors(Chart.Transparent);
            // c.yAxis2().setColors(Chart.Transparent);

            // Adjust the plot area size, such that the bounding box (inclusive of
            // axes) is 10 pixels from the left edge, just below the title, 10 pixels
            // from the right edge, and 20 pixels from the bottom edge.
            //c.packPlotArea(10, title.getHeight(), c.getWidth() - 10, c.getHeight() -
            //    20);

            // Output the chart
            viewer.Chart = c;

            // Include tool tip for the chart
            // viewer.ImageMap = c.getHTMLImageMap("clickable");
        }
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WPFChartViewer viewer, int chartIndex)
        {
            // The data for the chart
            double[] data0 = { 42, 49, Chart.NoValue, 38, 64, 56, 29, 41, 44, 57 };
            double[] data1 = { 65, 75, 47, 34, 42, 49, 73, Chart.NoValue, 90, 69, 66, 78 };
            double[] data2 = { Chart.NoValue, Chart.NoValue, 25, 28, 38, 20, 22, Chart.NoValue, 25,
                               33,                       30, 24 };
            string[] labels = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
                                "Nov", "Dec" };

            // Create a XYChart object of size 600 x 360 pixels. Set background color to brushed
            // silver, with a 2 pixel 3D border. Use rounded corners.
            XYChart c = new XYChart(600, 360, Chart.brushedSilverColor(), Chart.Transparent, 2);

            c.setRoundedFrame();

            // Add a title using 18pt Times New Roman Bold Italic font. #Set top/bottom margins to 6
            // pixels.
            ChartDirector.TextBox title = c.addTitle("Product Line Global Revenue",
                                                     "Times New Roman Bold Italic", 18);
            title.setMargin2(0, 0, 6, 6);

            // Add a separator line just under the title
            c.addLine(10, title.getHeight(), c.getWidth() - 11, title.getHeight(), Chart.LineColor);

            // Add a legend box where the top-center is anchored to the horizontal center of the
            // chart, just under the title. Use horizontal layout and 10 points Arial Bold font, and
            // transparent background and border.
            LegendBox legendBox = c.addLegend(c.getWidth() / 2, title.getHeight(), false,
                                              "Arial Bold", 10);

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

            // Tentatively set the plotarea at (70, 75) and of 460 x 240 pixels in size. Use
            // transparent border and black (000000) grid lines
            c.setPlotArea(70, 75, 460, 240, -1, -1, Chart.Transparent, 0x000000, -1);

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

            // Show the same scale on the left and right y-axes
            c.syncYAxis();

            // Set y-axis tick density to 30 pixels. ChartDirector auto-scaling will use this as the
            // guideline when putting ticks on the y-axis.
            c.yAxis().setTickDensity(30);

            // Set all axes to transparent
            c.xAxis().setColors(Chart.Transparent);
            c.yAxis().setColors(Chart.Transparent);
            c.yAxis2().setColors(Chart.Transparent);

            // Set the x-axis margins to 15 pixels, so that the horizontal grid lines can extend
            // beyond the leftmost and rightmost vertical grid lines
            c.xAxis().setMargin(15, 15);

            // Set axis label style to 8pt Arial Bold
            c.xAxis().setLabelStyle("Arial Bold", 8);
            c.yAxis().setLabelStyle("Arial Bold", 8);
            c.yAxis2().setLabelStyle("Arial Bold", 8);

            // Add axis title using 10pt Arial Bold Italic font
            c.yAxis().setTitle("Revenue in USD millions", "Arial Bold Italic", 10);
            c.yAxis2().setTitle("Revenue in USD millions", "Arial Bold Italic", 10);

            // Add the first line. The missing data will be represented as gaps in the line (the
            // default behaviour)
            LineLayer layer0 = c.addLineLayer2();

            layer0.addDataSet(data0, 0xff0000, "Quantum Computer").setDataSymbol(
                Chart.GlassSphere2Shape, 11);
            layer0.setLineWidth(3);

            // Add the second line. The missing data will be represented by using dash lines to
            // bridge the gap
            LineLayer layer1 = c.addLineLayer2();

            layer1.addDataSet(data1, 0x00ff00, "Atom Synthesizer").setDataSymbol(
                Chart.GlassSphere2Shape, 11);
            layer1.setLineWidth(3);
            layer1.setGapColor(c.dashLineColor(0x00ff00));

            // Add the third line. The missing data will be ignored - just join the gap with the
            // original line style.
            LineLayer layer2 = c.addLineLayer2();

            layer2.addDataSet(data2, 0xff6600, "Proton Cannon").setDataSymbol(
                Chart.GlassSphere2Shape, 11);
            layer2.setLineWidth(3);
            layer2.setGapColor(Chart.SameAsMainColor);

            // layout the legend so we can get the height of the legend box
            c.layoutLegend();

            // Adjust the plot area size, such that the bounding box (inclusive of axes) is 15
            // pixels from the left edge, just under the legend box, 16 pixels from the right edge,
            // and 25 pixels from the bottom edge.
            c.packPlotArea(15, legendBox.getTopY() + legendBox.getHeight(), c.getWidth() - 16,
                           c.getHeight() - 25);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Revenue of {dataSetName} in {xLabel}: US$ {value}M'");
        }
Esempio n. 4
0
        //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 = { 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.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Year {xLabel}: US$ {value}M'");
        }
Esempio n. 5
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)
        {
            // Data for the chart
            double[] data0 = { 1700, 3900, 2900, 3800, 4100, 4600, 2900, 4100, 4400, 5700, 5900,
                               5200, 3700, 3400, 5100, 5600, 5600, 6000, 7000, 7600, 6300, 6700, 7500, 6400, 8800 };
            double[] data1 = { 500, 550, 670, 990, 820, 730, 800, 720, 730, 790, 860, 800, 840, 680,
                               740, 890, 680, 790, 730, 770, 840, 820, 800, 840, 670 };
            double[] data2 = { 46, 68, 35, 33, 38, 20, 12, 18, 15, 23, 30, 24, 28, 15, 21, 26, 46,
                               42, 38, 25, 23, 32, 24, 20, 25 };
            double[] data3 = { 0.84, 0.82, 0.82, 0.38, 0.25, 0.52, 0.54, 0.52, 0.38, 0.51, 0.46,
                               0.29,  0.5, 0.55, 0.47, 0.34, 0.52, 0.33, 0.21,  0.3, 0.25, 0.15,0.18, 0.22, 0.14 };

            // 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 600 x 360 pixels. Use a vertical gradient color from
            // sky blue (aaccff) to white (ffffff) as background. Set border to grey (888888). Use
            // rounded corners. Enable soft drop shadow.
            XYChart c = new XYChart(600, 360);

            c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight(), 0xaaccff, 0xffffff),
                            0x888888);
            c.setRoundedFrame();
            c.setDropShadow();

            // Add a title box to the chart using 15pt Arial Bold Italic font. Set top margin to 16
            // pixels.
            ChartDirector.TextBox title = c.addTitle("Multiple Axes Demonstration",
                                                     "Arial Bold Italic", 15);
            title.setMargin2(0, 0, 16, 0);

            // Set the plotarea at (100, 80) and of size 400 x 230 pixels, with white (ffffff)
            // background. Use grey #(aaaaa) dotted lines for both horizontal and vertical grid
            // lines.
            c.setPlotArea(100, 80, 400, 230, 0xffffff, -1, -1, c.dashLineColor(0xaaaaaa,
                                                                               Chart.DotLine), -1);

            // Add a legend box with the bottom center anchored at (300, 80) (top center of the plot
            // area). Use horizontal layout, and 8 points Arial Bold font. Set background and border
            // to transparent.
            LegendBox legendBox = c.addLegend(300, 80, false, "Arial Bold", 8);

            legendBox.setAlignment(Chart.BottomCenter);
            legendBox.setBackground(Chart.Transparent, Chart.Transparent);

            // 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
            c.xAxis().setTitle("Hour of Day");

            // Add a title on top of the primary (left) y axis.
            c.yAxis().setTitle("Power\n(Watt)").setAlignment(Chart.TopLeft2);
            // Set the axis, label and title colors for the primary y axis to red (c00000) to match
            // the first data set
            c.yAxis().setColors(0xcc0000, 0xcc0000, 0xcc0000);

            // Add a title on top of the secondary (right) y axis.
            c.yAxis2().setTitle("Load\n(Mbps)").setAlignment(Chart.TopRight2);
            // Set the axis, label and title colors for the secondary y axis to green (00800000) to
            // match the second data set
            c.yAxis2().setColors(0x008000, 0x008000, 0x008000);

            // Add the third y-axis at 50 pixels to the left of the plot area
            Axis leftAxis = c.addAxis(Chart.Left, 50);

            // Add a title on top of the third y axis.
            leftAxis.setTitle("Temp\n(C)").setAlignment(Chart.TopLeft2);
            // Set the axis, label and title colors for the third y axis to blue (0000cc) to match
            // the third data set
            leftAxis.setColors(0x0000cc, 0x0000cc, 0x0000cc);

            // Add the fouth y-axis at 50 pixels to the right of the plot area
            Axis rightAxis = c.addAxis(Chart.Right, 50);

            // Add a title on top of the fourth y axis.
            rightAxis.setTitle("Error\n(%)").setAlignment(Chart.TopRight2);
            // Set the axis, label and title colors for the fourth y axis to purple (880088) to
            // match the fourth data set
            rightAxis.setColors(0x880088, 0x880088, 0x880088);

            // Add a line layer to for the first data set using red (c00000) color, with a line
            // width of 2 pixels
            LineLayer layer0 = c.addLineLayer(data0, 0xcc0000, "Power");

            layer0.setLineWidth(2);

            // Add a line layer to for the second data set using green (00c0000) color, with a line
            // width of 2 pixels. Bind the layer to the secondary y-axis.
            LineLayer layer1 = c.addLineLayer(data1, 0x008000, "Load");

            layer1.setLineWidth(2);
            layer1.setUseYAxis2();

            // Add a line layer to for the third data set using blue (0000cc) color, with a line
            // width of 2 pixels. Bind the layer to the third y-axis.
            LineLayer layer2 = c.addLineLayer(data2, 0x0000cc, "Temperature");

            layer2.setLineWidth(2);
            layer2.setUseYAxis(leftAxis);

            // Add a line layer to for the fourth data set using purple (880088) color, with a line
            // width of 2 pixels. Bind the layer to the fourth y-axis.
            LineLayer layer3 = c.addLineLayer(data3, 0x880088, "Error Rate");

            layer3.setLineWidth(2);
            layer3.setUseYAxis(rightAxis);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} at hour {xLabel} = {value}'");
        }
Esempio n. 6
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 (x, y, z) coordinates of the scattered data
            double[] dataX = { 0.5, 1.9, 4.9, 1.0,  8.9,  9.8, 5.9, 2.9, 6.8, 9.0, 0.0,
                               8.9, 1.9, 4.8, 2.4,  3.4,  7.9, 7.5, 4.8, 7.5, 9.5, 0.4, 8.9, 0.9, 5.4,
                               9.4, 2.9, 8.9, 0.9,  8.9, 10.0, 1.0, 6.8, 3.8, 9.0, 5.3, 6.4, 4.9,
                               4.5, 2.0, 5.4, 0.0, 10.0,  3.9, 5.4, 5.9, 5.8, 0.3, 4.4, 8.3 };
            double[] dataY = { 3.3, 3.0, 0.7, 1.0, 9.3, 4.5, 8.4, 0.1, 0.8, 0.1, 9.3,
                               1.8, 4.3, 1.3, 2.3, 5.4, 6.9, 9.0, 9.8, 7.5, 1.8, 1.4, 4.5, 7.8, 3.8,
                               4.0, 2.9, 2.4, 3.9, 2.9, 2.3, 9.3, 2.0, 3.4, 4.8, 2.3, 3.4, 2.3, 1.5,
                               7.8, 4.5, 0.9, 6.3, 2.4, 6.9, 2.8, 1.3, 2.9, 6.4, 6.3 };
            double[] dataZ = { 6.6, 12.5, 7.4,  6.2, 9.6, 13.6, 19.9,  2.2,  6.9,  3.4,
                               8.7,  8.4, 7.8,  8.0, 9.4, 11.9,  9.6, 15.7, 12.0, 13.3,  9.6,  6.4,  9.0,
                               6.9,  4.6, 9.7, 10.6, 9.2,  7.0,  6.9,  9.7,  8.6,  8.0, 13.6, 13.2,  5.9,
                               9.0,  3.2, 8.3,  9.7, 8.2,  6.1,  8.7,  5.6, 14.9,  9.8,  9.3,  5.1, 10.8,
                               9.8 };

            // Create a SurfaceChart object of size 680 x 550 pixels. Set background
            // to brushed silver and border to grey (888888). Set the top-left and
            // bottom-right corners to rounded corners with 20 pixels radius.
            SurfaceChart c = new SurfaceChart(680, 550, Chart.brushedSilverColor(),
                                              0x888888);

            c.setRoundedFrame(0xffffff, 20, 0, 20, 0);

            // Add a title to the chart using 20 points Times New Roman Italic font.
            // Set top/bottom margin to 8 pixels.
            ChartDirector.TextBox title = c.addTitle(
                "Surface Created Using Scattered Data Points",
                "Times New Roman Italic", 20);
            title.setMargin2(0, 0, 8, 8);

            // Add a 2 pixel wide black (000000) separator line under the title
            c.addLine(10, title.getHeight(), c.getWidth() - 10, title.getHeight(),
                      0x000000, 2);

            // Set the center of the plot region at (290, 235), and set width x depth
            // x height to 360 x 360 x 180 pixels
            c.setPlotRegion(290, 235, 360, 360, 180);

            // Set the elevation and rotation angles to 45 and -45 degrees
            c.setViewAngle(45, -45);

            // Set the perspective level to 30
            c.setPerspective(30);

            // Set the data to use to plot the chart
            c.setData(dataX, dataY, dataZ);

            // Add a color axis (the legend) in which the top right corner is
            // anchored at (660, 80). Set the length to 200 pixels and the labels on
            // the right side.
            ColorAxis cAxis = c.setColorAxis(660, 80, Chart.TopRight, 200,
                                             Chart.Right);

            // Set the color axis title with 12 points Arial Bold font
            cAxis.setTitle("Z Title Placeholder", "Arial Bold", 12);

            // Add a bounding box with light grey (eeeeee) background and grey
            // (888888) border. Set the top-left and bottom-right corners to rounded
            // corners of  10 pixels radius.
            cAxis.setBoundingBox(0xeeeeee, 0x888888);
            cAxis.setRoundedCorners(10, 0, 10, 0);

            // Set surface grid lines to semi-transparent black (cc000000)
            c.setSurfaceAxisGrid(unchecked ((int)0xcc000000));

            // Set contour lines to semi-transparent white (80ffffff)
            c.setContourColor(unchecked ((int)0x80ffffff));

            // Set the walls to black in color
            c.setWallColor(0x000000);

            // Set the xyz major wall grid lines to white (ffffff), and minor wall
            // grid lines to grey (888888)
            c.setWallGrid(0xffffff, 0xffffff, 0xffffff, 0x888888, 0x888888, 0x888888)
            ;

            // Set the wall thickness to 0
            c.setWallThickness(0, 0, 0);

            // Show only the xy wall, and hide the yz and zx walls.
            c.setWallVisibility(true, false, false);

            // Set the x, y and z axis titles using 12 points Arial Bold font
            c.xAxis().setTitle("X Title\nPlaceholder", "Arial Bold", 12);
            c.yAxis().setTitle("Y Title\nPlaceholder", "Arial Bold", 12);

            // Output the chart
            viewer.Image = c.makeImage();
        }
Esempio n. 7
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer, int chartIndex)
        {
            // The value to display on the meter
            double value = 75.35;

            // Create a LinearMeter object of size 250 x 75 pixels with very light grey (0xeeeeee)
            // backgruond and a light grey (0xccccccc) 3-pixel thick rounded frame
            LinearMeter m = new LinearMeter(70, 260, 0xeeeeee, 0xcccccc);

            m.setRoundedFrame(Chart.Transparent);
            m.setThickFrame(3);

            // Set the scale region top-left corner at (28, 30), with size of 20 x 196 pixels. The scale
            // labels are located on the left (default - implies vertical meter)
            m.setMeter(28, 30, 20, 196);

            // Set meter scale from 0 - 100, with a tick every 10 units
            m.setScale(0, 100, 10);

            // Demostrate different types of color scales and putting them at different positions
            double[] smoothColorScale = { 0, 0x6666ff, 25, 0x00bbbb, 50, 0x00ff00, 75, 0xffff00, 100,
                                          0xff0000 };
            double[] stepColorScale    = { 0, 0x33ff33, 50, 0xffff33, 80, 0xff3333, 100 };
            double[] highLowColorScale = { 0, 0x6666ff, 70, Chart.Transparent, 100, 0xff0000 };

            if (chartIndex == 0)
            {
                // Add the smooth color scale at the default position
                m.addColorScale(smoothColorScale);
            }
            else if (chartIndex == 1)
            {
                // Add the step color scale at the default position
                m.addColorScale(stepColorScale);
            }
            else if (chartIndex == 2)
            {
                // Add the high low scale at the default position
                m.addColorScale(highLowColorScale);
            }
            else if (chartIndex == 3)
            {
                // Add the smooth color scale starting at x = 28 (left of scale) with zero width and
                // ending at x = 28 with 20 pixels width
                m.addColorScale(smoothColorScale, 28, 0, 28, 20);
            }
            else if (chartIndex == 4)
            {
                // Add the smooth color scale starting at x = 38 (center of scale) with zero width and
                // ending at x = 28 with 20 pixels width
                m.addColorScale(smoothColorScale, 38, 0, 28, 20);
            }
            else
            {
                // Add the smooth color scale starting at x = 48 (right of scale) with zero width and
                // ending at x = 28 with 20 pixels width
                m.addColorScale(smoothColorScale, 48, 0, 28, 20);
            }

            // In this demo, we demostrate pointers of different shapes
            if (chartIndex < 3)
            {
                // Add a blue (0x0000cc) pointer of default shape at the specified value
                m.addPointer(value, 0x0000cc);
            }
            else
            {
                // Add a blue (0x0000cc) pointer of triangular shape the specified value
                m.addPointer(value, 0x0000cc).setShape(Chart.TriangularPointer, 0.7, 0.5);
            }

            // Add a title using 8pt Arial Bold font with a border color background
            m.addTitle("Temp C", "Arial Bold", 8, Chart.TextColor).setBackground(0xcccccc);

            // Add a text box at the bottom-center. Display the value using white (0xffffff) 8pt Arial
            // Bold font on a black (0x000000) background with rounded border.
            ChartDirector.TextBox t = m.addText(m.getWidth() / 2, m.getHeight() - 8, m.formatValue(value,
                                                                                                   "2"), "Arial Bold", 8, 0xffffff, Chart.Bottom);
            t.setBackground(0x000000);
            t.setRoundedCorners(3);
            t.setMargin2(5, 5, 2, 1);

            // Output the chart
            viewer.Image = m.makeWebImage(Chart.PNG);
        }
Esempio n. 8
0
        //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 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");
        }
Esempio n. 9
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The data for the bar chart
            double[] data0 = { 100, 125, 245, 147, 67 };
            double[] data1 = { 85, 156, 179, 211, 123 };
            double[] data2 = { 97, 87, 56, 267, 157 };

            // The labels for the bar chart
            string[] labels = { "Mon", "Tue", "Wed", "Thu", "Fri" };

            // Create a XYChart object of size 500 x 320 pixels. Use a vertical gradient color from pale
            // blue (e8f0f8) to sky blue (aaccff) spanning half the chart height as background. Set
            // border to blue (88aaee). Use rounded corners. Enable soft drop shadow.
            XYChart c = new XYChart(500, 320);

            c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight() / 2, 0xe8f0f8, 0xaaccff),
                            0x88aaee);
            c.setRoundedFrame();
            c.setDropShadow();

            //Set default directory for loading images
            c.setSearchPath(Url.Content("~/Content"));

            // Add a title to the chart using 15 points Arial Italic. Set top/bottom margins to 15
            // pixels.
            ChartDirector.TextBox title = c.addTitle("Weekly Product Sales", "Arial Italic", 15);
            title.setMargin2(0, 0, 15, 15);

            // Tentatively set the plotarea to 50 pixels from the left edge, and to just under the title.
            // Set the width to 60% of the chart width, and the height to 50 pixels from the bottom edge.
            // Use pale blue (e8f0f8) background, transparent border, and grey (aaaaaa) grid lines.
            c.setPlotArea(50, title.getHeight(), c.getWidth() * 6 / 10, c.getHeight() - title.getHeight()
                          - 50, 0xe8f0f8, -1, Chart.Transparent, 0xaaaaaa);

            // Add a legend box where the top-right corner is anchored at 10 pixels from the right edge,
            // and just under the title. Use vertical layout and 8 points Arial font.
            LegendBox legendBox = c.addLegend(c.getWidth() - 10, title.getHeight(), true, "Arial", 8);

            legendBox.setAlignment(Chart.TopRight);

            // Set the legend box background and border to transparent
            legendBox.setBackground(Chart.Transparent, Chart.Transparent);

            // Set the legend box icon size to 16 x 32 pixels to match with custom icon size
            legendBox.setKeySize(16, 32);

            // Set axes to transparent
            c.xAxis().setColors(Chart.Transparent);
            c.yAxis().setColors(Chart.Transparent);

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

            // Add a percentage bar layer
            BarLayer layer = c.addBarLayer2(Chart.Percentage);

            // Add the three data sets to the bar layer, using icons images with labels as data set names
            layer.addDataSet(data0, 0x66aaee,
                             "<*block,valign=absmiddle*><*img=service.png*> Service<*/*>");
            layer.addDataSet(data1, 0xeebb22,
                             "<*block,valign=absmiddle*><*img=software.png*> Software<*/*>");
            layer.addDataSet(data2, 0xcc88ff,
                             "<*block,valign=absmiddle*><*img=computer.png*> Hardware<*/*>");

            // Use soft lighting effect with light direction from top
            layer.setBorderColor(Chart.Transparent, Chart.softLighting(Chart.Top));

            // Enable data label at the middle of the the bar
            layer.setDataLabelStyle().setAlignment(Chart.Center);

            // For a vertical stacked chart with positive data only, the last data set is always on top.
            // However, in a vertical legend box, the last data set is at the bottom. This can be
            // reversed by using the setLegend method.
            layer.setLegend(Chart.ReverseLegend);

            // Adjust the plot area size, such that the bounding box (inclusive of axes) is 15 pixels
            // from the left edge, just below the title, 10 pixels to the right of the legend box, and 15
            // pixels from the bottom edge.
            c.packPlotArea(15, title.getHeight(), c.layoutLegend().getLeftX() - 10, c.getHeight() - 15);

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "",
                                                "title='{dataSetName} revenue on {xLabel}: US${value}K ({percent}%)'");
        }
Esempio n. 10
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)
        {
            // In this example, the data points are unevenly spaced on the x-axis
            double[]   dataY = { 4.7, 4.7, 6.6, 2.2, 4.7, 4.0, 4.0, 5.1, 4.5, 4.5, 6.8, 4.5, 4, 2.1, 3,
                                 2.5,   2.5, 3.1 };
            DateTime[] dataX = { new DateTime(1999,                                                                                       7,  1), new DateTime(2000,                 1,  1), new DateTime(
                                     2000,                                                                                                2,  1), new DateTime(2000,                 4,  1), new DateTime(2000,                 5, 8), new DateTime(2000,
                                                                                                                                                                                                                                                    7,                    5), new DateTime(2001,   3,                5), new DateTime(2001,   4,                7),new DateTime(2001,5, 9),
                                 new DateTime(2002,                                                                                       2,  4), new DateTime(2002,                 4,  4), new DateTime(2002,                 5, 8),
                                 new DateTime(2002,                                                                                       7,  7), new DateTime(2002,                 8, 30), new DateTime(2003,                 1, 2),
                                 new DateTime(2003,                                                                                       2, 16), new DateTime(2003,                11,  6), new DateTime(2004,                 1, 4) };

            // Data points are assigned different symbols based on point type
            double[] pointType = { 0, 1, 0, 1, 2, 1, 0, 0, 1, 1, 2, 2, 1, 0, 2, 1, 2, 0 };

            // Create a XYChart object of size 480 x 320 pixels. Use a vertical gradient color from
            // pale blue (e8f0f8) to sky blue (aaccff) spanning half the chart height as background.
            // Set border to blue (88aaee). Use rounded corners. Enable soft drop shadow.
            XYChart c = new XYChart(480, 320);

            c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight() / 2, 0xe8f0f8, 0xaaccff),
                            0x88aaee);
            c.setRoundedFrame();
            c.setDropShadow();

            // Add a title to the chart using 15 points Arial Italic font. Set top/bottom margins to
            // 12 pixels.
            ChartDirector.TextBox title = c.addTitle("Multi-Symbol Line Chart Demo", "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 and vertical grid lines.
            c.setPlotArea(50, title.getHeight(), c.getWidth() - 65, c.getHeight() - title.getHeight(
                              ) - 90, 0xe8f0f8, -1, Chart.Transparent, c.dashLineColor(0x888888, Chart.DotLine),
                          -1);

            // Add a legend box where the bottom-center is anchored to the 12 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() - 12, false,
                                              "Arial Bold", 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);

            // Set the y axis label format to display a percentage sign
            c.yAxis().setLabelFormat("{value}%");

            // Set y-axis title to use 10 points Arial Bold Italic font
            c.yAxis().setTitle("Axis Title Placeholder", "Arial Bold Italic", 10);

            // Set axis labels to use Arial Bold font
            c.yAxis().setLabelStyle("Arial Bold");
            c.xAxis().setLabelStyle("Arial Bold");

            // We add the different data symbols using scatter layers. The scatter layers are added
            // before the line layer to make sure the data symbols stay on top of the line layer.

            // We select the points with pointType = 0 (the non-selected points will be set to
            // NoValue), and use yellow (ffff00) 15 pixels high 5 pointed star shape symbols for the
            // points. (This example uses both x and y coordinates. For charts that have no x
            // explicitly coordinates, use an empty array as dataX.)
            c.addScatterLayer(Chart.CTime(dataX), new ArrayMath(dataY).selectEQZ(pointType,
                                                                                 Chart.NoValue).result(), "Point Type 0", Chart.StarShape(5), 15, 0xffff00);

            // Similar to above, we select the points with pointType - 1 = 0 and use green (ff00) 13
            // pixels high six-sided polygon as symbols.
            c.addScatterLayer(Chart.CTime(dataX), new ArrayMath(dataY).selectEQZ(new ArrayMath(
                                                                                     pointType).sub(1).result(), Chart.NoValue).result(), "Point Type 1",
                              Chart.PolygonShape(6), 13, 0x00ff00);

            // Similar to above, we select the points with pointType - 2 = 0 and use red (ff0000) 13
            // pixels high X shape as symbols.
            c.addScatterLayer(Chart.CTime(dataX), new ArrayMath(dataY).selectEQZ(new ArrayMath(
                                                                                     pointType).sub(2).result(), Chart.NoValue).result(), "Point Type 2",
                              Chart.Cross2Shape(), 13, 0xff0000);

            // Finally, add a blue (0000ff) line layer with line width of 2 pixels
            LineLayer layer = c.addLineLayer(dataY, 0x0000ff);

            layer.setXData(Chart.CTime(dataX));
            layer.setLineWidth(2);

            // Adjust the plot area size, such that the bounding box (inclusive of axes) is 10
            // pixels from the left edge, just below the title, 25 pixels from the right edge, and 8
            // pixels above the legend box.
            c.packPlotArea(10, title.getHeight(), c.getWidth() - 25, c.layoutLegend().getTopY() - 8)
            ;

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{x|mmm dd, yyyy}: {value}%'");
        }
Esempio n. 11
0
        //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 = { 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.Chart = c;

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable");
        }
Esempio n. 12
0
        //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 pie chart
            double[] data = { 20, 10, 15, 12 };

            // The labels for the pie chart
            string[] labels = { "Labor", "Licenses", "Facilities", "Production" };

            // The colors to use for the sectors
            int[] colors = { 0x66aaee, 0xeebb22, 0xcccccc, 0xcc88ff };

            // Create a PieChart object of size 600 x 320 pixels. Use a vertical gradient color from
            // deep blue (000066) to blue (0000cc) as background. Use rounded corners of 20 pixels
            // radius.
            PieChart c = new PieChart(600, 320);

            c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight(), 0x000066, 0x0000cc));
            c.setRoundedFrame(0xffffff, 20);

            // Add a title using 18pt Times New Roman Bold Italic font in white (ffffff) color. Set
            // top/bottom margins to 8 pixels.
            ChartDirector.TextBox title = c.addTitle("Donut Chart Demonstration",
                                                     "Times New Roman Bold Italic", 18, 0xffffff);
            title.setMargin2(0, 0, 8, 8);

            // Add a separator line in white color just under the title
            c.addLine(10, title.getHeight(), c.getWidth() - 11, title.getHeight(), 0xffffff);

            // Set donut center at (300, 170), and outer/inner radii as 120/60 pixels
            c.setDonutSize(300, 170, 120, 60);

            // Draw the pie in 3D with a pie thickness of 25 pixels
            c.set3D(25);

            // Set the pie data and the pie labels
            c.setData(data, labels);

            // Set the sector colors
            c.setColors2(Chart.DataColor, colors);

            // Use local gradient shading for the sectors
            c.setSectorStyle(Chart.LocalGradientShading);

            // Set sector border color to same as fill color. Set label join line color to white
            // (ffffff)
            c.setLineColor(Chart.SameAsMainColor, 0xffffff);

            // Use the side label layout method, with the labels positioned 16 pixels from the donut
            // bounding box
            c.setLabelLayout(Chart.SideLayout, 16);

            // Set the sector label format. The label consists of two lines. The first line is the
            // sector name in Times Bold Italic font and is underlined. The second line shows the
            // data value and percentage.
            c.setLabelFormat(
                "<*block,halign=left*><*font=Times New Roman Bold Italic,size=12,underline=1*>" +
                "{label}<*/font*><*br*>US$ {value}K ({percent}%)");

            // Set the label box background color the same as the sector color. Use soft lighting
            // effect with light direction from right. Use rounded corners.
            ChartDirector.TextBox t = c.setLabelStyle();
            t.setBackground(Chart.SameAsMainColor, Chart.Transparent, Chart.softLighting(Chart.Right
                                                                                         ));
            t.setRoundedCorners();

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{label}: US${value}K ({percent}%)'");
        }
Esempio n. 13
0
        //Main code for creating charts
        public void createChart(WinChartViewer viewer, int chartIndex)
        {
            // The value to display on the meter
            double value = 74.25;

            // Create a LinearMeter object of size 70 x 260 pixels with very light grey (0xeeeeee)
            // backgruond and a grey (0xbbbbbb) 3-pixel thick rounded frame
            LinearMeter m = new LinearMeter(70, 260, 0xeeeeee, 0xbbbbbb);

            m.setRoundedFrame(Chart.Transparent);
            m.setThickFrame(3);

            // Set the scale region top-left corner at (28, 33), with size of 20 x 194 pixels. The
            // scale labels are located on the left (default - implies vertical meter).
            m.setMeter(28, 33, 20, 194);

            // Set meter scale from 0 - 100, with a tick every 10 units
            m.setScale(0, 100, 10);

            // Demostrate different types of color scales
            double[] smoothColorScale = { 0, 0x0000ff, 25, 0x0088ff, 50, 0x00ff00, 75, 0xdddd00, 100,
                                          0xff0000 };
            double[] stepColorScale = { 0, 0x00dd00, 50, 0xffff00, 80, 0xff0000, 100 };
            double[] highColorScale = { 70, Chart.Transparent, 100, 0xff0000 };
            double[] lowColorScale  = { 0, 0x0000ff, 30, Chart.Transparent };

            if (chartIndex == 0)
            {
                // Add a blue (0x0088ff) bar from 0 to value with glass effect and 4 pixel rounded
                // corners
                m.addBar(0, value, 0x0088ff, Chart.glassEffect(Chart.NormalGlare, Chart.Left), 4);
                // Add a 6-pixel thick smooth color scale at x = 53 (right of meter scale)
                m.addColorScale(smoothColorScale, 53, 6);
            }
            else if (chartIndex == 1)
            {
                // Add a green (0x00cc00) bar from 0 to value with bar lighting effect and 4 pixel
                // rounded corners
                m.addBar(0, value, 0x00cc00, Chart.barLighting(), 4);
                // Add a high only color scale at x = 52 (right of meter scale) with thickness
                // varying from 0 to 8
                m.addColorScale(highColorScale, 52, 0, 52, 8);
                // Add a low only color scale at x = 52 (right of meter scale) with thickness
                // varying from 8 to 0
                m.addColorScale(lowColorScale, 52, 8, 52, 0);
            }
            else if (chartIndex == 2)
            {
                // Add a purple (0x0088ff) bar from 0 to value with glass effect and 4 pixel rounded
                // corners
                m.addBar(0, value, 0x8833dd, Chart.glassEffect(Chart.NormalGlare, Chart.Left), 4);
                // Add a high only color scale at x = 52 (right of meter scale) with thickness
                // varying from 0 to 8
                m.addColorScale(highColorScale, 52, 0, 52, 8);
            }
            else if (chartIndex == 3)
            {
                // Add a orange (0xff8800) bar from 0 to value with cylinder lighting effect
                m.addBar(0, value, 0xff8800, Chart.cylinderEffect());
                // Add a high only color scale at x = 53 (right of meter scale)
                m.addColorScale(highColorScale, 53, 6);
            }
            else if (chartIndex == 4)
            {
                // Add a red (0xee3333) bar from 0 to value with glass effect and 4 pixel rounded
                // corners
                m.addBar(0, value, 0xee3333, Chart.glassEffect(Chart.NormalGlare, Chart.Left), 4);
                // Add a step color scale at x = 53 (right of meter scale)
                m.addColorScale(stepColorScale, 53, 6);
            }
            else
            {
                // Add a grey (0xaaaaaa) bar from 0 to value
                m.addBar(0, value, 0xaaaaaa);
                // Add a smooth color scale at x = 52 (right of meter scale) with thickness varying
                // from 0 to 8
                m.addColorScale(smoothColorScale, 52, 0, 52, 8);
            }

            // Add a title using 8pt Arial Bold font with grey (0xbbbbbb) background
            m.addTitle("Temp C", "Arial Bold", 8, Chart.TextColor).setBackground(0xbbbbbb);

            // Add a text box at the bottom-center. Display the value using white (0xffffff) 8pt
            // Arial Bold font on a black (0x000000) background with rounded border.
            ChartDirector.TextBox t = m.addText(m.getWidth() / 2, m.getHeight() - 8, m.formatValue(
                                                    value, "2"), "Arial Bold", 8, 0xffffff, Chart.Bottom);
            t.setBackground(0x000000);
            t.setRoundedCorners(3);
            t.setMargin2(5, 5, 2, 1);

            // Output the chart
            viewer.Chart = m;
        }