/// <summary>
        ///
        /// </summary>
        /// <returns>
        ///		An image map that can be added to the main image map
        ///		so that the toolbar buttons work.
        /// </returns>
        private void addToolbar(WebChartViewer viewer)
        {
            StringBuilder imageMapText;
            TextBox       currIcon;
            int           y;

            imageMapText = new StringBuilder();

            _chart.setSearchPath(_toolbarImagePath);

            //Start 5 pixels from the top of the chart, or the title
            y = _headerHeight + TOP_MARGIN + 5;

            currIcon = _chart.addText(5, y, "<*img=Refresh.jpg*>");
            imageMapText.Append("<area " + currIcon.getImageCoor());
            imageMapText.Append(" href=\"" + viewer.GetPostBackURL(TOOLBAR_KEY_REFRESH) + "\"");
            imageMapText.Append(" title=\"Refresh\" />");

            y       += 35;
            currIcon = _chart.addText(8, y, "<*img=ZoomIn.gif*>");
            imageMapText.Append("<area " + currIcon.getImageCoor());
            imageMapText.Append(" href=\"" + viewer.GetPostBackURL(TOOLBAR_KEY_ZOOM_IN) + "\"");
            imageMapText.Append(" title=\"Zoom In\" />");

            y       += 25;
            currIcon = _chart.addText(8, y, "<*img=ZoomOut.gif*>");
            imageMapText.Append("<area " + currIcon.getImageCoor());
            imageMapText.Append(" href=\"" + viewer.GetPostBackURL(TOOLBAR_KEY_ZOOM_OUT) + "\"");
            imageMapText.Append(" title=\"Zoom Out\" />");

            y       += 25;
            currIcon = _chart.addText(8, y, "<*img=ScrollLeft.gif*>");
            imageMapText.Append("<area " + currIcon.getImageCoor());
            imageMapText.Append(" href=\"" + viewer.GetPostBackURL(TOOLBAR_KEY_SCROLL_LEFT) + "\"");
            imageMapText.Append(" title=\"Scroll Left\" />");

            y       += 25;
            currIcon = _chart.addText(8, y, "<*img=ScrollRight.gif*>");
            imageMapText.Append("<area " + currIcon.getImageCoor());
            imageMapText.Append(" href=\"" + viewer.GetPostBackURL(TOOLBAR_KEY_SCROLL_RIGHT) + "\"");
            imageMapText.Append(" title=\"Scroll Right\" />");

            y       += 25;
            currIcon = _chart.addText(8, y, "<*img=Save.gif*>");
            imageMapText.Append("<area " + currIcon.getImageCoor());
            imageMapText.Append(" href=\"" + viewer.GetPostBackURL(TOOLBAR_KEY_SAVE) + "\"");
            imageMapText.Append(" title=\"Save\" />");

            imageMapAreas.Append(imageMapText.ToString());
        }
Exemple #2
0
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, int chartIndex)
        {
            // The data for the chart
            double[] data = { 30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89, 60, 55, 53, 35,
                              50, 66, 56, 48, 52, 65, 62 };

            // The labels for the chart
            string[] labels = { "0",  "1",  "2",  "3",  "4",  "5",  "6",  "7",  "8",  "9",  "10", "11", "12",
                                "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24" };

            // Create a XYChart object of size 500 x 300 pixels, with a pale yellow (0xffffc0)
            // background, a black border, and 1 pixel 3D border effect
            XYChart c = new XYChart(500, 300, 0xffffc0, 0x000000, 1);

            // Set the plotarea at (55, 50) and of size 420 x 205 pixels, with white background.
            // Turn on both horizontal and vertical grid lines with light grey color (0xc0c0c0)
            c.setPlotArea(55, 50, 420, 205, 0xffffff).setGridColor(0xc0c0c0, 0xc0c0c0);

            // Add a legend box at (55, 25) (top of the chart) with horizontal layout. Use 8pt Arial
            // font. Set the background and border color to Transparent.
            LegendBox legendBox = c.addLegend(55, 25, false, "", 8);

            legendBox.setBackground(Chart.Transparent);

            // Add keys to the legend box to explain the color zones
            legendBox.addKey("Normal Zone", unchecked ((int)0x8033ff33));
            legendBox.addKey("Alert Zone", unchecked ((int)0x80ff3333));

            // Add a title box to the chart using 13pt Arial Bold Italic font. The title is in CDML
            // and includes embedded images for highlight. The text is white (0xffffff) on a black
            // background, with a 1 pixel 3D border.
            c.addTitle(
                "<*block,valign=absmiddle*><*img=@/images/star.png*><*img=@/images/star.png*> Y " +
                "Zone Color Demo <*img=@/images/star.png*><*img=@/images/star.png*><*/*>",
                "Arial Bold Italic", 13, 0xffffff).setBackground(0x000000, -1, 1);

            // Add a title to the y axis
            c.yAxis().setTitle("Energy Concentration (KJ per liter)");

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

            // Display 1 out of 3 labels on the x-axis.
            c.xAxis().setLabelStep(3);

            // Add a title to the x axis using CDML
            c.xAxis().setTitle(
                "<*block,valign=absmiddle*><*img=@/images/clock.png*>  Elapsed Time (hour)<*/*>");

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

            // Add an area layer to the chart. The area is using a y zone color, where the color is
            // semi-transparent green below 60, and semi-transparent red above 60.
            c.addAreaLayer(data, c.yZoneColor(60, unchecked ((int)0x8033ff33),
                                              unchecked ((int)0x80ff3333)));

            // Add a custom CDML text at the bottom right of the plot area as the logo
            c.addText(475, 255,
                      "<*block,valign=absmiddle*><*img=@/images/small_molecule.png*> <*block*>" +
                      "<*font=Times New Roman Bold Italic,size=10,color=804040*>Molecular\nEngineering" +
                      "<*/*>").setAlignment(Chart.BottomRight);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Hour {xLabel}: {value} KJ/liter'");
        }
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WPFChartViewer viewer, int chartIndex)
        {
            //
            // Sample data for the CandleStick chart.
            //
            double[] highData = { 2043, 2039, 2076, 2064, 2048, 2058, 2070, 2033, 2027, 2029, 2071,
                                  2085, 2034, 2031, 2056, 2128, 2180, 2183, 2192, 2213, 2230, 2281, 2272 };

            double[] lowData = { 1931, 1921, 1985, 2028, 1986, 1994, 1999, 1958, 1943, 1944, 1962,
                                 2011, 1975, 1962, 1928, 2059, 2112, 2103, 2151, 2127, 2123, 2152, 2212 };

            double[] openData = { 2000, 1957, 1993, 2037, 2018, 2021, 2045, 2009, 1959, 1985, 2008,
                                  2048, 2006, 2010, 1971, 2080, 2116, 2137, 2170, 2172, 2171, 2191, 2240 };

            double[] closeData = { 1950, 1991, 2026, 2029, 2004, 2053, 2011, 1962, 1987, 2019, 2040,
                                   2016, 1996, 1985, 2006, 2113, 2142, 2167, 2158, 2201, 2188, 2231, 2242 };

            // The labels for the CandleStick chart
            string[] labels = { "Mon 1",  "Tue 2",  "Wed 3",  "Thu 4",  "Fri 5",  "Mon 8",  "Tue 9",
                                "Wed 10", "Thu 11", "Fri 12", "Mon 15", "Tue 16", "Wed 17", "Thu 18","Fri 19",
                                "Mon 22", "Tue 23", "Wed 24", "Thu 25", "Fri 26", "Mon 29", "Tue 30","Wed 31" };

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

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

            // Add a title to the chart
            c.addTitle("Universal Stock Index on Jan 2001");

            // Add a custom text at (50, 25) (the upper left corner of the plotarea). Use 12pt Arial
            // Bold/blue (4040c0) as the font.
            c.addText(50, 25, "(c) Global XYZ ABC Company", "Arial Bold", 12, 0x4040c0);

            // Add a title to the x axis
            c.xAxis().setTitle("Jan 2001");

            // Set the labels on the x axis. Rotate the labels by 45 degrees.
            c.xAxis().setLabels(labels).setFontAngle(45);

            // Add a title to the y axis
            c.yAxis().setTitle("Universal Stock Index");

            // Draw the y axis on the right hand side of the plot area
            c.setYAxisOnRight(true);

            // Add a CandleStick layer to the chart using green (00ff00) for up candles and red
            // (ff0000) for down candles
            CandleStickLayer layer = c.addCandleStickLayer(highData, lowData, openData, closeData,
                                                           0x00ff00, 0xff0000);

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

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{xLabel} Jan 2001\nHigh:{high}\nOpen:{open}\nClose:{close}\nLow:{low}'");
        }
Exemple #4
0
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WPFChartViewer viewer, int chartIndex)
        {
            // The data for the upper and lower bounding lines
            double[] upperY = { 60, 60, 100, 100, 60, 60 };
            double[] lowerY = { 40, 40, 80, 80, 40, 40 };
            double[] zoneX  = { 0, 2.5, 3.5, 5.5, 6.5, 10 };

            // The data for the spline curve
            double[] curveY = { 50, 44, 54, 48, 58, 50, 90, 85, 104, 82, 96, 90, 74, 52, 35, 58, 46,
                                54, 48, 52, 50 };
            double[] curveX = { 0,   0.5,   1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8,
                                8.5,   9, 9.5, 10 };

            // Create a XYChart object of size 600 x 300 pixels, with a light grey (cccccc)
            // background, black border, and 1 pixel 3D border effect.
            XYChart c = new XYChart(600, 300, 0xcccccc, 0x000000, 1);

            // Set the plotarea at (55, 58) and of size 520 x 195 pixels, with white background.
            // Turn on both horizontal and vertical grid lines with light grey color (cccccc)
            c.setPlotArea(55, 58, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);

            // Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9pt Arial
            // Bold font. Set the background and border color to Transparent.
            c.addLegend(55, 32, false, "Arial Bold", 9).setBackground(Chart.Transparent);

            // Add a title box to the chart using 15pt Times Bold Italic font. The title is in CDML
            // and includes embedded images for highlight. The text is white (ffffff) on a black
            // background, with a 1 pixel 3D border.
            c.addTitle(
                "<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Performance Enhancer " +
                "<*img=star.png*><*img=star.png*><*/*>", "Times New Roman Bold Italic", 15, 0xffffff
                ).setBackground(0x000000, -1, 1);

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

            // Add a title to the x axis using CMDL
            c.xAxis().setTitle(
                "<*block,valign=absmiddle*><*img=clock.png*>  Elapsed Time (hour)<*/*>");

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

            // Add a purple (800080) spline layer to the chart with a line width of 2 pixels
            SplineLayer splineLayer = c.addSplineLayer(curveY, 0x800080, "Molecular Temperature");

            splineLayer.setXData(curveX);
            splineLayer.setLineWidth(2);

            // Add a line layer to the chart with two dark green (338033) data sets, and a line
            // width of 2 pixels
            LineLayer lineLayer = c.addLineLayer2();

            lineLayer.addDataSet(upperY, 0x338033, "Target Zone");
            lineLayer.addDataSet(lowerY, 0x338033);
            lineLayer.setXData(zoneX);
            lineLayer.setLineWidth(2);

            // Color the zone between the upper zone line and lower zone line as semi-transparent
            // light green (8099ff99)
            c.addInterLineLayer(lineLayer.getLine(0), lineLayer.getLine(1),
                                unchecked ((int)0x8099ff99), unchecked ((int)0x8099ff99));

            // If the spline line gets above the upper zone line, color to area between the lines
            // red (ff0000)
            c.addInterLineLayer(splineLayer.getLine(0), lineLayer.getLine(0), 0xff0000,
                                Chart.Transparent);

            // If the spline line gets below the lower zone line, color to area between the lines
            // blue (0000ff)
            c.addInterLineLayer(splineLayer.getLine(0), lineLayer.getLine(1), Chart.Transparent,
                                0x0000ff);

            // Add a custom CDML text at the bottom right of the plot area as the logo
            c.addText(575, 250,
                      "<*block,valign=absmiddle*><*img=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='Temperature at hour {x}: {value} C'");
        }
Exemple #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)
        {
            // The age groups
            string[] labels = { "0 - 4",   "5 - 9",   "10 - 14", "15 - 19", "20 - 24",
                                "24 - 29", "30 - 34", "35 - 39", "40 - 44", "44 - 49","50 - 54",
                                "55 - 59", "60 - 64", "65 - 69", "70 - 74", "75 - 79","80+" };

            // The male population (in thousands)
            double[] male = { 215, 238, 225, 236, 235, 260, 286, 340, 363, 305, 259,
                              164, 135, 127, 102,  68, 66 };

            // The female population (in thousands)
            double[] female = { 194, 203, 201, 220, 228, 271, 339, 401, 384, 304, 236,
                                137, 116, 122, 112,  85, 110 };


            //=============================================================
            //    Draw the right bar chart
            //=============================================================

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

            // Set the plotarea at (50, 0) and of size 250 x 255 pixels. Use pink
            // (0xffdddd) as the background.
            c.setPlotArea(50, 0, 250, 255, 0xffdddd);

            // Add a custom text label at the top right corner of the right bar chart
            c.addText(300, 0, "Female", "Times New Roman Bold Italic", 12, 0xa07070
                      ).setAlignment(Chart.TopRight);

            // Add the pink (0xf0c0c0) bar chart layer using the female data
            BarLayer femaleLayer = c.addBarLayer(female, 0xf0c0c0, "Female");

            // Swap the axis so that the bars are drawn horizontally
            c.swapXY(true);

            // Set the bar to touch each others
            femaleLayer.setBarGap(Chart.TouchBar);

            // Set the border style of the bars to 1 pixel 3D border
            femaleLayer.setBorderColor(-1, 1);

            // Add a Transparent line layer to the chart using the male data. As it
            // is Transparent, only the female bar chart can be seen. We need to put
            // both male and female data in both left and right charts, because we
            // want auto-scaling to produce the same scale for both chart.
            c.addLineLayer(male, Chart.Transparent);

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

            // Set the labels between the two bar charts, which can be considered as
            // the x-axis labels for the right chart
            ChartDirector.TextBox tb = c.xAxis().setLabels(labels);

            // Use a fix width of 50 for the labels (height = automatic) with center
            // alignment
            tb.setSize(50, 0);
            tb.setAlignment(Chart.Center);

            // Set the label font to Arial Bold
            tb.setFontStyle("Arial Bold");

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

            //=============================================================
            //    Draw the left bar chart
            //=============================================================

            // Create a XYChart object of size 280 x 300 pixels with a transparent
            // background.
            XYChart c2 = new XYChart(280, 300, Chart.Transparent);

            // Set the plotarea at (20, 0) and of size 250 x 255 pixels. Use pale
            // blue (0xddddff) as the background.
            c2.setPlotArea(20, 0, 250, 255, 0xddddff);

            // Add a custom text label at the top left corner of the left bar chart
            c2.addText(20, 0, "Male", "Times New Roman Bold Italic", 12, 0x7070a0);

            // Add the pale blue (0xaaaaff) bar chart layer using the male data
            BarLayer maleLayer = c2.addBarLayer(male, 0xaaaaff, "Male");

            // Swap the axis so that the bars are drawn horizontally
            c2.swapXY(true);

            // Reverse the direction of the y-axis so it runs from right to left
            c2.yAxis().setReverse();

            // Set the bar to touch each others
            maleLayer.setBarGap(Chart.TouchBar);

            // Set the border style of the bars to 1 pixel 3D border
            maleLayer.setBorderColor(-1, 1);

            // Add a Transparent line layer to the chart using the female data. As it
            // is Transparent, only the male bar chart can be seen. We need to put
            // both male and female data in both left and right charts, because we
            // want auto-scaling to produce the same scale for both chart.
            c2.addLineLayer(female, Chart.Transparent);

            // Set the y axis label font to Arial Bold
            c2.yAxis().setLabelStyle("Arial Bold");

            // Set the x-axis labels for tool tip purposes.
            c2.xAxis().setLabels(labels);

            // Hide the x-axis labels by setting them to Transparent. We only need to
            // display the x-axis labels for the right chart.
            c2.xAxis().setColors(0x000000, Chart.Transparent, -1, Chart.Transparent);

            //=============================================================
            //    Use a MultiChart to contain both bar charts
            //=============================================================

            // Create a MultiChart object of size 590 x 320 pixels.
            MultiChart m = new MultiChart(590, 320);

            // Add a title to the chart using Arial Bold Italic font
            m.addTitle("Demographics Hong Kong Year 2002", "Arial Bold Italic");

            // Add another title at the bottom using Arial Bold Italic font
            m.addTitle2(Chart.Bottom, "Population (in thousands)",
                        "Arial Bold Italic", 10);

            // Put the right chart at (270, 25)
            m.addChart(270, 25, c);

            // Put the left chart at (0, 25)
            m.addChart(0, 25, c2);

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

            //include tool tip for the chart
            viewer.ImageMap = m.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} (Age {xLabel}): Population {value}K'");
        }
Exemple #6
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The XY data of the first data series
            double[] dataX = {50, 55, 37, 24, 42, 49, 63, 72, 83, 59};
            double[] dataY = {3.6, 2.8, 2.5, 2.3, 3.8, 3.0, 3.8, 5.0, 6.0, 3.3};

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("");
        }
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, int chartIndex)
        {
            // The data for the area chart
            double[] data = { 30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89, 60, 55, 53, 35,
                              50, 66, 56, 48, 52, 65, 62 };

            // The labels for the area chart
            string[] labels = { "0",  "1",  "2",  "3",  "4",  "5",  "6",  "7",  "8",  "9",  "10", "11", "12",
                                "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24" };

            // Create a XYChart object of size 600 x 360 pixels, with a brushed silver background, 1
            // pixel 3D border effect, rounded corners and soft drop shadow.
            XYChart c = new XYChart(600, 360, Chart.brushedSilverColor(), Chart.Transparent, 1);

            c.setRoundedFrame();
            c.setDropShadow();

            // Add a title box to the chart using 18pt Times Bold Italic font.
            ChartDirector.TextBox title = c.addTitle(
                "<*block,valign=absmiddle*><*img=@/images/star.png*><*img=@/images/star.png*> " +
                "Performance Enhancer <*img=@/images/star.png*><*img=@/images/star.png*><*/*>",
                "Times New Roman Bold Italic", 18);

            //
            // Use a text box with a depressed 3D border to create the inner depressed region
            //

            // The width of the frame border
            int frameWidth = 5;

            // Set the depressed region position
            ChartDirector.TextBox contentBox = c.addText(frameWidth, title.getHeight(), "");
            contentBox.setSize(c.getDrawArea().getWidth() - 1 - frameWidth * 2, c.getDrawArea(
                                   ).getHeight() - title.getHeight() - frameWidth - 1);

            // Use -1 as the rasied effect to create a depressed region
            contentBox.setBackground(Chart.Transparent, Chart.Transparent, -1);

            // Set rounded corners, and put the text box at the back of the chart
            contentBox.setRoundedCorners(10);
            contentBox.setZOrder(Chart.ChartBackZ);

            // Tentatively set the plotarea to 50 pixels from the left depressed edge, and 25 pixels
            // under the top depressed edge. Set the width to 75 pixels less than the depressed
            // region width, and the height to 75 pixels less than the depressed region height. Use
            // white (ffffff) background, transparent border, and grey (cccccc) horizontal and
            // vertical grid lines.
            PlotArea plotArea = c.setPlotArea(50 + contentBox.getLeftX(), contentBox.getTopY() + 25,
                                              contentBox.getWidth() - 75, contentBox.getHeight() - 75, 0xffffff, -1, -1, 0xcccccc,
                                              -1);

            // Add a title to the y axis
            c.yAxis().setTitle("Energy Concentration (KJ per liter)");

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

            // Display 1 out of 3 labels on the x-axis.
            c.xAxis().setLabelStep(3);

            // Add a title to the x axis using CDML
            c.xAxis().setTitle(
                "<*block,valign=absmiddle*><*img=@/images/clock.png*>  Elapsed Time (hour)<*/*>");

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

            // Add an area layer to the chart using a gradient color that changes vertically from
            // semi-transparent red (60ff0000) to semi-transparent white (60ffffff)
            c.addAreaLayer(data, c.linearGradientColor(0, contentBox.getTopY() + 20, 0,
                                                       contentBox.getTopY() + contentBox.getHeight() - 50, 0x60ff0000, 0x60ffffff));

            // Adjust the plot area size, such that the bounding box (inclusive of axes) is 15
            // pixels from the left depressed edge, 25 pixels below the top depressed edge, 25
            // pixels from the right depressed edge, and 15 pixels above the bottom depressed edge.
            c.packPlotArea(contentBox.getLeftX() + 15, contentBox.getTopY() + 25,
                           contentBox.getLeftX() + contentBox.getWidth() - 25, contentBox.getTopY() +
                           contentBox.getHeight() - 15);

            // Add a custom CDML text with the bottom right corner is anchored to the bootom right
            // corner of the plot area, with 5 pixels margin.
            c.addText(plotArea.getLeftX() + plotArea.getWidth() - 5, plotArea.getTopY() +
                      plotArea.getHeight() - 5,
                      "<*block,valign=absmiddle*><*img=@/images/small_molecule.png*> <*block*>" +
                      "<*font=Times New Roman Bold Italic,size=10,color=804040*>Molecular\nEngineering" +
                      "<*/*>").setAlignment(Chart.BottomRight);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Hour {xLabel}: {value} KJ/liter'");
        }
        //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 with error information
            double[] data = { 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[] errData = { 5,     6, 5.1, 6.5, 6.6,   8, 5.4, 5.1, 4.6, 5.0, 5.2, 6.0, 4.9, 5.6, 4.8,
                                 6.2, 7.4, 7.1, 6.0, 6.6, 7.1, 5.3, 5.5, 7.9, 6.1 };

            // 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 600 x 300 pixels, with a light grey (eeeeee)
            // background, black border, 1 pixel 3D border effect and rounded corners.
            XYChart c = new XYChart(600, 300, 0xeeeeee, 0x000000, 1);

            c.setRoundedFrame();

            // Set the plotarea at (55, 55) and of size 520 x 195 pixels, with white (ffffff)
            // background. Set horizontal and vertical grid lines to grey (cccccc).
            c.setPlotArea(55, 55, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);

            // Add a title box to the chart using 15pt Times Bold Italic font. The title is in CDML
            // and includes embedded images for highlight. The text is on a light grey (dddddd)
            // background, with glass lighting effect.
            c.addTitle(
                "<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Molecular " +
                "Temperature Control <*img=star.png*><*img=star.png*><*/*>",
                "Times New Roman Bold Italic", 15).setBackground(0xdddddd, 0, Chart.glassEffect());

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

            // Add a title to the x axis using CMDL
            c.xAxis().setTitle(
                "<*block,valign=absmiddle*><*img=clock.png*>  Elapsed Time (hour)<*/*>");

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

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

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

            // Add a blue (0xff) data set to the line layer, with yellow (0xffff80) diamond symbols
            lineLayer.addDataSet(data, 0x0000ff).setDataSymbol(Chart.DiamondSymbol, 12, 0xffff80);

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

            // Add a box whisker layer to the chart. Use the upper and lower mark of the box whisker
            // layer to act as error zones. The upper and lower marks are computed using the
            // ArrayMath object.
            BoxWhiskerLayer errLayer = c.addBoxWhiskerLayer(null, null, new ArrayMath(data).add(
                                                                errData).result(), new ArrayMath(data).sub(errData).result(), data,
                                                            Chart.Transparent, 0xbb6633);

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

            // Set the error zone to occupy half the space between the symbols
            errLayer.setDataGap(0.5);

            // Add a custom CDML text at the bottom right of the plot area as the logo
            c.addText(575, 247,
                      "<*block,valign=absmiddle*><*img=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. We only need to show the tool tip for the box whisker
            // layer.
            viewer.ImageMap = errLayer.getHTMLImageMap("clickable", "",
                                                       "title='Temperature at hour {xLabel}: {med} +/- {={med}-{min}} C'");
        }
Exemple #9
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            //
            //    We use a random number generator to simulate the data from 9:30am to 4:30pm with one
            //    data point every 4 minutes. The total number of points during that period is 106.  (7
            //    hours x 15 points/hour + 1)
            //
            int noOfPoints = 106;

            // Assume we have not reached the end of the day yet, and only 85 points are available.
            // Create a random table object of 1 col x 85 rows, using 9 as seed.
            RanTable rantable = new RanTable(9, 1, 85);

            // Set the 1st column to start with 1800 and with random delta from -5 to 5.
            rantable.setCol(0, 1800, -5, 5);

            // Get the data as the 1st column of the random table
            double[] data = rantable.getCol(0);

            // The x-axis labels for the chart
            string[] labels = { "-",   "10am", "-", " ", "-", "12am", "-", " ", "-", "2pm", "-", " ", "-",
                                "4pm", "-" };

            //
            //    Now we obtain the data into arrays, we can start to draw the chart using ChartDirector
            //

            // Create a XYChart object of size 180 x 180 pixels with a blue background (0x9c9cce)
            XYChart c = new XYChart(180, 180, 0x9c9cce);

            // Add titles to the top and bottom of the chart using 7.5pt Arial font. The text is white
            // 0xffffff on a deep blue 0x31319C background.
            c.addTitle2(Chart.Top, "STAR TECH INDEX  2003-01-28", "Arial", 7.5, 0xffffff, 0x31319c);
            c.addTitle2(Chart.Bottom, "LATEST  STI:1809.41 (+14.51)", "Arial", 7.5, 0xffffff, 0x31319c);

            // Set the plotarea at (31, 21) and of size 145 x 124 pixels, with a pale yellow (0xffffc8)
            // background.
            c.setPlotArea(31, 21, 145, 124, 0xffffc8);

            // Add custom text at (176, 21) (top right corner of plotarea) using 11pt Times Bold Italic
            // font/red (0xc09090) color
            c.addText(176, 21, "Chart Demo", "Times New Roman Bold Italic", 11, 0xc09090).setAlignment(
                Chart.TopRight);

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

            // Set the labels on the x axis by spreading the labels evenly between the first point (index
            // = 0) and the last point (index = noOfPoints - 1)
            c.xAxis().setLinearScale(0, noOfPoints - 1, labels);

            // Use 7.5pt Arial as the x axis label font
            c.xAxis().setLabelStyle("", 7.5);

            // Add a deep blue (0x000080) line layer to the chart
            c.addLineLayer(data, 0x000080);

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

            // Include tool tip for the chart. The chart starts at 9:30am and each point spans 240
            // seconds, so we can compute the time as {x}*240+9.5*3600.
            viewer.ImageMap = c.getHTMLImageMap("", "", "title='{={x}*240+9.5*3600|h:nna}: {value|2}'");
        }
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, int chartIndex)
        {
            // The data for the chart
            double[] data0 = { 32, 39, 23, 28, 41, 38, 26, 35, 29 };
            double[] data1 = { 50, 55, 47, 34, 47, 53, 38, 40, 51 };

            // The labels for the chart
            string[] labels = { "0", "1", "2", "3", "4", "5", "6", "7", "8" };

            // Create a XYChart object of size 600 x 300 pixels, with a pale red (ffdddd)
            // background, black border, 1 pixel 3D border effect and rounded corners.
            XYChart c = new XYChart(600, 300, 0xffdddd, 0x000000, 1);

            c.setRoundedFrame();

            // Set the plotarea at (55, 58) and of size 520 x 195 pixels, with white (ffffff)
            // background. Set horizontal and vertical grid lines to grey (cccccc).
            c.setPlotArea(55, 58, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);

            // Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9pt Arial
            // Bold font. Set the background and border color to Transparent.
            c.addLegend(55, 32, false, "Arial Bold", 9).setBackground(Chart.Transparent);

            // Add a title box to the chart using 15pt Times Bold Italic font. The title is in CDML
            // and includes embedded images for highlight. The text is white (ffffff) on a dark red
            // (880000) background, with soft lighting effect from the right side.
            c.addTitle(
                "<*block,valign=absmiddle*><*img=@/images/star.png*><*img=@/images/star.png*> " +
                "Performance Enhancer <*img=@/images/star.png*><*img=@/images/star.png*><*/*>",
                "Times New Roman Bold Italic", 15, 0xffffff).setBackground(0x880000, -1,
                                                                           Chart.softLighting(Chart.Right));

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

            // Add a title to the x axis using CMDL
            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 a spline layer to the chart
            SplineLayer layer = c.addSplineLayer();

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

            // Add a data set to the spline layer, using blue (0000c0) as the line color, with
            // yellow (ffff00) circle symbols.
            layer.addDataSet(data1, 0x0000c0, "Target Group").setDataSymbol(Chart.CircleSymbol, 9,
                                                                            0xffff00);

            // Add a data set to the spline layer, using brown (982810) as the line color, with pink
            // (f040f0) diamond symbols.
            layer.addDataSet(data0, 0x982810, "Control Group").setDataSymbol(Chart.DiamondSymbol,
                                                                             11, 0xf040f0);

            // Add a custom CDML text at the bottom right of the plot area as the logo
            c.addText(575, 250,
                      "<*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='{dataSetName} at t = {xLabel} hour: {value} KJ/liter'");
        }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The data for the line chart
            double[] data0 = { 50, 55, 47, 36, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58, 59, 73,
                               77, 84, 82, 80, 84 };
            double[] data1 = { 36, 28, 25, 33, 38, 20, 22, 30, 25, 33, 30, 24, 28, 36, 30, 45, 46, 42, 48,
                               45, 43, 52, 64, 70 };

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

            // Create an XYChart object of size 600 x 360 pixels, with a light blue (EEEEFF) background,
            // black border, 1 pxiel 3D border effect and rounded corners
            XYChart c = new XYChart(600, 360, 0xeeeeff, 0x000000, 1);

            c.setRoundedFrame();

            // Set plotarea at (55, 60) with size of 520 x 240 pixels. Use white (ffffff) as background
            // and grey (cccccc) for grid lines
            c.setPlotArea(55, 60, 520, 240, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);

            // Add a legend box at (55, 58) (top of plot area) using 9pt Arial Bold font with horizontal
            // layout Set border and background colors of the legend box to Transparent
            LegendBox legendBox = c.addLegend(55, 58, false, "Arial Bold", 9);

            legendBox.setBackground(Chart.Transparent);

            // Reserve 10% margin at the top of the plot area during auto-scaling to leave space for the
            // legends.
            c.yAxis().setAutoScale(0.1);

            // Add a title to the chart using 15pt Times Bold Italic font. The text is white (ffffff) on
            // a blue (0000cc) background, with glass effect.
            ChartDirector.TextBox title = c.addTitle("Monthly Revenue for Year 2000/2001",
                                                     "Times New Roman Bold Italic", 15, 0xffffff);
            title.setBackground(0x0000cc, 0x000000, Chart.glassEffect(Chart.ReducedGlare));

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

            // Set the labels on the x axis. Draw the labels vertical (angle = 90)
            c.xAxis().setLabels(labels).setFontAngle(90);

            // Add a vertical mark at x = 17 using a semi-transparent purple (809933ff) color and Arial
            // Bold font. Attached the mark (and therefore its label) to the top x axis.
            Mark mark = c.xAxis2().addMark(17, unchecked ((int)0x809933ff), "Merge with Star Tech",
                                           "Arial Bold");

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

            // Set the mark label font color to purple (0x9933ff)
            mark.setFontColor(0x9933ff);

            // Add a copyright message at (575, 295) (bottom right of plot area) using Arial Bold font
            ChartDirector.TextBox copyRight = c.addText(575, 295, "(c) Copyright Space Travel Ltd",
                                                        "Arial Bold");
            copyRight.setAlignment(Chart.BottomRight);

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

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

            // Add the data sets to the line layer
            layer.addDataSet(data0, -1, "Enterprise");
            layer.addDataSet(data1, -1, "Consumer");

            // Create the image
            viewer.Image = c.makeWebImage(Chart.PNG);

            // Create an image map for the chart
            string chartImageMap = c.getHTMLImageMap(Url.Action("", "xystub"), "",
                                                     "title='{dataSetName} @ {xLabel} = USD {value|0} millions'");

            // Create an image map for the legend box
            string legendImageMap = legendBox.getHTMLImageMap(
                "javascript:popMsg('the legend key [{dataSetName}]');", " ",
                "title='This legend key is clickable!'");

            // Obtain the image map for the title
            string titleImageMap = "<area " + title.getImageCoor() +
                                   " href='javascript:popMsg(\"the chart title\");' title='The title is clickable!'>";

            // Obtain the image map for the mark
            string markImageMap = "<area " + mark.getImageCoor() +
                                  " href='javascript:popMsg(\"the Merge with Star Tech mark\");' title='The Merge with " +
                                  "Star Tech text is clickable!'>";

            // Obtain the image map for the copyright message
            string copyRightImageMap = "<area " + copyRight.getImageCoor() +
                                       " href='javascript:popMsg(\"the copyright message\");' title='The copyright text is " +
                                       "clickable!'>";

            // Get the combined image map
            viewer.ImageMap = chartImageMap + legendImageMap + titleImageMap + markImageMap +
                              copyRightImageMap;
        }
        /// <summary>
        /// Pecs the area count XSSD.
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        private void PecAreaCountXssd(DataTable dt, string name)
        {
            try {
                string[] sdlxms = { "40KM/H以下", "40-50KM/H", "50-60KM/H", "60-70KM/H", "70-80KM/H", "80-90KM/H", "90-100KM/H", "100-110KM/H", "110-120KM/H", "120KM/H 以上" };
                string[] sdlx   = { "000400", "040050", "050060", "060070", "070080", "080090", "090100", "100110", "110120", "120000" };
                double[] dxcl   = new double[10];
                double[] xxcl   = new double[10];
                double[] gacl   = new double[10];
                double[] qtcl   = new double[10];

                for (int i = 0; i < sdlx.Length; i++)
                {
                    System.Data.DataRow[] drs = dt.Select(@"sdlx = '" + sdlx[i] + "'");
                    if (drs != null && drs.Length > 0)
                    {
                        for (int j = 0; j < drs.Length; j++)
                        {
                            dxcl[i] = dxcl[i] + double.Parse(drs[j]["dxcl"].ToString());
                            xxcl[i] = xxcl[i] + double.Parse(drs[j]["xxcl"].ToString());
                            gacl[i] = gacl[i] + double.Parse(drs[j]["gacl"].ToString());
                            qtcl[i] = qtcl[i] + double.Parse(drs[j]["qtcl"].ToString());
                        }
                    }
                    else
                    {
                        dxcl[i] = 0;
                        xxcl[i] = 0;
                        gacl[i] = 0;
                        qtcl[i] = 0;
                    }
                }
                double dc = 0;
                double xc = 0;
                double ga = 0;
                double qt = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dc = dc + double.Parse(dt.Rows[i]["dxcl"].ToString());
                    xc = xc + double.Parse(dt.Rows[i]["xxcl"].ToString());
                    ga = ga + double.Parse(dt.Rows[i]["gacl"].ToString());
                    qt = qt + double.Parse(dt.Rows[i]["qtcl"].ToString());
                }
                string  msg = "共计大型车辆:" + dc.ToString() + "条,小型车辆:" + xc.ToString() + "条,公安车辆:" + ga.ToString() + "条,其它车辆" + qt.ToString() + "条";
                XYChart c   = new XYChart(960, 500);
                c.addTitle("区间行驶速度数据统计图表" + name, "Times New Roman Bold", 15).setBackground(Chart.metalColor(0x8888ff));
                c.addText(110, 475, msg);
                c.setBackground(Chart.metalColor(0xccccff), 0x000000, 1);
                c.addLegend(55, 45, false, "", 8).setBackground(Chart.Transparent);
                c.setPlotArea(80, 80, 800, 360, 0xffffc0, 0xffffe0);
                c.yAxis().setTitle("通过车辆");
                c.yAxis().setTopMargin(20);
                c.xAxis().setLabels(sdlxms);
                BarLayer layer = c.addBarLayer2(Chart.Side, 3);
                layer.addDataSet(dxcl, 0xff8080, "大型车辆");
                layer.addDataSet(xxcl, 0x80ff80, "小型车辆");
                layer.addDataSet(gacl, 0xff80ff, "公安车辆");
                layer.addDataSet(qtcl, 0x8080ff, "其它类型");
                layer.set3D(10);
                layer.setBarShape(Chart.CircleShape);
                WebChartViewer2.Image        = c.makeWebImage(Chart.PNG);
                WebChartViewer2.ImageMap     = c.getHTMLImageMap("", "", "title='{dataSetName} on {xLabel}: {value} 辆'");
                this.WebChartViewer2.Visible = true;
                pnlXssdData.Render(this.WebChartViewer2, RenderMode.Auto);
            }
            catch (Exception ex)
            {
                ILog.WriteErrorLog(ex);
                logManager.InsertLogError("PeccancyAreaQuery.aspx-PecAreaCountXssd", ex.Message + ";" + ex.StackTrace, "PecAreaCountXssd has an exception");
            }
        }
        /// <summary>
        /// Pecs the area count WFXW.
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        private void PecAreaCountWfxw(DataTable dt, string name)
        {
            try {
                string[] wfxwms = { "正常车辆", "超速低于50%", "超速50-70%", "超速70-100%", "超速100%以上" };
                string[] wfxw   = { "0", "13031", "17215", "17216", "17217" };
                double[] dxcl   = new double[5];
                double[] xxcl   = new double[5];
                double[] gacl   = new double[5];
                double[] qtcl   = new double[5];
                for (int i = 0; i < wfxw.Length; i++)
                {
                    System.Data.DataRow[] drs = dt.Select(@"wfxw = '" + wfxw[i] + "'");
                    if (drs != null && drs.Length > 0)
                    {
                        for (int j = 0; j < drs.Length; j++)
                        {
                            dxcl[i] = dxcl[i] + double.Parse(drs[j]["dxcl"].ToString());
                            xxcl[i] = xxcl[i] + double.Parse(drs[j]["xxcl"].ToString());
                            gacl[i] = qtcl[i] + double.Parse(drs[j]["gacl"].ToString());
                            qtcl[i] = qtcl[i] + double.Parse(drs[j]["qtcl"].ToString());
                        }
                    }
                    else
                    {
                        dxcl[i] = 0;
                        xxcl[i] = 0;
                        gacl[i] = 0;
                        qtcl[i] = 0;
                    }
                }
                double dc = 0;
                double xc = 0;
                double ga = 0;
                double qt = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dc = dc + double.Parse(dt.Rows[i]["dxcl"].ToString());
                    xc = xc + double.Parse(dt.Rows[i]["xxcl"].ToString());
                    ga = ga + double.Parse(dt.Rows[i]["gacl"].ToString());
                    qt = qt + double.Parse(dt.Rows[i]["qtcl"].ToString());
                }
                string msg = "共计大型车辆:" + dc.ToString() + "条,小型车辆:" + xc.ToString() + "条,公安车辆:" + ga.ToString() + "条,其它车辆" + qt.ToString() + "条";

                XYChart c = new XYChart(800, 500);
                c.addTitle("区间违法行为数据统计图表" + name, "Times New Roman Bold", 15).setBackground(Chart.metalColor(0x8888ff));
                c.addText(110, 475, msg);
                c.setBackground(Chart.metalColor(0xccccff), 0x000000, 1);
                c.addLegend(55, 45, false, "", 8).setBackground(Chart.Transparent);
                c.setPlotArea(80, 80, 640, 360, 0xffffc0, 0xffffe0);
                c.yAxis().setTitle("通过车辆");
                c.yAxis().setTopMargin(20);
                c.xAxis().setLabels(wfxwms);
                BarLayer layer = c.addBarLayer2(Chart.Side, 3);
                layer.addDataSet(dxcl, 0xff8080, "大型车辆");
                layer.addDataSet(xxcl, 0x80ff80, "小型车辆");
                layer.addDataSet(gacl, 0xff80ff, "公安车辆");
                layer.addDataSet(qtcl, 0x8080ff, "其它类型");
                layer.set3D(10);
                layer.setBarShape(Chart.CircleShape);
                WebChartViewer1.Image        = c.makeWebImage(Chart.PNG);
                WebChartViewer1.ImageMap     = c.getHTMLImageMap("", "", "title='{dataSetName} on {xLabel}: {value} 辆'");
                this.WebChartViewer1.Visible = true;
                pnlWfxwData.Render(this.WebChartViewer1, RenderMode.Auto);
            }
            catch (Exception ex)
            {
                ILog.WriteErrorLog(ex);
                logManager.InsertLogError("PeccancyAreaQuery.aspx-PecAreaCountWfxw", ex.Message + ";" + ex.StackTrace, "PecAreaCountWfxw has an exception");
            }
        }
Exemple #14
0
        /// <summary>
        /// Draw the chart and display it in the given viewer.
        /// </summary>
        private void drawChart(WinChartViewer 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(Chart.CColor(BackColor));

            // 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("Realtime Chart Demonstration", "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("Price (USD)", "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. Access to the data buffer should be synchronized
            // because the data buffer may be updated by another thread at real time
            DateTime lastTime = timeStamps[timeStamps.Length - 1];

            if (lastTime != DateTime.MinValue)
            {
                // Set up the x-axis to show the time range in the data buffer
                c.xAxis().setDateScale(lastTime.AddSeconds(
                                           -dataRateTimer.Interval * timeStamps.Length / 1000), 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, "Software: <*bgColor=FFCCCC*>" +
                                 c.formatValue(dataSeriesA[dataSeriesA.Length - 1], " {value|2} "));
                layer.addDataSet(dataSeriesB, 0x00cc00, "Hardware: <*bgColor=CCFFCC*>" +
                                 c.formatValue(dataSeriesB[dataSeriesB.Length - 1], " {value|2} "));
                layer.addDataSet(dataSeriesC, 0x0000ff, "Services: <*bgColor=CCCCFF*>" +
                                 c.formatValue(dataSeriesC[dataSeriesC.Length - 1], " {value|2} "));

                //
                // To show the capabilities of ChartDirector, we are add a movable threshold
                // line to the chart and dynamically print a warning message on the chart if
                // a data value exceeds the threshold
                //

                // Add a red mark line to the chart, with the mark label shown at the left of
                // the mark line.
                double threshold = (double)alarmThreshold.Value;
                Mark   m         = c.yAxis().addMark(threshold, 0xff0000, "Alarm = " + threshold);
                m.setAlignment(Chart.Left);
                m.setBackground(0xffcccc);

                if ((dataSeriesC[dataSeriesC.Length - 1] > threshold) ||
                    (dataSeriesB[dataSeriesB.Length - 1] > threshold))
                {
                    // Add an alarm message as a custom text box on top-right corner of the
                    // plot area if the latest data value exceeds threshold.
                    c.addText(575, 62, "Alarm - Latest Value Exceeded Threshold",
                              "Arial Bold Italic", 10, 0xffffff, Chart.TopRight).setBackground(0xdd0000);
                }

                // Fill the region above the threshold as semi-transparent red (80ff8888)
                c.addInterLineLayer(layer.getLine(1), m.getLine(), unchecked ((int)0x80ff8888), Chart.Transparent);
                c.addInterLineLayer(layer.getLine(2), m.getLine(), unchecked ((int)0x80ff8888), Chart.Transparent);
            }

            // Set the chart image to the WinChartViewer
            winChartViewer1.Image = c.makeImage();
        }