Esempio n. 1
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[] data0 = { 100, 100, 100, 100, 100 };
            double[] data1 = { 90, 85, 85, 80, 70 };
            double[] data2 = { 80, 65, 65, 75, 45 };

            // The labels for the chart
            string[] labels = { "Population<*br*><*font=Arial*>6 millions",
                                "GDP<*br*><*font=Arial*>120 billions",     "Export<*br*><*font=Arial*>25 billions",
                                "Import<*br*><*font=Arial*>24 billions",
                                "Investments<*br*><*font=Arial*>20 billions" };

            // Create a PolarChart object of size 480 x 460 pixels. Set background color to silver,
            // with 1 pixel 3D border effect
            PolarChart c = new PolarChart(480, 460, Chart.silverColor(), 0x000000, 1);

            // Add a title to the chart using 15pt Times Bold Italic font. The title text is white
            // (ffffff) on a deep green (008000) background
            c.addTitle("Economic Growth", "Times New Roman Bold Italic", 15, 0xffffff
                       ).setBackground(0x008000);

            // Set plot area center at (240, 270), with 150 pixels radius
            c.setPlotArea(240, 270, 150);

            // Use 1 pixel width semi-transparent black (c0000000) lines as grid lines
            c.setGridColor(unchecked ((int)0xc0000000), 1, unchecked ((int)0xc0000000), 1);

            // Add a legend box at top-center of plot area (240, 35) using horizontal layout. Use
            // 10pt Arial Bold font, with silver background and 1 pixel 3D border effect.
            LegendBox b = c.addLegend(240, 35, false, "Arial Bold", 10);

            b.setAlignment(Chart.TopCenter);
            b.setBackground(Chart.silverColor(), Chart.Transparent, 1);

            // Add area layers of different colors to represent the data
            c.addAreaLayer(data0, 0xcc8880, "Year 2004");
            c.addAreaLayer(data1, 0xffd080, "Year 1994");
            c.addAreaLayer(data2, 0xa0bce0, "Year 1984");

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

            // Set radial axis from 0 - 100 with a tick every 20 units
            c.radialAxis().setLinearScale(0, 100, 20);

            // Just show the radial axis as a grid line. Hide the axis labels by setting the label
            // color to Transparent
            c.radialAxis().setColors(unchecked ((int)0xc0000000), Chart.Transparent);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Current {label}: {value}% in {dataSetName}'");
        }
        //
        // Draw the chart and display it in the given viewer.
        //
        private void drawChart2(WPFChartViewer viewer)
        {
            // Create an XYChart object 600 x 270 pixels in size, with light grey (f4f4f4)
            // background, black (000000) border, 1 pixel raised effect, and with a rounded frame.
            XYChart c = new XYChart(600, 270, 0xf4f4f4, 0x000000, 1);

            c.setRoundedFrame(0xffffff);

            // Set the plotarea at (55, 62) and of size 520 x 175 pixels. Use white (ffffff)
            // background. Enable both horizontal and vertical grids by setting their colors to
            // grey (cccccc). Set clipping mode to clip the data lines to the plot area.
            c.setPlotArea(55, 62, 520, 175, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
            c.setClipping();

            // Add a title to the chart using 15 pts Times New Roman Bold Italic font, with a light
            // grey (dddddd) background, black (000000) border, and a glass like raised effect.
            c.addTitle("Fast Fourier Transform", "Times New Roman Bold Italic", 15
                       ).setBackground(0xdddddd, 0x000000, Chart.glassEffect());

            // Add a legend box at the top of the plot area with 9pts Arial Bold font. We set the
            // legend box to the same width as the plot area and use grid layout (as opposed to
            // flow or top/down layout). This distributes the 3 legend icons evenly on top of the
            // plot area.
            LegendBox b = c.addLegend2(55, 33, 1, "Arial Bold", 9);

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

            // Configure the y-axis with a 10pts Arial Bold axis title
            c.yAxis().setTitle("Magnitude", "Arial Bold", 10);

            // Configure the x-axis to auto-scale with at least 75 pixels between major tick and 15
            // pixels between minor ticks. This shows more minor grid lines on the chart.
            c.xAxis().setTickDensity(75, 15);

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

            // c.yAxis().setDateScale(0, 600);

            // Set the x-axis label format
            //c.xAxis().setLabelFormat("{0:0.##}");

            // Create a line layer to plot the lines
            LineLayer layer = c.addLineLayer2();

            // Perform FFT if the option is chosen
            if (this.ShowFFT)
            {
                this.fftBuffer = this.computeNormalizedFFT(this.fftLength, this.fftOutLength);
            }
            // Add data to the layer
            layer.addDataSet(this.fftBuffer, 0xff0000);
            // Assign the chart to the WinChartViewer
            viewer.Chart = c;
        }
Esempio n. 3
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();
        }
Esempio n. 4
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 };

            string[] labels = { "North", "North<*br*>East", "East", "South<*br*>East",
                                "South", "South<*br*>West", "West", "North<*br*>West" };

            // Create a PolarChart object of size 460 x 500 pixels, with a grey
            // (e0e0e0) background and 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 a wood pattern as the title background.
            c.addTitle("Polar Area Chart Demo", "Arial Bold Italic", 15
                       ).setBackground(c.patternColor("wood.png"));

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

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

            // Add a legend box at top-center of plot area (230, 35) using horizontal
            // layout. Use 10 pts Arial Bold font, with 1 pixel 3D border effect.
            LegendBox b = c.addLegend(230, 35, false, "Arial Bold", 9);

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

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

            // Specify the label format for the radial axis
            c.radialAxis().setLabelFormat("{value}%");

            // Set radial axis label background to semi-transparent grey (40cccccc)
            c.radialAxis().setLabelStyle().setBackground(0x40cccccc, 0);

            // Add the data as area layers
            c.addAreaLayer(data2, -1, "5 m/s or above");
            c.addAreaLayer(data1, -1, "1 - 5 m/s");
            c.addAreaLayer(data0, -1, "less than 1 m/s");

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='[{label}] {dataSetName}: {value}%'");
        }
Esempio n. 5
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)
        {
            // Sample data for the Box-Whisker chart. Represents the minimum, 1st
            // quartile, medium, 3rd quartile and maximum values of some quantities
            double[] Q0Data = { 40, 45, 40, 30, 20, 50, 25, 44 };
            double[] Q1Data = { 55, 60, 50, 40, 38, 60, 51, 60 };
            double[] Q2Data = { 62, 70, 60, 50, 48, 70, 62, 70 };
            double[] Q3Data = { 70, 80, 65, 60, 53, 78, 69, 76 };
            double[] Q4Data = { 80, 90, 75, 70, 60, 85, 80, 84 };

            // The labels for the chart
            string[] labels = { "Group A", "Group B", "Group C", "Group D", "Group E",
                                "Group F", "Group G", "Group H" };

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

            // Set the plotarea at (50, 25) and of size 450 x 200 pixels. Enable both
            // horizontal and vertical grids by setting their colors to grey
            // (0xc0c0c0)
            c.setPlotArea(50, 50, 450, 200).setGridColor(0xc0c0c0, 0xc0c0c0);

            // Add a title to the chart
            c.addTitle("Computer Vision Test Scores");

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

            // Set the font for the y axis labels to Arial Bold
            c.yAxis().setLabelStyle("Arial Bold");

            // Add a Box Whisker layer using light blue 0x9999ff as the fill color
            // and blue (0xcc) as the line color. Set the line width to 2 pixels
            c.addBoxLayer(Q4Data, Q3Data, 0x00ff00, "Top 25%");
            c.addBoxLayer(Q3Data, Q2Data, 0x9999ff, "25% - 50%");
            c.addBoxLayer(Q2Data, Q1Data, 0xffff00, "50% - 75%");
            c.addBoxLayer(Q1Data, Q0Data, 0xff0000, "Bottom 25%");

            // Add legend box at top center above the plot area using 10 pts Arial
            // Bold Font
            LegendBox b = c.addLegend(50 + 225, 22, false, "Arial Bold", 10);

            b.setAlignment(Chart.TopCenter);
            b.setBackground(Chart.Transparent);

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{xLabel} ({dataSetName}): {bottom} to {top} points'");
        }
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 data for the chart
            double[] data0 = { 90, 60, 85, 75, 55 };
            double[] data1 = { 60, 80, 70, 80, 85 };

            // The labels for the chart
            string[] labels = { "Speed", "Reliability", "Comfort", "Safety",
                                "Efficiency" };

            // Create a PolarChart object of size 480 x 380 pixels. Set background
            // color to gold, with 1 pixel 3D border effect
            PolarChart c = new PolarChart(480, 380, Chart.goldColor(), 0x000000, 1);

            // Add a title to the chart using 15 pts Times Bold Italic font. The
            // title text is white (ffffff) on a deep blue (000080) background
            c.addTitle("Space Travel Vehicles Compared",
                       "Times New Roman Bold Italic", 15, 0xffffff).setBackground(0x000080);

            // Set plot area center at (240, 210), with 150 pixels radius, and a
            // white (ffffff) background.
            c.setPlotArea(240, 210, 150, 0xffffff);

            // Add a legend box at top right corner (470, 35) using 10 pts Arial Bold
            // font. Set the background to silver, with 1 pixel 3D border effect.
            LegendBox b = c.addLegend(470, 35, true, "Arial Bold", 10);

            b.setAlignment(Chart.TopRight);
            b.setBackground(Chart.silverColor(), Chart.Transparent, 1);

            // Add an area layer to the chart using semi-transparent blue
            // (0x806666cc). Add a blue (0x6666cc) line layer using the same data
            // with 3 pixel line width to highlight the border of the area.
            c.addAreaLayer(data0, unchecked ((int)0x806666cc), "Model Saturn");
            c.addLineLayer(data0, 0x6666cc).setLineWidth(3);

            // Add an area layer to the chart using semi-transparent red
            // (0x80cc6666). Add a red (0xcc6666) line layer using the same data with
            // 3 pixel line width to highlight the border of the area.
            c.addAreaLayer(data1, unchecked ((int)0x80cc6666), "Model Jupiter");
            c.addLineLayer(data1, 0xcc6666).setLineWidth(3);

            // 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 = c.getHTMLImageMap("clickable", "",
                                                "title='[{dataSetName}] {label}: score = {value}'");
        }
Esempio n. 7
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 pyramid chart
            double[] data = { 156, 123, 211, 179 };

            // The labels for the pyramid chart
            string[] labels = { "Funds", "Bonds", "Stocks", "Cash" };

            // The semi-transparent colors for the pyramid layers
            int[] colors = { 0x400000cc, 0x4066aaee, 0x40ffbb00, 0x40ee6622 };

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

            // Set the pyramid center at (220, 180), and width x height to 150 x 300
            // pixels
            c.setPyramidSize(220, 180, 150, 300);

            // Set the elevation to 15 degrees and rotation to 75 degrees
            c.setViewAngle(15, 75);

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

            // Set the layer colors to the given colors
            c.setColors2(Chart.DataColor, colors);

            // Leave 1% gaps between layers
            c.setLayerGap(0.01);

            // Add a legend box at (320, 60), with light grey (eeeeee) background and
            // grey (888888) border. Set the top-left and bottom-right corners to
            // rounded corners of 10 pixels radius.
            LegendBox legendBox = c.addLegend(320, 60);

            legendBox.setBackground(0xeeeeee, 0x888888);
            legendBox.setRoundedCorners(10, 0, 10, 0);

            // Add labels at the center of the pyramid layers using Arial Bold font.
            // The labels will show the percentage of the layers.
            c.setCenterLabel("{percent}%", "Arial Bold");

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{label}: US$ {value}M ({percent}%)'");
        }
Esempio n. 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 pie chart
            double[] data = { 25, 18, 15, 12, 8, 30, 35 };

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

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

            c.setRoundedFrame(0xffffff, 20);

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

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

            // Set donut center at (160, 175), and outer/inner radii as 110/55 pixels
            c.setDonutSize(160, 175, 110, 55);

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

            // Use ring shading effect for the sectors
            c.setSectorStyle(Chart.RingShading);

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

            // Show only the sector number as the sector label
            c.setLabelFormat("{={sector}+1}");

            // Set the sector label style to Arial Bold 10pt, with a dark grey
            // (444444) border
            c.setLabelStyle("Arial Bold", 10).setBackground(Chart.Transparent,
                                                            0x444444);

            // Add a legend box, with the center of the left side anchored at (330,
            // 175), and using 10 pts Arial Bold Italic font
            LegendBox b = c.addLegend(330, 175, true, "Arial Bold Italic", 10);

            b.setAlignment(Chart.Left);

            // Set the legend box border to dark grey (444444), and with rounded
            // conerns
            b.setBackground(Chart.Transparent, 0x444444);
            b.setRoundedCorners();

            // Set the legend box margin to 16 pixels, and the extra line spacing
            // between the legend entries as 5 pixels
            b.setMargin(16);
            b.setKeySpacing(0, 5);

            // Set the legend text to show the sector number, followed by a 120
            // pixels wide block showing the sector label, and a 40 pixels wide block
            // showing the percentage
            b.setText(
                "<*block,valign=top*>{={sector}+1}.<*advanceTo=22*>" +
                "<*block,width=120*>{label}<*/*><*block,width=40,halign=right*>" +
                "{percent}<*/*>%");

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{label}: US${value}K ({percent}%)'");
        }
Esempio n. 9
0
        //
        // Draw the chart and display it in the given viewer.
        //
        private void drawChart(WPFChartViewer viewer)
        {
            // Create an XYChart object 600 x 270 pixels in size, with light grey (f4f4f4)
            // background, black (000000) border, 1 pixel raised effect, and with a rounded frame.
            XYChart c = new XYChart(600, 270, 0xf4f4f4, 0x000000, 1);

            c.setRoundedFrame(0xffffff);

            // Set the plotarea at (55, 62) and of size 520 x 175 pixels. Use white (ffffff)
            // background. Enable both horizontal and vertical grids by setting their colors to
            // grey (cccccc). Set clipping mode to clip the data lines to the plot area.
            c.setPlotArea(55, 62, 520, 175, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
            c.setClipping();

            // Add a title to the chart using 15 pts Times New Roman Bold Italic font, with a light
            // grey (dddddd) background, black (000000) border, and a glass like raised effect.
            c.addTitle("Field Intensity at Observation Satellite", "Times New Roman Bold Italic", 15
                       ).setBackground(0xdddddd, 0x000000, Chart.glassEffect());

            // Add a legend box at the top of the plot area with 9pts Arial Bold font. We set the
            // legend box to the same width as the plot area and use grid layout (as opposed to
            // flow or top/down layout). This distributes the 3 legend icons evenly on top of the
            // plot area.
            LegendBox b = c.addLegend2(55, 33, 3, "Arial Bold", 9);

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

            // Configure the y-axis with a 10pts Arial Bold axis title
            c.yAxis().setTitle("Intensity (V/m)", "Arial Bold", 10);

            // Configure the x-axis to auto-scale with at least 75 pixels between major tick and 15
            // pixels between minor ticks. This shows more minor grid lines on the chart.
            c.xAxis().setTickDensity(75, 15);

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

            // Now we add the data to the chart
            DateTime lastTime = timeStamps[timeStamps.Length - 1];

            if (lastTime != DateTime.MinValue)
            {
                // Set up the x-axis scale. In this demo, we set the x-axis to show the last 240
                // samples, with 250ms per sample.
                c.xAxis().setDateScale(lastTime.AddSeconds(
                                           -dataRateTimer.Interval.TotalSeconds * timeStamps.Length), lastTime);

                // Set the x-axis label format
                c.xAxis().setLabelFormat("{value|hh:nn:ss}");

                // Create a line layer to plot the lines
                LineLayer layer = c.addLineLayer2();

                // The x-coordinates are the timeStamps.
                layer.setXData(timeStamps);

                // The 3 data series are used to draw 3 lines. Here we put the latest data values
                // as part of the data set name, so you can see them updated in the legend box.
                layer.addDataSet(dataSeriesA, 0xff0000, "Alpha: <*bgColor=FFCCCC*>" +
                                 c.formatValue(dataSeriesA[dataSeriesA.Length - 1], " {value|2} "));
                layer.addDataSet(dataSeriesB, 0x00cc00, "Beta: <*bgColor=CCFFCC*>" +
                                 c.formatValue(dataSeriesB[dataSeriesB.Length - 1], " {value|2} "));
                layer.addDataSet(dataSeriesC, 0x0000ff, "Gamma: <*bgColor=CCCCFF*>" +
                                 c.formatValue(dataSeriesC[dataSeriesC.Length - 1], " {value|2} "));
            }

            // Assign the chart to the WinChartViewer
            viewer.Chart = c;
        }
Esempio n. 10
0
        /// <summary>
        /// 绘制噪声数据比较分析图
        /// </summary>
        private void CreateChart(int line)
        {
            if (sRecorder == null)
            {
                return;
            }

            XYChart c = new XYChart(700, 360);

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

            ChartDirector.TextBox title = c.addTitle("噪声数据比较分析图", "Arial Bold", 13);
            title.setPos(0, 20);

            c.setPlotArea(80, 80, 580, 230, 0xffffff, -1, -1, c.dashLineColor(
                              0xaaaaaa, Chart.DotLine), -1);

            LegendBox legendBox = c.addLegend(350, 80, false, "Arial", 8);

            legendBox.setAlignment(Chart.BottomCenter);
            legendBox.setBackground(Chart.Transparent, Chart.Transparent);
            legendBox.setLineStyleKey();
            legendBox.setFontSize(8);

            c.xAxis().setIndent(true);
            c.xAxis().setTitle("噪声频率(Hz)");


            c.yAxis().setTitle("噪声幅度(%)");


            LineLayer layer1;

            ChartDirector.DataSet ds;
            double[] dataSet;
            double[] da;

            dataSet = sRecorder.Data.Amplitude.Skip(4).ToArray();
            da      = sRecorder.Data.Frequency.Skip(4).ToArray();
            switch (line)
            {
            case 0:
                layer1 = c.addLineLayer();
                ds     = layer1.addDataSet(dataSet, GetRandomColor(0), "记录仪" + sRecorder.ID);
                layer1.setLineWidth(2);
                layer1.setXData(da);
                break;

            case 1:
                layer1 = c.addSplineLayer();
                ds     = layer1.addDataSet(dataSet, GetRandomColor(0), "记录仪" + sRecorder.ID);
                layer1.setLineWidth(2);
                layer1.setXData(da);
                break;
            }

            if (eRecorder != null && sRecorder.ID != eRecorder.ID)
            {
                dataSet = eRecorder.Data.Amplitude.Skip(4).ToArray();
                da      = eRecorder.Data.Frequency.Skip(4).ToArray();
                switch (line)
                {
                case 0:
                    layer1 = c.addLineLayer();
                    ds     = layer1.addDataSet(dataSet, GetRandomColor(1), "记录仪" + eRecorder.ID);
                    layer1.setLineWidth(2);
                    layer1.setXData(da);
                    break;

                case 1:
                    layer1 = c.addSplineLayer();
                    ds     = layer1.addDataSet(dataSet, GetRandomColor(1), "记录仪" + eRecorder.ID);
                    layer1.setLineWidth(2);
                    layer1.setXData(da);
                    break;
                }
            }

            c.xAxis().setLabelStep(15);
            c.yAxis().setDateScale(0, 120);

            winChartViewer1.Chart    = c;
            winChartViewer1.ImageMap = c.getHTMLImageMap("clickable", "",
                                                         "title='噪声频率: {x}Hz, \n{dataSetName}: {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(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}'");
        }
        //
        // 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'");
        }
Esempio n. 13
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'");
        }
Esempio n. 14
0
        //
        // Draw the chart.
        //
        private void drawChart(WinChartViewer viewer)
        {
            // Get the start date and end date that are visible on the chart.
            double viewPortStartDate = viewer.getValueAtViewPort("x", viewer.ViewPortLeft);
            double viewPortEndDate   = viewer.getValueAtViewPort("x", viewer.ViewPortLeft +
                                                                 viewer.ViewPortWidth);

            // Extract the part of the data arrays that are visible.
            double[] viewPortTimeStamps  = null;
            double[] viewPortDataSeriesA = null;
            double[] viewPortDataSeriesB = null;

            if (currentIndex > 0)
            {
                // Get the array indexes that corresponds to the visible start and end dates
                int startIndex = (int)Math.Floor(Chart.bSearch2(timeStamps, 0, currentIndex, viewPortStartDate));
                int endIndex   = (int)Math.Ceiling(Chart.bSearch2(timeStamps, 0, currentIndex, viewPortEndDate));
                int noOfPoints = endIndex - startIndex + 1;

                // Extract the visible data
                viewPortTimeStamps  = (double[])Chart.arraySlice(timeStamps, startIndex, noOfPoints);
                viewPortDataSeriesA = (double[])Chart.arraySlice(dataSeriesA, startIndex, noOfPoints);
                viewPortDataSeriesB = (double[])Chart.arraySlice(dataSeriesB, startIndex, noOfPoints);
                chartTimeLimit      = timeStamps[currentIndex - 1];
            }

            //
            // At this stage, we have extracted the visible data. We can use those data to plot the chart.
            //

            //================================================================================
            // Configure overall chart appearance.
            //================================================================================

            // Create an XYChart object of size 640 x 350 pixels
            XYChart c = new XYChart(512, 288);

            // Set the position, size and colors of the plot area
            c.setPlotArea(23, 33, c.getWidth() - 41, c.getHeight() - 53, c.linearGradientColor(0, 33, 0,
                                                                                               c.getHeight() - 53, 0xf0f6ff, 0xa0c0ff), -1, Chart.Transparent, 0xffffff, 0xffffff);

            // As the data can lie outside the plotarea in a zoomed chart, we need enable clipping.
            c.setClipping();

            // Add a title to the chart using 18 pts Arial font
            c.addTitle("Gerçek Zamanlı Motor Verileri", "Arial", 18);

            // Add a legend box at (60, 28) using horizontal layout. Use 8pts Arial Bold as font. Set the
            // background and border color to Transparent and use line style legend key.
            LegendBox b = c.addLegend(60, 28, false, "Arial Bold", 10);

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

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

            // Set the y-axis tick length to 0 to disable the tick and put the labels closer to the axis.
            c.yAxis().setLabelGap(-1);
            c.yAxis().setLabelAlignment(1);
            c.yAxis().setTickLength(0);
            c.yAxis().setMargin(20);

            // Add axis title using 12pts Arial Bold Italic font
            c.yAxis().setTitle("Angular Rate", "Arial Bold", 12);

            // Configure the x-axis tick length to 1 to put the labels closer to the axis.
            c.xAxis().setTickLength(1);

            //================================================================================
            // Add data to chart
            //================================================================================

            //
            // In this example, we represent the data by lines. You may modify the code below to use other
            // representations (areas, scatter plot, etc).
            //

            // Add a line layer for the lines, using a line width of 2 pixels
            LineLayer layer = c.addLineLayer2();

            layer.setLineWidth(2);
            layer.setFastLineMode();

            // Now we add the 3 data series to a line layer, using the color red (ff0000), green (00cc00)
            // and blue (0000ff)
            layer.setXData(viewPortTimeStamps);
            layer.addDataSet(viewPortDataSeriesA, 0x00cc00, "Motor Devir");
            layer.addDataSet(viewPortDataSeriesB, 0x0000ff, "Motor Sicaklik");

            //================================================================================
            // Configure axis scale and labelling
            //================================================================================

            if (currentIndex > 0)
            {
                c.xAxis().setDateScale(viewPortStartDate, viewPortEndDate);
            }

            // For the automatic axis labels, set the minimum spacing to 75/30 pixels for the x/y axis.
            c.xAxis().setTickDensity(75);
            c.yAxis().setTickDensity(30);

            // We use "hh:nn:ss" as the axis label format.
            c.xAxis().setLabelFormat("{value|nn:ss}");

            // We make sure the tick increment must be at least 1 second.
            c.xAxis().setMinTickInc(1);

            //================================================================================
            // Output the chart
            //================================================================================

            // We need to update the track line too.
            trackLineLabel(c);

            // Set the chart image to the WinChartViewer
            viewer.Chart = c;
        }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // Data points which more unevenly spaced in time
            double[]   data0Y = { 62, 69, 53, 58, 84, 76, 49, 61, 64, 77, 79 };
            DateTime[] data0X = { new DateTime(2007,                                                                      1,  1), new DateTime(2007,                 1,  2), new DateTime(2007,
                                                                                                                                                                                          1,                    5), new DateTime(2007,   1,                7), new DateTime(2007,   1,10), new DateTime(2007, 1, 14),
                                  new DateTime(2007,                                                                      1, 17), new DateTime(2007,                 1, 18), new DateTime(2007, 1, 19),
                                  new DateTime(2007,                                                                      1, 20), new DateTime(2007,                 1, 21) };

            // Data points which are evenly spaced in a certain time range
            double[] data1Y     = { 36, 25, 28, 38, 20, 30, 27, 35, 65, 60, 40, 73, 62, 90, 75, 72 };
            DateTime data1Start = new DateTime(2007, 1, 1);
            DateTime data1End   = new DateTime(2007, 1, 16);

            // Data points which are evenly spaced in another time range, in which the spacing is
            // different from the above series
            double[] data2Y     = { 25, 15, 30, 23, 32, 55, 45 };
            DateTime data2Start = new DateTime(2007, 1, 9);
            DateTime data2End   = new DateTime(2007, 1, 21);

            // Create a XYChart object of size 600 x 400 pixels. Use a vertical gradient color from light
            // blue (99ccff) to white (ffffff) spanning the top 100 pixels as background. Set border to
            // grey (888888). Use rounded corners. Enable soft drop shadow.
            XYChart c = new XYChart(600, 400);

            c.setBackground(c.linearGradientColor(0, 0, 0, 100, 0x99ccff, 0xffffff), 0x888888);
            c.setRoundedFrame();
            c.setDropShadow();

            // Add a title using 18pt Times New Roman Bold Italic font. Set top margin to 16 pixels.
            c.addTitle("Product Line Order Backlog", "Times New Roman Bold Italic", 18).setMargin2(0, 0,
                                                                                                   16, 0);

            // Set the plotarea at (60, 80) and of 510 x 275 pixels in size. Use transparent border and
            // dark grey (444444) dotted grid lines
            PlotArea plotArea = c.setPlotArea(60, 80, 510, 275, -1, -1, Chart.Transparent,
                                              c.dashLineColor(0x444444, 0x0101), -1);

            // Add a legend box where the top-center is anchored to the horizontal center of the plot
            // area at y = 45. Use horizontal layout and 10 points Arial Bold font, and transparent
            // background and border.
            LegendBox legendBox = c.addLegend(plotArea.getLeftX() + plotArea.getWidth() / 2, 45, false,
                                              "Arial Bold", 10);

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

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

            // Set all axes to transparent
            c.xAxis().setColors(Chart.Transparent);
            c.yAxis().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("Backlog in USD millions", "Arial Bold Italic", 10);

            // Add the first data series
            LineLayer layer0 = c.addLineLayer2();

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

            // Add the second data series
            LineLayer layer1 = c.addLineLayer2();

            layer1.addDataSet(data1Y, 0x00ff00, "Atom Synthesizer").setDataSymbol(
                Chart.GlassSphere2Shape, 11);
            layer1.setXData2(data1Start, data1End);
            layer1.setLineWidth(3);

            // Add the third data series
            LineLayer layer2 = c.addLineLayer2();

            layer2.addDataSet(data2Y, 0xff6600, "Proton Cannon").setDataSymbol(Chart.GlassSphere2Shape,
                                                                               11);
            layer2.setXData2(data2Start, data2End);
            layer2.setLineWidth(3);

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "",
                                                "title='Backlog of {dataSetName} at {x|mm/dd/yyyy}: US$ {value}M'");
        }
Esempio n. 16
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 = { 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 15 pts 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.Image = c.makeImage();

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} at hour {xLabel} = {value}'");
        }
Esempio n. 17
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)
        {
            // In this example, we simply use random data for the 2 data series.
            RanSeries r = new RanSeries(127);

            double[]   data0      = r.getSeries(180, 70, -5, 5);
            double[]   data1      = r.getSeries(180, 150, -15, 15);
            DateTime[] timeStamps = r.getDateSeries(180, new DateTime(2014, 3, 1), 86400);

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

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

            // Add a title box using grey (0x555555) 20pt Arial Bold font
            c.addTitle("   Plasma Stabilizer Energy Usage", "Arial Bold", 20, 0x555555);

            // Set the plotarea at (70, 70) and of size 540 x 320 pixels, with transparent
            // background and border and light grey (0xcccccc) horizontal grid lines
            c.setPlotArea(70, 70, 540, 320, -1, -1, Chart.Transparent, 0xcccccc);

            // Add a legend box with horizontal layout above the plot area at (70, 32). Use 12pt
            // Arial Bold dark grey (0x555555) font, transparent background and border, and line
            // style legend icon.
            LegendBox b = c.addLegend(70, 32, false, "Arial Bold", 12);

            b.setFontColor(0x555555);
            b.setBackground(Chart.Transparent, Chart.Transparent);
            b.setLineStyleKey();

            // Set axis label font to 12pt Arial
            c.xAxis().setLabelStyle("Arial", 12);
            c.yAxis().setLabelStyle("Arial", 12);

            // Set the x and y axis stems to transparent, and the x-axis tick color to grey
            // (0xaaaaaa)
            c.xAxis().setColors(Chart.Transparent, Chart.TextColor, Chart.TextColor, 0xaaaaaa);
            c.yAxis().setColors(Chart.Transparent);

            // Set the major/minor tick lengths for the x-axis to 10 and 0.
            c.xAxis().setTickLength(10, 0);

            // For the automatic axis labels, set the minimum spacing to 80/40 pixels for the x/y
            // axis.
            c.xAxis().setTickDensity(80);
            c.yAxis().setTickDensity(40);

            // Use "mm/yyyy" as the x-axis label format for the first plotted month of a year, and
            // "mm" for other months
            c.xAxis().setMultiFormat(Chart.StartOfYearFilter(), "{value|mm/yyyy} ",
                                     Chart.StartOfMonthFilter(), "{value|mm}");

            // Add a title to the y axis using dark grey (0x555555) 12pt Arial Bold font
            c.yAxis().setTitle("Energy (kWh)", "Arial Bold", 14, 0x555555);

            // Add a line layer with 2-pixel line width
            LineLayer layer0 = c.addLineLayer(data0, 0xcc0000, "Power Usage");

            layer0.setXData(timeStamps);
            layer0.setLineWidth(2);

            // Add an area layer using semi-transparent blue (0x7f0044cc) as the fill color
            AreaLayer layer1 = c.addAreaLayer(data1, 0x7f0044cc, "Effective Load");

            layer1.setXData(timeStamps);
            layer1.setBorderColor(Chart.SameAsMainColor);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='[{x|mm dd, yyyy}] {value} kWh'");
        }
        //
        // Draw the chart.
        //
        private void drawChart(WPFChartViewer viewer)
        {
            // Get the start date and end date that are visible on the chart.
            DateTime viewPortStartDate = Chart.NTime(viewer.getValueAtViewPort("x", viewer.ViewPortLeft));
            DateTime viewPortEndDate   = Chart.NTime(viewer.getValueAtViewPort("x", viewer.ViewPortLeft +
                                                                               viewer.ViewPortWidth));

            // Extract the part of the data arrays that are visible.
            DateTime[] viewPortTimeStamps  = null;
            double[]   viewPortDataSeriesA = null;
            double[]   viewPortDataSeriesB = null;
            double[]   viewPortDataSeriesC = null;

            if (currentIndex > 0)
            {
                // Get the array indexes that corresponds to the visible start and end dates
                int startIndex = (int)Math.Floor(Chart.bSearch2(timeStamps, 0, currentIndex, viewPortStartDate));
                int endIndex   = (int)Math.Ceiling(Chart.bSearch2(timeStamps, 0, currentIndex, viewPortEndDate));
                int noOfPoints = endIndex - startIndex + 1;

                // Extract the visible data
                viewPortTimeStamps  = (DateTime[])Chart.arraySlice(timeStamps, startIndex, noOfPoints);
                viewPortDataSeriesA = (double[])Chart.arraySlice(dataSeriesA, startIndex, noOfPoints);
                viewPortDataSeriesB = (double[])Chart.arraySlice(dataSeriesB, startIndex, noOfPoints);
                viewPortDataSeriesC = (double[])Chart.arraySlice(dataSeriesC, startIndex, noOfPoints);
            }

            //
            // At this stage, we have extracted the visible data. We can use those data to plot the chart.
            //

            //================================================================================
            // Configure overall chart appearance.
            //================================================================================

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

            // Set the plotarea at (55, 50) with width 80 pixels less than chart width, and height 85 pixels
            // less than chart height. Use a vertical gradient from light blue (f0f6ff) to sky blue (a0c0ff)
            // as background. Set border to transparent and grid lines to white (ffffff).
            c.setPlotArea(55, 50, c.getWidth() - 85, c.getHeight() - 80, c.linearGradientColor(0, 50, 0,
                                                                                               c.getHeight() - 35, 0xf0f6ff, 0xa0c0ff), -1, Chart.Transparent, 0xffffff, 0xffffff);

            // As the data can lie outside the plotarea in a zoomed chart, we need enable clipping.
            c.setClipping();

            // Add a title to the chart using 18 pts Times New Roman Bold Italic font
            c.addTitle("  Realtime Chart with Zoom/Scroll and Track Line", "Arial", 18);

            // Add a legend box at (55, 25) using horizontal layout. Use 8pts Arial Bold as font. Set the
            // background and border color to Transparent and use line style legend key.
            LegendBox b = c.addLegend(55, 25, false, "Arial Bold", 10);

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

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

            // Add axis title using 10pts Arial Bold Italic font
            c.yAxis().setTitle("Ionic Temperature (C)", "Arial Bold", 10);

            //================================================================================
            // Add data to chart
            //================================================================================

            //
            // In this example, we represent the data by lines. You may modify the code below to use other
            // representations (areas, scatter plot, etc).
            //

            // Add a line layer for the lines, using a line width of 2 pixels
            LineLayer layer = c.addLineLayer2();

            layer.setLineWidth(2);
            layer.setFastLineMode();

            // Now we add the 3 data series to a line layer, using the color red (ff0000), green (00cc00)
            // and blue (0000ff)
            layer.setXData(viewPortTimeStamps);
            layer.addDataSet(viewPortDataSeriesA, 0xff0000, "Alpha");
            layer.addDataSet(viewPortDataSeriesB, 0x00cc00, "Beta");
            layer.addDataSet(viewPortDataSeriesC, 0x0000ff, "Gamma");

            //================================================================================
            // Configure axis scale and labelling
            //================================================================================

            if (currentIndex > 0)
            {
                c.xAxis().setDateScale(viewPortStartDate, viewPortEndDate);
            }

            // For the automatic axis labels, set the minimum spacing to 75/30 pixels for the x/y axis.
            c.xAxis().setTickDensity(75);
            c.yAxis().setTickDensity(30);

            //
            // In a zoomable chart, the time range can be from a few years to a few seconds. We can need
            // to define the date/time format the various cases.
            //

            // If all ticks are year aligned, we use "yyyy" as the label format.
            c.xAxis().setFormatCondition("align", 360 * 86400);
            c.xAxis().setLabelFormat("{value|yyyy}");

            // If all ticks are month aligned, we use "mmm yyyy" in bold font as the first label of a year,
            // and "mmm" for other labels.
            c.xAxis().setFormatCondition("align", 30 * 86400);
            c.xAxis().setMultiFormat(Chart.StartOfYearFilter(), "<*font=bold*>{value|mmm yyyy}",
                                     Chart.AllPassFilter(), "{value|mmm}");

            // If all ticks are day algined, we use "mmm dd<*br*>yyyy" in bold font as the first label of a
            // year, and "mmm dd" in bold font as the first label of a month, and "dd" for other labels.
            c.xAxis().setFormatCondition("align", 86400);
            c.xAxis().setMultiFormat(Chart.StartOfYearFilter(),
                                     "<*block,halign=left*><*font=bold*>{value|mmm dd<*br*>yyyy}", Chart.StartOfMonthFilter(),
                                     "<*font=bold*>{value|mmm dd}");
            c.xAxis().setMultiFormat2(Chart.AllPassFilter(), "{value|dd}");

            // If all ticks are hour algined, we use "hh:nn<*br*>mmm dd" in bold font as the first label of
            // the Day, and "hh:nn" for other labels.
            c.xAxis().setFormatCondition("align", 3600);
            c.xAxis().setMultiFormat(Chart.StartOfDayFilter(), "<*font=bold*>{value|hh:nn<*br*>mmm dd}",
                                     Chart.AllPassFilter(), "{value|hh:nn}");

            // If all ticks are minute algined, then we use "hh:nn" as the label format.
            c.xAxis().setFormatCondition("align", 60);
            c.xAxis().setLabelFormat("{value|hh:nn}");

            // If all other cases, we use "hh:nn:ss" as the label format.
            c.xAxis().setFormatCondition("else");
            c.xAxis().setLabelFormat("{value|hh:nn:ss}");

            // We make sure the tick increment must be at least 1 second.
            c.xAxis().setMinTickInc(1);

            //================================================================================
            // Output the chart
            //================================================================================

            // We need to update the track line too. If the mouse is moving on the chart (eg. if
            // the user drags the mouse on the chart to scroll it), the track line will be updated
            // in the MouseMovePlotArea event. Otherwise, we need to update the track line here.
            if (!viewer.IsInMouseMoveEvent)
            {
                trackLineLabel(c, (null == viewer.Chart) ? c.getPlotArea().getRightX() :
                               viewer.PlotAreaMouseX);
            }

            viewer.Chart = c;
        }
Esempio n. 19
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)
        {
            // XY points for the scatter chart
            double[] dataX0 = { 10, 15, 6, -12, 14, -8, 13, -13, 16, 12, 10.5 };
            double[] dataY0 = { 130, 150, 80, 110, -110, -105, -130, 115, -170, 125, 125 };

            double[] dataX1 = { 6, 7, -4, 3.5, 7, 8, -9, -10, -12, 11, 8 };
            double[] dataY1 = { 65, -40, -40, 45, -70, -80, 80, 10, -100, 105, 60 };

            double[] dataX2 = { -10, -12, 11, 8, 6, 12, -4, 3.5, 7, 8, -9 };
            double[] dataY2 = { 65, -80, -40, 45, -70, -80, 80, 90, -100, 105, 60 };

            // Create a XYChart object of size 600 x 300 pixels, with a light blue (ccccff)
            // background, a black border, and 1 pixel 3D border effect
            XYChart c = new XYChart(600, 480, 0xccccff, 0x000000, 1);

            // Add a title box to the chart using 16pt Arial Bold Italic font, with white text on
            // deep blue background
            c.addTitle("Four Quadrant Chart Demonstration", "Arial Bold Italic", 16, 0xffffff
                       ).setBackground(0x000080);

            // Set the plotarea at (20, 60) and of size 560 x 360 pixels, with grey (808080) border,
            // and light grey (c0c0c0) horizontal and vertical grid lines. Set 4 quadrant coloring,
            // where the colors of the quadrants alternate between lighter and deeper grey
            // (dddddd/eeeeee)
            c.setPlotArea(20, 60, 560, 360, -1, -1, 0x808080, 0xc0c0c0, 0xc0c0c0).set4QBgColor(
                0xdddddd, 0xeeeeee, 0xdddddd, 0xeeeeee);

            // Set 4 quadrant mode, with both x and y axes symetrical around the origin
            c.setAxisAtOrigin(Chart.XYAxisAtOrigin, Chart.XAxisSymmetric + Chart.YAxisSymmetric);

            // Add a legend box at (300, 460) (bottom center of the chart) with horizontal layout.
            // Use 8pt Arial Bold font.
            LegendBox legendBox = c.addLegend(300, 460, false, "Arial Bold", 8);

            legendBox.setAlignment(Chart.BottomCenter);

            // Set legend box background to light grey (dddddd) with a black border
            legendBox.setBackground(0xdddddd, 0);

            // Set left/right margin to 20 pixels and top/bottom margin to 5 pixels
            legendBox.setMargin2(20, 20, 5, 5);

            // Add a titles to axes
            c.xAxis().setTitle("Alpha Index");
            c.yAxis().setTitle("Beta Index");

            // Set axes width to 2 pixels
            c.xAxis().setWidth(2);
            c.yAxis().setWidth(2);

            // Add scatter layer, using 15 pixels red (ff33333) X shape symbols
            c.addScatterLayer(dataX0, dataY0, "Group A", Chart.Cross2Shape(), 15, 0xff3333);

            // Add scatter layer, using 15 pixels green (33ff33) 6-sided polygon symbols
            c.addScatterLayer(dataX1, dataY1, "Group B", Chart.PolygonShape(6), 15, 0x33ff33);

            // Add scatter layer, using 15 pixels blue (3333ff) triangle symbols
            c.addScatterLayer(dataX2, dataY2, "Group C", Chart.TriangleSymbol, 15, 0x3333ff);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='[{dataSetName}] Alpha = {x}, Beta = {value}'");
        }
Esempio n. 20
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 line chart
            double[] data0  = { 42, 49, 33, 38, 64, 56, 29, 41, 44, 57, 59, 42 };
            double[] data1  = { 65, 75, 47, 34, 42, 49, 73, 62, 90, 69, 66, 78 };
            double[] data2  = { 36, 28, 25, 28, 38, 20, 22, 30, 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 400 pixels
            XYChart c = new XYChart(600, 400);

            // Add a title to the chart using 18 pts Times Bold Italic font
            ChartDirector.TextBox title = c.addTitle("Product Line Global Revenue",
                                                     "Times New Roman Bold Italic", 18);

            // Tentatively set the plotarea at (50, 55) and of (chart_width - 100) x
            // (chart_height - 120) pixels in size. Use a vertical gradient color
            // from sky blue (aaccff) t0 light blue (f9f9ff) as background. Set both
            // horizontal and vertical grid lines to dotted semi-transprent black
            // (aa000000).
            PlotArea plotArea = c.setPlotArea(50, 55, c.getWidth() - 100,
                                              c.getHeight() - 120, c.linearGradientColor(0, 55, 0, 55 +
                                                                                         c.getHeight() - 120, 0xaaccff, 0xf9fcff), -1, -1, c.dashLineColor(
                                                  unchecked ((int)0xaa000000), Chart.DotLine), -1);

            // Add a legend box and anchored the top center at the horizontal center
            // of the chart, just under the title. Use 10pts Arial Bold as font, with
            // 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);

            // Set y-axis title using 10 points Arial Bold Italic font, label style
            // to 8 points Arial Bold, and axis color to transparent
            c.yAxis().setTitle("Revenue (USD millions)", "Arial Bold Italic", 10);
            c.yAxis().setLabelStyle("Arial Bold", 8);
            c.yAxis().setColors(Chart.Transparent);

            // 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);

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

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

            // Add the three data sets to the line layer, using circles, diamands and
            // X shapes as symbols
            layer.addDataSet(data0, 0xff0000, "Quantum Computer").setDataSymbol(
                Chart.CircleSymbol, 9);
            layer.addDataSet(data1, 0x00ff00, "Atom Synthesizer").setDataSymbol(
                Chart.DiamondSymbol, 11);
            layer.addDataSet(data2, 0xff6600, "Proton Cannon").setDataSymbol(
                Chart.Cross2Shape(), 11);

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

            // Convert the labels on the x-axis to a CDMLTable
            CDMLTable table = c.xAxis().makeLabelTable();

            // Set the default top/bottom margins of the cells to 3 pixels
            table.getStyle().setMargin2(0, 0, 3, 3);

            // Use Arial Bold as the font for the first row
            table.getRowStyle(0).setFontStyle("Arial Bold");

            //
            // We can add more information to the table. In this sample code, we add
            // the data series and the legend icons to the table.
            //

            // Add 3 more rows to the table. Set the background of the 1st and 3rd
            // rows to light grey (eeeeee).
            table.appendRow().setBackground(0xeeeeee, Chart.LineColor);
            table.appendRow();
            table.appendRow().setBackground(0xeeeeee, Chart.LineColor);

            // Put the values of the 3 data series to the cells in the 3 rows
            for (int i = 0; i < data0.Length; ++i)
            {
                table.setText(i, 1, (data0[i]).ToString());
                table.setText(i, 2, (data1[i]).ToString());
                table.setText(i, 3, (data2[i]).ToString());
            }

            // Insert a column on the left for the legend icons. Use 5 pixels
            // left/right margins and 3 pixels top/bottom margins for the cells in
            // this column.
            table.insertCol(0).setMargin2(5, 5, 3, 3);

            // The top cell is set to transparent, so it is invisible
            table.getCell(0, 0).setBackground(Chart.Transparent, Chart.Transparent);

            // The other 3 cells are set to the legend icons of the 3 data series
            table.setText(0, 1, layer.getLegendIcon(0));
            table.setText(0, 2, layer.getLegendIcon(1));
            table.setText(0, 3, layer.getLegendIcon(2));

            // Layout legend box first, so we can get its size
            c.layoutLegend();

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

            // After determining the exact plot area position, we may adjust the
            // legend box and the title positions so that they are centered relative
            // to the plot area (instead of the chart)
            legendBox.setPos(plotArea.getLeftX() + (plotArea.getWidth() -
                                                    legendBox.getWidth()) / 2, legendBox.getTopY());
            title.setPos(plotArea.getLeftX() + (plotArea.getWidth() - title.getWidth(
                                                    )) / 2, title.getTopY());

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Revenue of {dataSetName} in {xLabel}: US$ {value}M'");
        }
        //
        // 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();
        }
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WPFChartViewer viewer, int chartIndex)
        {
            // The data for the bar chart
            double[] data0 = { 100, 125, 245, 147, 67 };
            double[] data1 = { 85, 156, 179, 211, 123 };
            double[] data2 = { 97, 87, 56, 267, 157 };

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

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

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

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

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

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

            legendBox.setAlignment(Chart.TopRight);

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

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

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

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

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

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

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

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

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

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

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} revenue on {xLabel}: US${value}K ({percent}%)'");
        }
Esempio n. 23
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 bar chart
            double[] data0 = { 100, 115, 165, 107, 67 };
            double[] data1 = { 85, 106, 129, 161, 123 };
            double[] data2 = { 67, 87, 86, 167, 157 };

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

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

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

            // Set the plotarea at (70, 20) and of size 400 x 300 pixels, with transparent
            // background and border and light grey (0xcccccc) horizontal grid lines
            c.setPlotArea(70, 20, 400, 300, Chart.Transparent, -1, Chart.Transparent, 0xcccccc);

            // Add a legend box at (480, 20) using vertical layout and 12pt Arial font. Set
            // background and border to transparent and key icon border to the same as the fill
            // color.
            LegendBox b = c.addLegend(480, 20, true, "Arial", 12);

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

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

            // Add a stacked bar layer
            BarLayer layer = c.addBarLayer2(Chart.Stack);

            // Add the three data sets to the bar layer
            layer.addDataSet(data0, 0xaaccee, "Server # 1");
            layer.addDataSet(data1, 0xbbdd88, "Server # 2");
            layer.addDataSet(data2, 0xeeaa66, "Server # 3");

            // Set the bar border to transparent
            layer.setBorderColor(Chart.Transparent);

            // Enable labelling for the entire bar and use 12pt Arial font
            layer.setAggregateLabelStyle("Arial", 12);

            // Enable labelling for the bar segments and use 12pt Arial font with center alignment
            layer.setDataLabelStyle("Arial", 10).setAlignment(Chart.Center);

            // For a vertical stacked bar with positive data, the first data set is at the bottom.
            // For the legend box, by default, the first entry at the top. We can reverse the legend
            // order to make the legend box consistent with the stacked bar.
            layer.setLegendOrder(Chart.ReverseLegend);

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

            // For the automatic y-axis labels, set the minimum spacing to 40 pixels.
            c.yAxis().setTickDensity(40);

            // Add a title to the y axis using dark grey (0x555555) 14pt Arial Bold font
            c.yAxis().setTitle("Y-Axis Title Placeholder", "Arial Bold", 14, 0x555555);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} on {xLabel}: {value} MBytes/hour'");
        }
Esempio n. 24
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 names of the tasks
            string[] labels = { "Market Research",      "Define Specifications",
                                "Overall Archiecture",  "Project Planning",     "Detail Design",
                                "Software Development", "Test Plan",            "Testing and QA",
                                "User Documentation" };

            // the planned start dates and end dates for the tasks
            DateTime[] startDate = { new DateTime(2004,                                           8, 16), 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, 25), new DateTime(2004,                11, 1), new DateTime(2004, 11, 8) };
            DateTime[] endDate = { new DateTime(2004,                                         8, 30), 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,                                                 11,  8), new DateTime(2004,                11,22), new DateTime(2004, 11, 22) }

            ;

            // the actual start dates and end dates for the tasks up to now
            DateTime[] actualStartDate = { new DateTime(2004,                 8, 16), new DateTime(
                                               2004,                          8, 27), new DateTime(2004,9, 9), new DateTime(2004, 9, 18),
                                           new DateTime(2004,                 9, 22) };
            DateTime[] actualEndDate = { new DateTime(2004,                                             8, 27), new DateTime(2004,
                                                                                                                             9,                    9), new DateTime(2004,   9,27), new DateTime(2004, 10, 2),
                                         new DateTime(2004,                                            10, 8) };

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

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

            // 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);

            // Add a red (ff0000) dash line to represent the current day
            c.yAxis().addMark(Chart.CTime(new DateTime(2004, 10, 8)),
                              c.dashLineColor(0xff0000, Chart.DashLine));

            // 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);

            // Use blue (0000aa) as the color for the planned schedule
            int plannedColor = 0x0000aa;

            // Use a red hash pattern as the color for the actual dates. The pattern
            // is created as a 4 x 4 bitmap defined in memory as an array of colors.
            int actualColor = c.patternColor(new int[] { 0xffffff, 0xffffff, 0xffffff,
                                                         0xff0000, 0xffffff, 0xffffff, 0xff0000, 0xffffff, 0xffffff, 0xff0000,
                                                         0xffffff, 0xffffff, 0xff0000, 0xffffff, 0xffffff, 0xffffff }, 4);

            // Add a box whisker layer to represent the actual dates. We add the
            // actual dates layer first, so it will be the top layer.
            BoxWhiskerLayer actualLayer = c.addBoxLayer(Chart.CTime(actualStartDate),
                                                        Chart.CTime(actualEndDate), actualColor, "Actual");

            // Set the bar height to 8 pixels so they will not block the bottom bar
            actualLayer.setDataWidth(8);

            // Add a box-whisker layer to represent the planned schedule date
            c.addBoxLayer(Chart.CTime(startDate), Chart.CTime(endDate), plannedColor,
                          "Planned").setBorderColor(Chart.SameAsMainColor);

            // Add a legend box on the top right corner (595, 60) of the plot area
            // with 8 pt Arial Bold font. Use a semi-transparent grey (80808080)
            // background.
            LegendBox b = c.addLegend(595, 60, false, "Arial Bold", 8);

            b.setAlignment(Chart.TopRight);
            b.setBackground(unchecked ((int)0x80808080), -1, 2);

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{xLabel} ({dataSetName}): {top|mmm dd, yyyy} to " +
                                                "{bottom|mmm dd, yyyy}'");
        }
Esempio n. 25
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The data for the chart
            double[] data0   = { 90, 25, 40, 55, 68, 44, 79, 85, 50 };
            double[] angles0 = { 15, 60, 110, 180, 230, 260, 260, 310, 340 };

            double[] data1   = { 80, 91, 66, 80, 92, 87 };
            double[] angles1 = { 40, 65, 88, 110, 150, 200 };

            // Create a PolarChart object of size 460 x 500 pixels, with a grey (e0e0e0) background and 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 15pt Arial Bold Italic font. Use a
            // wood pattern as the title background.
            c.addTitle("Polar Line Chart Demo", "Arial Bold Italic", 15).setBackground(c.patternColor(
                                                                                           Url.Content("~/Content/wood.png")));

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

            // Set the grid style to circular grid, with grids below the chart layers
            c.setGridStyle(false, false);

            // Add a legend box at top-center of plot area (230, 35) using horizontal layout. Use 10pt
            // Arial Bold font, with 1 pixel 3D border effect.
            LegendBox b = c.addLegend(230, 35, false, "Arial Bold", 9);

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

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

            // Add a blue (0xff) line layer to the chart using (data0, angle0)
            PolarLineLayer layer0 = c.addLineLayer(data0, 0x0000ff, "Close Loop Line");

            layer0.setAngles(angles0);

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

            // Use 11 pixel triangle symbols for the data points
            layer0.setDataSymbol(Chart.TriangleSymbol, 11);

            // Enable data label and set its format
            layer0.setDataLabelFormat("({value},{angle})");

            // Set the data label text box with light blue (0x9999ff) backgruond color and 1 pixel 3D
            // border effect
            layer0.setDataLabelStyle().setBackground(0x9999ff, Chart.Transparent, 1);

            // Add a red (0xff0000) line layer to the chart using (data1, angle1)
            PolarLineLayer layer1 = c.addLineLayer(data1, 0xff0000, "Open Loop Line");

            layer1.setAngles(angles1);

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

            // Use 11 pixel diamond symbols for the data points
            layer1.setDataSymbol(Chart.DiamondSymbol, 11);

            // Set the line to open loop
            layer1.setCloseLoop(false);

            // Enable data label and set its format
            layer1.setDataLabelFormat("({value},{angle})");

            // Set the data label text box with light red (0xff9999) backgruond color and 1 pixel 3D
            // border effect
            layer1.setDataLabelStyle().setBackground(0xff9999, Chart.Transparent, 1);

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "", "title='[{dataSetName}] ({radius}, {angle})'");
        }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The data for the bar chart
            double[] data0 = { 44, 55, 100 };
            double[] data1 = { 97, 87, 167 };
            double[] data2 = { 156, 78, 147 };
            double[] data3 = { 125, 118, 211 };

            // The labels for the bar chart. The labels contains embedded images as icons.
            string[] labels = { "<*img=service.png*><*br*>Service", "<*img=software.png*><*br*>Software",
                                "<*img=computer.png*><*br*>Hardware" };

            // Create a XYChart object of size 600 x 350 pixels, using 0xe0e0ff as the background color,
            // 0xccccff as the border color, with 1 pixel 3D border effect.
            XYChart c = new XYChart(600, 350, 0xe0e0ff, 0xccccff, 1);

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

            // Add a title to the chart using 14 points Times Bold Itatic font and light blue (0x9999ff)
            // as the background color
            c.addTitle("Business Results 2001 vs 2002", "Times New Roman Bold Italic", 14).setBackground(
                0x9999ff);

            // Set the plotarea at (60, 45) and of size 500 x 210 pixels, using white (0xffffff) as the
            // background
            c.setPlotArea(60, 45, 500, 210, 0xffffff);

            // Swap the x and y axes to create a horizontal bar chart
            c.swapXY();

            // Add a title to the y axis using 11 pt Times Bold Italic as font
            c.yAxis().setTitle("Revenue (millions)", "Times New Roman Bold Italic", 11);

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

            // Disable x-axis ticks by setting the tick length to 0
            c.xAxis().setTickLength(0);

            // Add a stacked bar layer to the chart
            BarLayer layer = c.addBarLayer2(Chart.Stack);

            // Add the first two data sets to the chart as a stacked bar group
            layer.addDataGroup("2001");
            layer.addDataSet(data0, 0xaaaaff, "Local");
            layer.addDataSet(data1, 0x6666ff, "International");

            // Add the remaining data sets to the chart as another stacked bar group
            layer.addDataGroup("2002");
            layer.addDataSet(data2, 0xffaaaa, "Local");
            layer.addDataSet(data3, 0xff6666, "International");

            // Set the sub-bar gap to 0, so there is no gap between stacked bars with a group
            layer.setBarGap(0.2, 0);

            // Set the bar border to transparent
            layer.setBorderColor(Chart.Transparent);

            // Set the aggregate label format
            layer.setAggregateLabelFormat("Year {dataGroupName}\n{value} millions");

            // Set the aggregate label font to 8 point Arial Bold Italic
            layer.setAggregateLabelStyle("Arial Bold Italic", 8);

            // Reverse 20% space at the right during auto-scaling to allow space for the aggregate bar
            // labels
            c.yAxis().setAutoScale(0.2);

            // Add a legend box at (310, 300) using TopCenter alignment, with 2 column grid layout, and
            // use 8pt Arial Bold Italic as font
            LegendBox legendBox = c.addLegend2(310, 300, 2, "Arial Bold Italic", 8);

            legendBox.setAlignment(Chart.TopCenter);

            // Set the format of the text displayed in the legend box
            legendBox.setText("Year {dataGroupName} {dataSetName} Revenue");

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

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "",
                                                "title='Year {dataGroupName} {dataSetName} {xLabel} Revenue: {value} millions'");
        }
Esempio n. 27
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, we simply use random data for the 3 data series.
            RanSeries r = new RanSeries(129);

            double[]   data0      = r.getSeries(100, 100, -15, 15);
            double[]   data1      = r.getSeries(100, 160, -15, 15);
            double[]   data2      = r.getSeries(100, 220, -15, 15);
            DateTime[] timeStamps = r.getDateSeries(100, new DateTime(2014, 1, 1), 86400);

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

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

            // Add a title box using grey (0x555555) 20pt Arial font
            c.addTitle("    Multi-Line Chart Demonstration", "Arial", 20, 0x555555);

            // Set the plotarea at (70, 70) and of size 500 x 300 pixels, with transparent
            // background and border and light grey (0xcccccc) horizontal grid lines
            c.setPlotArea(70, 70, 500, 300, Chart.Transparent, -1, Chart.Transparent, 0xcccccc);

            // Add a legend box with horizontal layout above the plot area at (70, 35). Use 12pt
            // Arial font, transparent background and border, and line style legend icon.
            LegendBox b = c.addLegend(70, 35, false, "Arial", 12);

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

            // Set axis label font to 12pt Arial
            c.xAxis().setLabelStyle("Arial", 12);
            c.yAxis().setLabelStyle("Arial", 12);

            // Set the x and y axis stems to transparent, and the x-axis tick color to grey
            // (0xaaaaaa)
            c.xAxis().setColors(Chart.Transparent, Chart.TextColor, Chart.TextColor, 0xaaaaaa);
            c.yAxis().setColors(Chart.Transparent);

            // Set the major/minor tick lengths for the x-axis to 10 and 0.
            c.xAxis().setTickLength(10, 0);

            // For the automatic axis labels, set the minimum spacing to 80/40 pixels for the x/y
            // axis.
            c.xAxis().setTickDensity(80);
            c.yAxis().setTickDensity(40);

            // Add a title to the y axis using dark grey (0x555555) 14pt Arial font
            c.yAxis().setTitle("Y-Axis Title Placeholder", "Arial", 14, 0x555555);

            // Add a line layer to the chart with 3-pixel line width
            LineLayer layer = c.addLineLayer2();

            layer.setLineWidth(3);

            // Add 3 data series to the line layer
            layer.addDataSet(data0, 0x5588cc, "Alpha");
            layer.addDataSet(data1, 0xee9944, "Beta");
            layer.addDataSet(data2, 0x99bb55, "Gamma");

            // The x-coordinates for the line layer
            layer.setXData(timeStamps);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='[{x|mm/dd/yyyy}] {dataSetName}: {value}'");
        }
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, int chartIndex)
        {
            // The data for the area chart
            double[] data0 = { 42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56,
                               60, 70, 76, 63, 67, 75, 64, 51 };
            double[] data1 = { 50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58,
                               59, 73, 77, 84, 82, 80, 84, 98 };
            double[] data2 = { 87, 89, 85, 66, 53, 39, 24, 21, 37, 56, 37, 23, 21, 33, 13, 17, 14,
                               23, 16, 25, 29, 30, 45, 47, 46 };

            // The timestamps on the x-axis
            DateTime[] labels = { new DateTime(1996,                                                                                                                                                             1, 1), new DateTime(1996,                 4, 1), new DateTime(
                                      1996,                                                                                                                                                                      7, 1), new DateTime(1996,                10, 1), new DateTime(1997,                 1, 1), new DateTime(1997,
                                                                                                                                                                                                                                                                                                                         4,                                                                                         1), new DateTime(1997,  7,                1), new DateTime(1997, 10,                1),new DateTime(1998,1, 1
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ), new DateTime(1998,  4,                1), new DateTime(1998,  7,                1), new DateTime(1998, 10,1),
                                  new DateTime(1999,                                                                                                                                                             1, 1), new DateTime(1999,                 4, 1), new DateTime(1999,                 7, 1),
                                  new DateTime(1999,                                                                                                                                                            10, 1), new DateTime(2000,                 1, 1), new DateTime(2000,                 4, 1),
                                  new DateTime(2000,                                                                                                                                                             7, 1), new DateTime(2000,                10, 1), new DateTime(2001,                 1, 1),
                                  new DateTime(2001,                                                                                                                                                             4, 1), new DateTime(2001,                 7, 1), new DateTime(2001,                10, 1),
                                  new DateTime(2002,                                                                                                                                                             1, 1) };

            // Create a XYChart object of size 500 x 280 pixels, using 0xffffcc as background color,
            // with a black border, and 1 pixel 3D border effect
            XYChart c = new XYChart(500, 280, 0xffffcc, 0, 1);

            // Set the plotarea at (50, 45) and of size 320 x 200 pixels with white background.
            // Enable horizontal and vertical grid lines using the grey (0xc0c0c0) color.
            c.setPlotArea(50, 45, 320, 200, 0xffffff).setGridColor(0xc0c0c0, 0xc0c0c0);

            // Add a legend box at (370, 45) using vertical layout and 8 points Arial Bold font.
            LegendBox legendBox = c.addLegend(370, 45, true, "Arial Bold", 8);

            // 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);

            // Add a title to the chart using 14 points Times Bold Itatic font and white font color,
            // and 0x804020 as the background color
            c.addTitle("Quarterly Product Sales", "Times New Roman Bold Italic", 14, 0xffffff
                       ).setBackground(0x804020);

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

            // Set multi-style axis label formatting. Start of year labels are displayed as yyyy.
            // For other labels, just show minor tick.
            c.xAxis().setMultiFormat(Chart.StartOfYearFilter(), "{value|yyyy}", Chart.AllPassFilter(
                                         ), "-");

            // Add a percentage area layer to the chart
            AreaLayer layer = c.addAreaLayer2(Chart.Percentage);

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

            // 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);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} sales at {xLabel|yyyy} Q{=({xLabel|m}+2)/3|0}: US${value}K " +
                                                "({percent}%)'");
        }
Esempio n. 29
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // 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.Image = c.makeWebImage(Chart.PNG);

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "", "title='{x|mmm dd, yyyy}: {value}%'");
        }
        public void createChart(WinChartViewer viewer, DataTable dt_chart, string title)
        {
            try
            {
                Chart.setLicenseCode("DEVP-2LSU-B4LX-YCTY-2DF2-77EE");

                double[] data   = new double[dt_chart.Rows.Count];
                string[] labels = new string[dt_chart.Rows.Count];

                for (int i = 0; i < dt_chart.Rows.Count; i++)
                {
                    data[i]   = Convert.ToDouble(dt_chart.Rows[i]["RATE"].ToString());
                    labels[i] = dt_chart.Rows[i]["reason_tail_nm"].ToString();
                }



                // The colors to use for the sectors
                int[] colors = { 0x66aaee, 0xeebb22, 0xbbbbbb, 0x8844ff, 0xdd2222,
                                 0x009900, 0xff8040, 0xaa0023 };

                // Create a PieChart object of size 600 x 320 pixels. Use a vertical
                // gradient color from light blue (99ccff) to white (ffffff) spanning the
                // top 100 pixels as background. Set border to grey (888888). Use rounded
                // corners. Enable soft drop shadow.
                PieChart c = new PieChart(690, 310);
                c.setBackground(c.linearGradientColor(0, 0, 0, 100, 0x99ccff, 0xffffff),
                                0x888888);
                c.setRoundedFrame();
                c.setDropShadow();

                // Add a title using 18 pts Times New Roman Bold Italic font. Add 16
                // pixels top margin to the title.
                c.addTitle(title,
                           "Times New Roman Bold Italic", 18).setMargin2(0, 0, 1, 0);

                // Set the center of the pie at (160, 165) and the radius to 110 pixels
                c.setPieSize(230, 170, 140);

                // 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);

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

                // Show only the sector number as the sector label
                c.setLabelFormat("{percent} % ");

                // Set the sector label style to Arial Bold 10pt, with a dark grey
                // (444444) border
                c.setLabelStyle("Arial Bold", 10).setBackground(Chart.Transparent,
                                                                0x444444);

                // Add a legend box, with the center of the left side anchored at (330,
                // 175), and using 10 pts Arial Bold Italic font
                LegendBox b = new LegendBox();
                b = c.addLegend(470, 150, true, "Arial Bold Italic", 12);
                b.setAlignment(Chart.Left);

                // Set the legend box border to dark grey (444444), and with rounded
                // conerns
                b.setBackground(Chart.Transparent, 0x444444);
                b.setRoundedCorners();

                // Set the legend box margin to 16 pixels, and the extra line spacing
                // between the legend entries as 5 pixels
                b.setMargin(16);
                b.setKeySpacing(0, 5);

                // Set the legend box icon to have no border (border color same as fill
                // color)
                b.setKeyBorder(Chart.SameAsMainColor);

                // Set the legend text to show the sector number, followed by a 120
                // pixels wide block showing the sector label, and a 40 pixels wide block
                // showing the percentage
                b.setText(
                    "<*block,valign=top*> <*advanceTo=22*>" +
                    "<*block,width=140*>{label}<*/*>");

                // Output the chart
                viewer.Chart = c;

                //include tool tip for the chart
                viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                    "title='{label}: {percent} % '");
            }
            catch
            {
            }
            // The data for the pie chart
            //dt_chart = this.select_chart_1();
        }