Ejemplo n.º 1
0
        private void buildLinearChart() {

            int topMargin = 20;
            int bottomnMargin = 70;
            int leftMargin = 50;
            int rightMargin = 150;

            LinearChartData data = (LinearChartData)this.chartData;
            this.Text = data.Title;

            XYChart c = new XYChart(this.chartPanel.Size.Width, this.chartPanel.Size.Height, 0xeeeeff, 0x000000, 1);

            //c.setPlotArea(2 * offset, offset, this.chartPanel.Size.Width - (3 * offset),
            //    this.chartPanel.Size.Height - (3 * offset), 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
            c.setPlotArea(leftMargin, topMargin, this.chartPanel.Size.Width - (leftMargin + rightMargin),
                this.chartPanel.Size.Height - (topMargin + bottomnMargin), 0xffffff, -1, -1, 0xcccccc, 0xcccccc);


            c.addLegend(Size.Width - (rightMargin + 5), topMargin, true, "Arial Bold", 9).setBackground(
                ChartDirector.Chart.Transparent);

            c.xAxis().setTitle(data.XAxisLabel);
            c.yAxis().setTitle(data.YAxisLabel);

            LineLayer layer = null;
            foreach (LinearLayer linearLayer in data.Layers) {
                layer = c.addLineLayer2();
                layer.setLineWidth(2);
                layer.setXData(linearLayer.XValues);
                layer.addDataSet(linearLayer.YValues, -1, linearLayer.LayerLegend);
            }

            this.chartPanel.Image = c.makeImage();
        }
Ejemplo n.º 2
0
        public byte[] CreateChart(IList<ChartItemParm> dateItem,
            string[] labels, string title, string bottom_text, string left_text, string scaleFromat)
        {
            string font_1 = "微軟正黑體";
            string font_2 = "新細明體";

            int CanvasWidth = CommWebSetup.Chart_Canvas_Width;
            int DiagramWidth = CommWebSetup.Chart_Diagram_Width;

            XYChart xyCht = new XYChart(CanvasWidth, CommWebSetup.Chart_Canvas_Height, CommWebSetup.Chart_Canvas_BgColor, CommWebSetup.Chart_Canvas_EdgeColor, 1); //設定畫布區大小
            //parm 5:奇數列顏色
            //parm 6:偶數列顏色
            //parm 7:外框顏色
            xyCht.setPlotArea(72, 90, DiagramWidth, CommWebSetup.Chart_Diagram_Height, 0xefefef, 0xfefefe, Chart.Transparent, 0x999999, 0x999999); //繪制圖表的位置及大小

            xyCht.setRoundedFrame();

            TextBox getTitleText = xyCht.addTitle(title, CommWebSetup.Chart_Title_FontFamily, CommWebSetup.Chart_Title_FontSize, CommWebSetup.Chart_Title_FontColor, CommWebSetup.Chart_Title_BgColor);
            getTitleText.setHeight(CommWebSetup.Chart_Title_Height);
            getTitleText.setAlignment(Chart.Center);

            //設定上方資訊綜合區
            LegendBox legendBox = xyCht.addLegend(72, getTitleText.getHeight(), false, font_1, 10);
            legendBox.setAlignment(Chart.TopLeft);
            legendBox.setBackground(Chart.Transparent, Chart.Transparent);

            //左側處理
            TextBox getY = xyCht.yAxis().setTitle(left_text, font_2, 14);
            getY.setFontAngle(0, true);
            xyCht.yAxis().setWidth(2);
            getY.setHeight(CommWebSetup.Chart_Diagram_Height);

            var getScaleText = xyCht.yAxis().setLabelStyle(font_2, 9);

            if (scaleFromat != null)
            {
                xyCht.yAxis().setLabelFormat(scaleFromat); //設定左邊刻度格式
                //xyCht.yAxis().setLabelFormat("{value}度");
            }

            //底部處理
            var getBottomText = xyCht.xAxis().setTitle(bottom_text, font_1,14);
            var getBottomlabel = xyCht.xAxis().setLabels(labels);
            getBottomlabel.setFontSize(9);
            getBottomlabel.setFontStyle(font_2);
            //xyCht.xAxis().setLabelStep(3); //設定Label間隔(橫向) 如果Label太密集可在此設定

            foreach (var getItem in dateItem)
            {
                LineLayer setLine = xyCht.addLineLayer2();
                setLine.addDataSet(getItem.getData, getItem.color, getItem.name).setDataSymbol(Chart.GlassSphere2Shape, 9);
                setLine.setLineWidth(2);
                setLine.setGapColor(xyCht.dashLineColor(getItem.color)); //設定無值顏色

            }
            //c.layoutLegend();
            return xyCht.makeChart(Chart.PNG);
        }
Ejemplo 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)
        {
            // The XY data of the first data series
            double[] dataX0 = { 10, 35, 17, 4, 22, 29, 45, 52, 63, 39 };
            double[] dataY0 = { 2.0, 3.2, 2.7, 1.2, 2.8, 2.9, 3.1, 3.0, 2.3, 3.3 };

            // The XY data of the second data series
            double[] dataX1 = { 30, 35, 17, 4, 22, 59, 43, 52, 63, 39 };
            double[] dataY1 = { 1.0, 1.3, 0.7, 0.6, 0.8, 3.0, 1.8, 2.3, 3.4, 1.5 };

            // The XY data of the third data series
            double[] dataX2 = { 28, 35, 15, 10, 22, 60, 46, 64, 39 };
            double[] dataY2 = { 2.0, 2.2, 1.2, 0.4, 1.8, 2.7, 2.4, 2.8, 2.4 };

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

            // Set the plotarea at (70, 65) and of size 400 x 350 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(70, 65, 400, 350, 0xffffff, -1, 0xc0c0c0, 0xc0c0c0, -1);

            // Add a legend box with the top center point anchored at (270, 30). Use
            // horizontal layout. Use 10 pts Arial Bold Italic font. Set the
            // background and border color to Transparent.
            LegendBox legendBox = c.addLegend(270, 30, false, "Arial Bold Italic", 10
                                              );

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

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

            // Add titles to the axes using 12 pts Arial Bold Italic font
            c.yAxis().setTitle("Axis Title Placeholder", "Arial Bold Italic", 12);
            c.xAxis().setTitle("Axis Title Placeholder", "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 (dataX0, dataY0)
            c.addScatterLayer(dataX0, dataY0, "Polynomial", Chart.GlassSphere2Shape,
                              11, 0xff0000);

            // Add a degree 2 polynomial trend line layer for (dataX0, dataY0)
            TrendLayer trend0 = c.addTrendLayer2(dataX0, dataY0, 0xff0000);

            trend0.setLineWidth(3);
            trend0.setRegressionType(Chart.PolynomialRegression(2));
            trend0.setHTMLImageMap("{disable}");

            // Add a scatter layer for (dataX1, dataY1)
            c.addScatterLayer(dataX1, dataY1, "Exponential", Chart.GlassSphere2Shape,
                              11, 0x00aa00);

            // Add an exponential trend line layer for (dataX1, dataY1)
            TrendLayer trend1 = c.addTrendLayer2(dataX1, dataY1, 0x00aa00);

            trend1.setLineWidth(3);
            trend1.setRegressionType(Chart.ExponentialRegression);
            trend1.setHTMLImageMap("{disable}");

            // Add a scatter layer using (dataX2, dataY2)
            c.addScatterLayer(dataX2, dataY2, "Logarithmic", Chart.GlassSphere2Shape,
                              11, 0x0000ff);

            // Add a logarithmic trend line layer for (dataX2, dataY2)
            TrendLayer trend2 = c.addTrendLayer2(dataX2, dataY2, 0x0000ff);

            trend2.setLineWidth(3);
            trend2.setRegressionType(Chart.LogarithmicRegression);
            trend2.setHTMLImageMap("{disable}");

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='[{dataSetName}] ({x}, {value})'");
        }
Ejemplo 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)
        {
            // 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 375 pixels
            XYChart c = new XYChart(600, 375);

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

            // Set the plotarea at (50, 55) and of 500 x 280 pixels in size. Use a
            // vertical gradient color from light blue (f9f9ff) to sky blue (aaccff)
            // as background. Set border to transparent and grid lines to white
            // (ffffff).
            c.setPlotArea(50, 55, 500, 280, c.linearGradientColor(0, 55, 0, 335,
                                                                  0xf9fcff, 0xaaccff), -1, Chart.Transparent, 0xffffff);

            // Add a legend box at (50, 28) using horizontal layout. Use 10pts Arial
            // Bold as font, with transparent background.
            c.addLegend(50, 28, false, "Arial Bold", 10).setBackground(
                Chart.Transparent);

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

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

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

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

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

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

            // 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'");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Draw the chart.
        /// </summary>
        private void drawChart(WinChartViewer viewer)
        {
            //
            // In this demo, we copy the visible part of the data to a separate buffer for chart
            // plotting.
            //
            // Note that if you only have a small amount of data (a few hundred data points), it
            // may be easier to just plot all data in any case (so the following copying code is
            // not needed), and let ChartDirector "clip" the chart to the plot area.
            //

            // Using ViewPortLeft and ViewPortWidth, get the start and end dates of the view port.
            DateTime viewPortStartDate = minDate.AddSeconds(Math.Round(viewer.ViewPortLeft * dateRange));
            DateTime viewPortEndDate   = viewPortStartDate.AddSeconds(Math.Round(viewer.ViewPortWidth * dateRange));

            // Get the starting index of the array using the start date
            int startIndex = Array.BinarySearch(timeStamps, viewPortStartDate);

            if (startIndex < 0)
            {
                startIndex = (~startIndex) - 1;
            }

            // Get the ending index of the array using the end date
            int endIndex = Array.BinarySearch(timeStamps, viewPortEndDate);

            if (endIndex < 0)
            {
                endIndex = ((~endIndex) < timeStamps.Length) ? ~endIndex : timeStamps.Length - 1;
            }

            // Get the length
            int noOfPoints = endIndex - startIndex + 1;

            // Now, we can just copy the visible data we need into the view port data series
            DateTime[] viewPortTimeStamps  = new DateTime[noOfPoints];
            double[]   viewPortDataSeriesA = new double[noOfPoints];
            double[]   viewPortDataSeriesB = new double[noOfPoints];
            double[]   viewPortDataSeriesC = new double[noOfPoints];
            Array.Copy(timeStamps, startIndex, viewPortTimeStamps, 0, noOfPoints);
            Array.Copy(dataSeriesA, startIndex, viewPortDataSeriesA, 0, noOfPoints);
            Array.Copy(dataSeriesB, startIndex, viewPortDataSeriesB, 0, noOfPoints);
            Array.Copy(dataSeriesC, startIndex, viewPortDataSeriesC, 0, noOfPoints);

            if (viewPortTimeStamps.Length >= 520)
            {
                //
                // Zoomable chart with high zooming ratios often need to plot many thousands of
                // points when fully zoomed out. However, it is usually not needed to plot more
                // data points than the resolution of the chart. Plotting too many points may cause
                // the points and the lines to overlap. So rather than increasing resolution, this
                // reduces the clarity of the chart. So it is better to aggregate the data first if
                // there are too many points.
                //
                // In our current example, the chart only has 520 pixels in width and is using a 2
                // pixel line width. So if there are more than 520 data points, we aggregate the
                // data using the ChartDirector aggregation utility method.
                //
                // If in your real application, you do not have too many data points, you may
                // remove the following code altogether.
                //

                // Set up an aggregator to aggregate the data based on regular sized slots
                ArrayMath m = new ArrayMath(viewPortTimeStamps);
                m.selectRegularSpacing(viewPortTimeStamps.Length / 260);

                // For the timestamps, take the first timestamp on each slot
                viewPortTimeStamps = m.aggregate(viewPortTimeStamps, Chart.AggregateFirst);

                // For the data values, aggregate by taking the averages
                viewPortDataSeriesA = m.aggregate(viewPortDataSeriesA, Chart.AggregateAvg);
                viewPortDataSeriesB = m.aggregate(viewPortDataSeriesB, Chart.AggregateAvg);
                viewPortDataSeriesC = m.aggregate(viewPortDataSeriesC, Chart.AggregateAvg);
            }

            //
            // Now we have obtained the data, we can plot the chart.
            //

            ///////////////////////////////////////////////////////////////////////////////////////
            // Step 1 - Configure overall chart appearance.
            ///////////////////////////////////////////////////////////////////////////////////////

            // Create an XYChart object 600 x 300 pixels in size, with pale blue (0xf0f0ff)
            // background, black (000000) border, 1 pixel raised effect, and with a rounded frame.
            XYChart c = new XYChart(600, 300, 0xf0f0ff, 0, 1);

            c.setRoundedFrame(Chart.CColor(BackColor));

            // Set the plotarea at (52, 60) and of size 520 x 192 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(52, 60, 520, 192, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
            c.setClipping();

            // Add a top title to the chart using 15 pts Times New Roman Bold Italic font, with a
            // light blue (ccccff) background, black (000000) border, and a glass like raised effect.
            c.addTitle("Zooming and Scrolling Demonstration", "Times New Roman Bold Italic", 15
                       ).setBackground(0xccccff, 0x0, Chart.glassEffect());

            // Add a bottom title to the chart to show the date range of the axis, with a light blue
            // (ccccff) background.
            c.addTitle2(Chart.Bottom, "From <*font=Arial Bold Italic*>"
                        + c.formatValue(viewPortStartDate, "{value|mmm dd, yyyy}")
                        + "<*/font*> to <*font=Arial Bold Italic*>"
                        + c.formatValue(viewPortEndDate, "{value|mmm dd, yyyy}")
                        + "<*/font*> (Duration <*font=Arial Bold Italic*>"
                        + Math.Round(viewPortEndDate.Subtract(viewPortStartDate).TotalSeconds / 86400.0)
                        + "<*/font*> days)", "Arial Italic", 10).setBackground(0xccccff);

            // Add a legend box at the top of the plot area with 9pts Arial Bold font with flow layout.
            c.addLegend(50, 33, false, "Arial Bold", 9).setBackground(Chart.Transparent, Chart.Transparent);

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

            // Add a title to the y-axis
            c.yAxis().setTitle("Price (USD)", "Arial Bold", 9);

            ///////////////////////////////////////////////////////////////////////////////////////
            // Step 2 - Add data to chart
            ///////////////////////////////////////////////////////////////////////////////////////

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

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

            layer.setLineWidth(2);

            // 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, "Product Alpha");
            layer.addDataSet(viewPortDataSeriesB, 0x00cc00, "Product Beta");
            layer.addDataSet(viewPortDataSeriesC, 0x0000ff, "Product Gamma");

            ///////////////////////////////////////////////////////////////////////////////////////
            // Step 3 - Set up x-axis scale
            ///////////////////////////////////////////////////////////////////////////////////////

            // Set x-axis date scale to the view port date range.
            c.xAxis().setDateScale(viewPortStartDate, viewPortEndDate);

            //
            // In the current demo, the x-axis range can be from a few years to a few days. We can
            // let ChartDirector auto-determine the date/time format. However, for more beautiful
            // formatting, we set up several label formats to be applied at different conditions.
            //

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

            // If all ticks are monthly aligned, then 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 daily algined, then 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}");

            // For all other cases (sub-daily ticks), use "hh:nn<*br*>mmm dd" for the first label of
            // a day, and "hh:nn" for other labels.
            c.xAxis().setFormatCondition("else");
            c.xAxis().setMultiFormat(Chart.StartOfDayFilter(), "<*font=bold*>{value|hh:nn<*br*>mmm dd}",
                                     Chart.AllPassFilter(), "{value|hh:nn}");

            ///////////////////////////////////////////////////////////////////////////////////////
            // Step 4 - Set up y-axis scale
            ///////////////////////////////////////////////////////////////////////////////////////

            if ((viewer.ZoomDirection == WinChartDirection.Horizontal) || (minValue == maxValue))
            {
                // y-axis is auto-scaled - save the chosen y-axis scaled to support xy-zoom mode
                c.layout();
                minValue = c.yAxis().getMinValue();
                maxValue = c.yAxis().getMaxValue();
            }
            else
            {
                // xy-zoom mode - compute the actual axis scale in the view port
                double axisLowerLimit = maxValue - (maxValue - minValue) * (viewer.ViewPortTop + viewer.ViewPortHeight);
                double axisUpperLimit = maxValue - (maxValue - minValue) * viewer.ViewPortTop;
                // *** use the following formula if you are using a log scale axis ***
                // double axisLowerLimit = maxValue * Math.Pow(minValue / maxValue, viewer.ViewPortTop + viewer.ViewPortHeight);
                // double axisUpperLimit = maxValue * Math.Pow(minValue / maxValue, viewer.ViewPortTop);

                // use the zoomed-in scale
                c.yAxis().setLinearScale(axisLowerLimit, axisUpperLimit);
                c.yAxis().setRounding(false, false);
            }

            ///////////////////////////////////////////////////////////////////////////////////////
            // Step 5 - Display the chart
            ///////////////////////////////////////////////////////////////////////////////////////

            viewer.Chart = c;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Draw the chart.
        /// </summary>
        private void drawChart(WinChartViewer viewer)
        {
            // Create an XYChart object 500 x 480 pixels in size, with the same background color
            // as the container
            XYChart c = new XYChart(500, 480, Chart.CColor(BackColor));

            // Set the plotarea at (50, 40) and of size 400 x 400 pixels. Use 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(50, 40, 400, 400, -1, -1, -1, 0xc0c0c0, 0xc0c0c0
                          ).set4QBgColor(0xdddddd, 0xeeeeee, 0xdddddd, 0xeeeeee, 0x000000);

            // Enable clipping mode to clip the part of the data that is outside the plot area.
            c.setClipping();

            // 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 (450, 40) (top right corner of the chart) with vertical layout
            // and 8 pts Arial Bold font. Set the background color to semi-transparent grey.
            LegendBox legendBox = c.addLegend(450, 40, true, "arialbd.ttf", 8);

            legendBox.setAlignment(Chart.TopRight);
            legendBox.setBackground(0x40dddddd);

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

            // The default ChartDirector settings has a denser y-axis grid spacing and less-dense
            // x-axis grid spacing. In this demo, we want the tick spacing to be symmetrical.
            // We use around 50 pixels between major ticks and 25 pixels between minor ticks.
            c.xAxis().setTickDensity(50, 25);
            c.yAxis().setTickDensity(50, 25);

            //
            // In this example, we represent the data by scatter points. If you want to represent
            // the data by somethings else (lines, bars, areas, floating boxes, etc), just modify
            // the code below to use the layer type of your choice.
            //

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

            // Add scatter layer, using 11 pixels green (33ff33) circle symbols
            c.addScatterLayer(dataX1, dataY1, "Group B", Chart.CircleShape, 11, 0x33ff33);

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

            if (maxX == minX)
            {
                // The axis scale has not yet been set up. So this is the first time the chart is
                // drawn and it is drawn with no zooming. We can use auto-scaling to determine the
                // axis-scales, then remember them for future use.

                // Explicitly auto-scale axes so we can get the axis scales
                c.layout();

                // Save the axis scales for future use
                minX = c.xAxis().getMinValue();
                maxX = c.xAxis().getMaxValue();
                minY = c.yAxis().getMinValue();
                maxY = c.yAxis().getMaxValue();
            }
            else
            {
                // Compute the zoomed-in axis scales using the overall axis scales and ViewPort size
                double xScaleMin = minX + (maxX - minX) * viewer.ViewPortLeft;
                double xScaleMax = minX + (maxX - minX) * (viewer.ViewPortLeft +
                                                           viewer.ViewPortWidth);
                double yScaleMin = maxY - (maxY - minY) * (viewer.ViewPortTop +
                                                           viewer.ViewPortHeight);
                double yScaleMax = maxY - (maxY - minY) * viewer.ViewPortTop;
                // *** use the following formula if you are using a log scale axis ***
                // double xScaleMin = minX * Math.Pow(maxX / minX, viewer.ViewPortLeft);
                // double xScaleMax = minX * Math.Pow(maxX / minX, viewer.ViewPortLeft +
                //	  viewer.ViewPortWidth);
                // double yScaleMin = maxY * Math.Pow(minY / maxY, viewer.ViewPortTop +
                //	  viewer.ViewPortHeight);
                // double yScaleMax = maxY * Math.Pow(minY / maxY, viewer.ViewPortTop);

                // Set the axis scales
                c.xAxis().setLinearScale(xScaleMin, xScaleMax);
                c.xAxis().setRounding(false, false);
                c.yAxis().setLinearScale(yScaleMin, yScaleMax);
                c.yAxis().setRounding(false, false);
            }

            // Set the chart image to the WinChartViewer
            winChartViewer1.Chart = c;
        }
Ejemplo n.º 7
0
		private void buildMultiBarChart() {

			int topMargin = 30;
			int bottomnMargin = 60;
			int leftMargin = 50;
			int rightMargin = 150;

			MultiBarChartData data = (MultiBarChartData)this.chartData;
			this.Text = data.Title;
			XYChart barChart = new XYChart(this.chartPanel.Size.Width, this.chartPanel.Size.Height, 0xeeeeff, -1, 2);

			barChart.setPlotArea(leftMargin, topMargin, this.chartPanel.Size.Width - (leftMargin + rightMargin),
				this.chartPanel.Size.Height - (topMargin + bottomnMargin), 0xffffff, -1, -1, 0xcccccc, 0xcccccc);

			barChart.addTitle(data.Title);

			barChart.addLegend(Size.Width - (rightMargin - 5), topMargin, true, "Arial Bold", 9).setBackground(
				ChartDirector.Chart.Transparent);

			// Set the labels on the x axis.
			barChart.xAxis().setLabels(data.XLabels);

			// Add a multi-bar chart layer using the given data
			ChartDirector.BarLayer layer = barChart.addBarLayer2(ChartDirector.Chart.Side, data.BarLayers.Length);
			foreach (BarLayer barLayer in data.BarLayers) {
				layer.addDataSet(barLayer.Data, -1, barLayer.Label);
			}

			// output the chart
			this.chartPanel.Image = barChart.makeImage();
		}
Ejemplo n.º 8
0
    private void SetMonthlyProductGraph()
    {
        int yearFrom = Convert.ToInt32(Request["yearfrom"]);
        int yearTo = Convert.ToInt32(Request["yearto"]);
        int currentYear = Convert.ToInt32(Request["currentyear"]);
        //int yearFrom = 2551;
        //int yearTo = 2551;
        //int currentYear = 2551;
        this.lnkYear.Text = GetReportTitle() + (yearFrom == yearTo ? "ã¹»Õ ¾.È. " + yearFrom.ToString() : " µÑé§áµè»Õ ¾.È. " + yearFrom.ToString() + "-" + yearTo.ToString());
        this.lblMonth.Text = ">> »Õ ¾.È. " + currentYear.ToString();
        this.pnlMonth.Visible = true;
        string[] labels = { "Á.¤.", "¡.¾.", "ÁÕ.¤.", "àÁ.Â.", "¾.¤.", "ÁÔ.Â.", "¡.¤.", "Ê.¤.", "¡.Â.", "µ.¤.", "¾.Â.", "¸.¤." };
        XYChart c = new XYChart(750, 380, 15663086, 14540253, 0);
        string title = GetReportTitle() + "ã¹»Õ ¾.È. " + currentYear.ToString();

        c.addTitle(title, "Tahoma Bold", 12);
        c.setPlotArea(70, 80, 640, 230, c.gradientColor(0, 60, 0, 350, 16777215, 11189196), -1, Chart.Transparent, 1111);
        c.addLegend(30, 25, false, "Tahoma Bold", 8).setBackground(Chart.Transparent); 
        c.xAxis().setLabels(labels);
        c.yAxis().setTickDensity(30);
        c.xAxis().setLabelStyle("Tahoma", 8, 001122, 90);
        c.yAxis().setLabelStyle("Tahoma", 8);
        c.yAxis().setLabelFormat("{value|0,}");
        c.xAxis().setWidth(2);
        c.yAxis().setWidth(2);
        c.yAxis().setTitle("ÃÒ¤Ò", "Tahoma Bold", 10);
        c.xAxis().setTitle("à´×͹", "Tahoma Bold", 10);

        LineLayer layer = c.addLineLayer();
        layer.setLineWidth(1);
        AddData(layer, currentYear - 543);
        vwChart.Image = c.makeWebImage(Chart.PNG);
        vwChart.ImageMap = c.getHTMLImageMap("", "", "title='{dataSetName} ã¹à´×͹ {xLabel}\r\n{value|,} ÃÒ¡Òà ({percent}%)'");
        this.pnlChart.Visible = true;
    }
Ejemplo n.º 9
0
        //Main code for creating chart.
        //Note: the argument img is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, string img)
        {
            // The data for the chart
            double[] data = { 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 8 pts 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 13 pts 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=star.png*><*img=star.png*> Y " +
                "Zone Color Demo <*img=star.png*><*img=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=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=small_molecule.png*> <*block*>" +
                      "<*font=Times New Roman Bold Italic,size=10,color=804040*>" +
                      "Molecular\nEngineering<*/*>").setAlignment(Chart.BottomRight);

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Hour {xLabel}: {value} KJ/liter'");
        }
Ejemplo n.º 10
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 line chart
            double[] data0 = { 70, 73, 80, 90, 95, 93, 82, 77, 82, 101, 111, 115 };
            double[] data1 = { 90, 96, 89, 77, 82, 96, 109, 109, 99, 108, 96, 91 };
            double[] data2 = { 58, 34, 25, 49, 64, 10, 16, 40, 25, 49, 40, 22 };

            // The labels for the line chart
            string[] labels = { "2008-01", "2008-02", "2008-03", "2008-04", "2008-05", "2008-06",
                                "2008-07", "2008-08", "2008-09", "2008-10", "2008-11", "2008-12" };

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

            // Add a title to the chart using 15pt Arial Italic font.
            ChartDirector.TextBox title = c.addTitle("Inter-line Coloring", "Arial Italic", 15);

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

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

            // Tentatively set the plotarea at (70, 65) and of (chart_width - 100) x (chart_height -
            // 110) in size. Use light grey (c0c0c0) border and horizontal and vertical grid lines.
            PlotArea plotArea = c.setPlotArea(70, 65, c.getWidth() - 100, c.getHeight() - 110, -1,
                                              -1, 0xc0c0c0, 0xc0c0c0, -1);

            // Add a title to the y axis using 12pt Arial Bold Italic font
            c.yAxis().setTitle("Axis Title Placeholder", "Arial Bold Italic", 12);

            // Add a title to the x axis using 12pt Arial Bold Italic font
            c.xAxis().setTitle("Axis Title Placeholder", "Arial Bold Italic", 12);

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

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

            // Use 8 points Arial rotated by 90 degrees as the x-axis label font
            c.xAxis().setLabelStyle("Arial", 8, Chart.TextColor, 90);

            // Add a spline curve to the chart
            SplineLayer layer0 = c.addSplineLayer(data0, 0xff0000, "Data Set 0");

            layer0.setLineWidth(2);

            // Add a normal line to the chart
            LineLayer layer1 = c.addLineLayer(data1, 0x008800, "Data Set 1");

            layer1.setLineWidth(2);

            // Color the region between the above spline curve and normal line. Use the
            // semi-transparent red (80ff000000) if the spline curve is higher than the normal line,
            // otherwise use semi-transparent green (80008800)
            c.addInterLineLayer(layer0.getLine(), layer1.getLine(), unchecked ((int)0x80ff0000),
                                unchecked ((int)0x80008800));

            // Add another normal line to the chart
            LineLayer layer2 = c.addLineLayer(data2, 0x0000ff, "Data Set 2");

            layer2.setLineWidth(2);

            // Add a horizontal mark line to the chart at y = 40
            Mark mark = c.yAxis().addMark(40, -1, "Threshold");

            mark.setLineWidth(2);

            // Set the mark line to purple (880088) dash line. Use white (ffffff) for the mark
            // label.
            mark.setMarkColor(c.dashLineColor(0x880088), 0xffffff);

            // Put the mark label at the left side of the mark, with a purple (880088) background.
            mark.setAlignment(Chart.Left);
            mark.setBackground(0x880088);

            // Color the region between the above normal line and mark line. Use the
            // semi-transparent blue (800000ff) if the normal line is higher than the mark line,
            // otherwise use semi-transparent purple (80880088)
            c.addInterLineLayer(layer2.getLine(), mark.getLine(), unchecked ((int)0x800000ff),
                                unchecked ((int)0x80880088));

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

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

            // 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.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} in {xLabel}: {value}'");
        }
Ejemplo n.º 11
0
        private void drawChart(WinChartViewer viewer)
        {
            DateTime viewPortStartDate = beginDate.AddSeconds(Math.Round(viewer.ViewPortLeft * dateRange));
            DateTime viewPortEndDate = viewPortStartDate.AddSeconds(Math.Round(viewer.ViewPortWidth * dateRange));
            TimeSpan hoursCalc = viewPortEndDate.Subtract(viewPortStartDate);
            int hours = (hoursCalc.Days * 24) + hoursCalc.Hours;
            viewPortEndDate = viewPortEndDate.AddMinutes(12 * hours); // hack to show hour labels
            Double axisLowerLimit = 0 + viewer.ViewPortTop * rowRange;
            Double axisUpperLimit = axisLowerLimit + viewer.ViewPortHeight * (rowRange);

            XYChart c = new XYChart(winChartViewer1.Width, this.winChartViewer1.Height, 0xf0f0ff, 0, 1);
            //c.setRoundedFrame(ChartDirector.Chart.CColor(BackColor));
			
			// Set the plotarea at (52, 60) and of size 520 x 192 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.
            int tryToBeMoreDynamic = this.Parent.Height - 200; // instead of hardcoding height
            c.setPlotArea(100, 50, 600, tryToBeMoreDynamic, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
			c.setClipping();

            c.yAxis().setWidth(2);
            c.yAxis().setDateScale(viewPortStartDate, viewPortEndDate);
            c.yAxis().setMultiFormat(ChartDirector.Chart.StartOfHourFilter(), "<*font=bold*>{value|w hh:nn}", ChartDirector.Chart.AllPassFilter(), "{value|w hh:nn}");

            c.xAxis().setWidth(2);
            c.xAxis().setLinearScale(axisLowerLimit, axisUpperLimit, 1);
            c.xAxis().setRounding(false, false);
            c.xAxis().setColors(0xcccccc, ChartDirector.Chart.Transparent);
            c.xAxis().setReverse();

            // swap the x and y axes to create a horziontal box-whisker chart
            c.swapXY();
            BoxWhiskerLayer layer = c.addBoxWhiskerLayer2(ChartDirector.Chart.CTime(timelineBlockBegins.ToArray()), ChartDirector.Chart.CTime(timelineBlockEnds.ToArray()));
            layer.setBoxColors(timelineBlockColors.ToArray());
            layer.addExtraField(timelineBlockNames.ToArray());
            layer.setXData(timelineBlockRow.ToArray());
            layer.setDataLabelFormat("{field0}");
            layer.setDataLabelStyle("Arial Bold").setAlignment(ChartDirector.Chart.Center);
            layer.setDataWidth(35);
            //layer.setDataGap(1);
            // TimelineRow parent
            Double rowParent = 0;
            Int32 colorParentIndex = 0;
            c.xAxis().addMark(0, 0x000000).setLineWidth(2);
            foreach (Double d in timelineBlockZones)
            {
                Double rowParentBegin = rowParent; // --0.5;
                Double rowParentEnd = d + 0.5; // --0.5;

                c.xAxis().addZone(rowParentBegin, rowParentEnd, timelineRowColors[colorParentIndex]);

                Mark xMark1 = c.xAxis().addMark(rowParentBegin, 0x000000, timelineRowNames[colorParentIndex]);
                xMark1.setLineWidth(2);
                xMark1.setFontStyle("Arial Bold Italic");

                // xMark1.setAlignment(ChartDirector.Chart.Center);

                //Mark xMark2 = c.xAxis().addMark(rowParentBegin, 0x000000);
                //xMark2.setLineWidth(2);

                rowParent = d;

                colorParentIndex++;
            }

            // TimelineRow child;
            double inset = 0.5;
            Int32 colorChildIndex = 0;
            foreach (String s in timelineRows)
            {
                Mark xMark = c.xAxis().addMark(colorChildIndex + inset, 0x000000, s);
                xMark.setLineWidth(0);

                colorChildIndex++;
            }

            // Milestones
            c.yAxis2().setDateScale(viewPortStartDate, viewPortEndDate);
            c.yAxis2().setColors(ChartDirector.Chart.Transparent, ChartDirector.Chart.Transparent, ChartDirector.Chart.Transparent);

            if (bShowMilestones)
            {
                Int32 timelineMilestoneCount = 0;
                int indentY = 40;
                double previousValue = 0.0;

                List<IndexedTime> indexedTimes = new List<IndexedTime>();
                for (int i = 0; i < timelineMilestoneTimes.Count; i++)
                {
                    indexedTimes.Add(new IndexedTime(timelineMilestoneTimes[i], i));
                }
                indexedTimes.Sort();

                int one = Int32.Parse("000000", System.Globalization.NumberStyles.AllowHexSpecifier);
                int two = Int32.Parse("888888", System.Globalization.NumberStyles.AllowHexSpecifier);
                int three = Int32.Parse("BB7700", System.Globalization.NumberStyles.AllowHexSpecifier);
                Int32 lineColor = one;

                foreach (IndexedTime time in indexedTimes)
                {
                    if (indentY > tryToBeMoreDynamic-10)
                    {
                        indentY = 40;
                    }

                    indentY += 20;

                    //Int32 lineColor = timelineMilestoneColors[time.Index];
                    Double value = ChartDirector.Chart.CTime(time.Time);

                    if (!value.Equals(previousValue))
                    {
                        if (lineColor == one)
                        {
                            lineColor = two;
                        }
                        else if (lineColor == two)
                        {
                            lineColor = three;
                        }
                        else if (lineColor == three)
                        {
                            lineColor = one;
                        }
                    }

                    Mark yMark = c.yAxis2().addMark(value, c.dashLineColor(lineColor, ChartDirector.Chart.DashLine), timelineMilestoneNames[time.Index]);

                    yMark.setPos(0, indentY);
                    yMark.setFontColor(lineColor);
                    yMark.setLineWidth(2);
                    yMark.setFontStyle("Arial Bold");
                    timelineMilestoneCount++;
                    previousValue = value;
                }
            }

            if (legendStrings != null)
            {
                LegendBox l = c.addLegend(5, 5);
                l.setFontSize(legendFontSize);
                l.setCols(legendStrings.Length);

                for (int i = 0; i < legendStrings.Length; i++)
                {
                    l.addKey(legendStrings[i], legendColors[i]);
                }
            }

            if (navigator != null && componentId >= 0 && legend.Items.Count == 0)
            {
                XPathNodeIterator iTLFilter = navigator.Select("//TimelineFilter");
                List<Int32> seenIDs = new List<Int32>();

                ImageList forLegend = new ImageList();
                foreach (XPathNavigator tlFilterItem in iTLFilter)
                {
                    string filterItemColor = tlFilterItem.GetAttribute(colorAttribute, tlFilterItem.NamespaceURI);

                    if (!forLegend.Images.ContainsKey(filterItemColor))
                    {
                        try
                        {
                            Bitmap bm = new Bitmap(16, 16);
                            Graphics g = Graphics.FromImage((Image)bm);
                            Brush forGraphics = new SolidBrush(HexToColor(filterItemColor));
                            
                            g.SmoothingMode = SmoothingMode.AntiAlias;
                            g.FillRectangle(forGraphics, new Rectangle(0, 0, bm.Width, bm.Height));
                            Icon icon = Icon.FromHandle(bm.GetHicon());
                            forGraphics.Dispose();
                            g.Dispose();
                            bm.Dispose();

                            forLegend.Images.Add(filterItemColor, icon);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, "Error creating icon");
                        }
                    }
                }

                legend.SmallImageList = forLegend;

                foreach (XPathNavigator tlFilterItem in iTLFilter)
                {
                    string filterItemName = tlFilterItem.GetAttribute(nameAttribute, tlFilterItem.NamespaceURI);
                    string filterItemID = tlFilterItem.GetAttribute(idAttribute, tlFilterItem.NamespaceURI);
                    string filterItemType = tlFilterItem.GetAttribute(typeAttribute, tlFilterItem.NamespaceURI);
                    string filterItemColor = tlFilterItem.GetAttribute(colorAttribute, tlFilterItem.NamespaceURI);

                    int iParse = Int32.Parse(filterItemID);
                    if (!seenIDs.Contains(iParse))
                    {
                        legend.Items.Add(filterItemName, filterItemColor);
                        seenIDs.Add(iParse);
                    }
                }
            }

            //Int32 timelineMilestoneCount = 0;
            //foreach (String milestonName in timelineMilestoneNames)
            //{
            //    Double[] xData = { 0 };
            //    Double[] yData = { ChartDirector.Chart.CTime(timelineMilestoneTimes[timelineMilestoneCount]) };
            //    Int32 color = timelineMilestoneColors[timelineMilestoneCount];
            //    ScatterLayer sLayer = c.addScatterLayer(xData, yData, "", ChartDirector.Chart.TriangleSymbol, 13, color);
            //    timelineMilestoneCount++;

            //    // Add labels to the chart as an extra field
            //    sLayer.addExtraField(timelineMilestoneNames.ToArray());

            //    // Set the data label format to display the extra field
            //    sLayer.setDataLabelFormat("{field0}");
            //}

			viewer.Chart = c;
        }
Ejemplo n.º 12
0
    private void SetDatelyProductGraph()
    {
        this.pnlMonth.Visible = false;
        DateTime DateFrom = this.ctlDateFrom.DateValue;
        DateTime DateTo = this.ctlDateTo.DateValue;
        string BarcodeFrom = this.txtBarcodeFrom.Text;
        string BarcodeTo = this.txtBarcodeTo.Text;
        DateTime temp = DateFrom;
        if (DateFrom > DateTo)
        {
            DateFrom = DateTo;
            DateTo = temp;
        }
        string[] labels = GetDateXLabel(DateFrom, DateTo);
        XYChart c = new XYChart(750, 380, 15663086, 14540253, 0);
        string title = GetReportTitle() + (DateFrom == DateTo ? "ã¹Çѹ·Õè " + DateFrom.ToString() : " µÑé§áµèÇѹ·Õè " + DateFrom.ToString().Substring(0, 9) + "-" + DateTo.ToString().Substring(0, 9));

        c.addTitle(title, "Tahoma Bold", 12);
        c.setPlotArea(70, 80, 640, 230, c.gradientColor(0, 60, 0, 350, 16777215, 11189196), -1, Chart.Transparent, 1111);
        c.addLegend(30, 25, false, "Tahoma Bold", 8).setBackground(Chart.Transparent); c.xAxis().setLabels(labels);
        c.yAxis().setTickDensity(30);
        c.xAxis().setLabelStyle("Tahoma", 8, 001122, 90);
        c.yAxis().setLabelStyle("Tahoma", 8);
        c.yAxis().setLabelFormat("{value|0,}");
        c.xAxis().setWidth(2);
        c.yAxis().setWidth(2);
        c.yAxis().setTitle("¨Ó¹Ç¹ÊÔ¹¤éÒ/Çѵ¶Ø´Ôº", "Tahoma Bold", 10);
        c.xAxis().setTitle("Çѹ·Õè", "Tahoma Bold", 10);

        c.xAxis().setLabels(labels);


        LineLayer layer = c.addLineLayer();
        layer.setLineWidth(1);
        AddDateData(layer, DateFrom, DateTo, BarcodeFrom, BarcodeTo);
        vwChart.Image = c.makeWebImage(Chart.PNG);
        vwChart.ImageMap = c.getHTMLImageMap("", "",
            "title='{dataSetName} ã¹Çѹ·Õè {xLabel}\r\n{value|,} ÃÒ¡Òà ({percent}%)'");
    }
Ejemplo n.º 13
0
    private void SetYearlyProductGraph()
    {
        this.pnlMonth.Visible = false;
        int yearFrom = Convert.ToInt32(this.txtYearFrom.Text == "" ? "0" : this.txtYearFrom.Text)-543;
        int yearTo = Convert.ToInt32(this.txtYearTo.Text == "" ? "0" : this.txtYearTo.Text)-543;
        string BarcodeFrom = this.txtBarcodeFrom.Text;
        string BarcodeTo = this.txtBarcodeTo.Text;
        if (yearFrom <0) yearFrom =0;
        if (yearTo < 0) yearTo = 0;
        int temp = yearFrom;
        if (yearFrom > yearTo)
        {
            yearFrom = yearTo;
            yearTo = temp;
        }
        yearFrom += 543;
        yearTo += 543;
        string[] labels = GetXLabel(yearFrom, yearTo);
        XYChart c = new XYChart(750, 380, 15663086, 14540253, 0);
        string title = GetReportTitle() + (yearFrom == yearTo ? "ã¹»Õ ¾.È. " + yearFrom.ToString() : " µÑé§áµè»Õ ¾.È. " + yearFrom.ToString() + "-" + yearTo.ToString());

        c.addTitle(title, "Tahoma Bold",12);
        c.setPlotArea(70, 80, 640, 230, c.gradientColor(0, 60, 0, 350, 16777215, 11189196), -1, Chart.Transparent, 1111);
        c.addLegend(30, 25, false, "Tahoma Bold", 8).setBackground(Chart.Transparent);c.xAxis().setLabels(labels);
        c.yAxis().setTickDensity(30);
        c.xAxis().setLabelStyle("Tahoma", 8, 001122, 90);
        c.yAxis().setLabelStyle("Tahoma", 8);
        c.yAxis().setLabelFormat("{value|0,}");
        c.xAxis().setWidth(2);
        c.yAxis().setWidth(2);
        c.yAxis().setTitle("¨Ó¹Ç¹ÊÔ¹¤éÒ/Çѵ¶Ø´Ôº", "Tahoma Bold", 10);
        c.xAxis().setTitle("»Õ ¾.È.", "Tahoma Bold", 10);

        LineLayer layer = c.addLineLayer();
        layer.setLineWidth(1);
        AddData(layer, yearFrom - 543, yearTo - 543,BarcodeFrom,BarcodeTo);
        vwChart.Image = c.makeWebImage(Chart.PNG);
        vwChart.ImageMap = c.getHTMLImageMap(GetReportPath()+ "?type=" + Request["type"] +  "&producegroup=" + this.cmbProduceGroup.SelectedItem.Value.ToString() + "&BarcodeFrom =" + this.txtBarcodeFrom.Text + "&BarcodeTo =" + this.txtBarcodeTo.Text+ "&currentyear={xLabel}&yearfrom=" + yearFrom.ToString() + "&yearto=" + yearTo.ToString(), "",
            "title='{dataSetName} ã¹»Õ {xLabel}\r\n{value|,} ÃÒ¡Òà ({percent}%)'");
    }
Ejemplo n.º 14
0
        //
        // Draw the chart and display it in the given viewer
        //
        private void drawChart(WPFChartViewer viewer)
        {
            // Create an XYChart object 500 x 480 pixels in size, with the same background color
            // as the container
            XYChart c = new XYChart(500, 480, 0xccccff);

            // Set the plotarea at (50, 40) and of size 400 x 400 pixels. Use 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(50, 40, 400, 400, -1, -1, -1, 0xc0c0c0, 0xc0c0c0
                          ).set4QBgColor(0xdddddd, 0xeeeeee, 0xdddddd, 0xeeeeee, 0x000000);

            // Enable clipping mode to clip the part of the data that is outside the plot area.
            c.setClipping();

            // 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 (450, 40) (top right corner of the chart) with vertical layout
            // and 8 pts Arial Bold font. Set the background color to semi-transparent grey.
            LegendBox b = c.addLegend(450, 40, true, "Arial Bold", 8);

            b.setAlignment(Chart.TopRight);
            b.setBackground(0x40dddddd);

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

            // The default ChartDirector settings has a denser y-axis grid spacing and less-dense
            // x-axis grid spacing. In this demo, we want the tick spacing to be symmetrical.
            // We use around 50 pixels between major ticks and 25 pixels between minor ticks.
            c.xAxis().setTickDensity(50, 25);
            c.yAxis().setTickDensity(50, 25);

            //
            // In this example, we represent the data by scatter points. If you want to represent
            // the data by somethings else (lines, bars, areas, floating boxes, etc), just modify
            // the code below to use the layer type of your choice.
            //

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

            // Add scatter layer, using 11 pixels green (33ff33) circle symbols
            c.addScatterLayer(dataX1, dataY1, "Group B", Chart.CircleShape, 11, 0x33ff33);

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

            //
            // In this example, we have not explicitly configured the full x and y range. In this case, the
            // first time syncLinearAxisWithViewPort is called, ChartDirector will auto-scale the axis and
            // assume the resulting range is the full range. In subsequent calls, ChartDirector will set the
            // axis range based on the view port and the full range.
            //
            viewer.syncLinearAxisWithViewPort("x", c.xAxis());
            viewer.syncLinearAxisWithViewPort("y", c.yAxis());

            // 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) && viewer.IsMouseOnPlotArea)
            {
                crossHair(c, viewer.PlotAreaMouseX, viewer.PlotAreaMouseY);
            }

            // Set the chart image to the ChartViewer
            viewer.Chart = c;
        }
Ejemplo n.º 15
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 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=@/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(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=@/images/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=@/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='Temperature at hour {x}: {value} C'");
        }
Ejemplo n.º 16
0
        protected void SingleChartInit(StackPanel configDisplayPanel, bool skipLegend, bool useTransColors)
        {
            List<string>[] chartLabels = null;

            // Initialize chart

            // Get the Factor Labels
            chartLabels = GetConfigDisplayLabels();
            if (chartLabels == null)
            {
                return;
            }

            int numOpenFactors = chartLabels.Length;

            // Tan border
            SolidColorBrush titleBorderBrush = new SolidColorBrush();
            titleBorderBrush.Color = Color.FromRgb(248, 245, 232);

            // Create a gird with a single entry for the chart
            Grid grid = new Grid();
            grid.Width = configDisplay.Width;
            grid.Height = configDisplay.Height;
            grid.HorizontalAlignment = HorizontalAlignment.Left;
            grid.VerticalAlignment = VerticalAlignment.Top;

            ColumnDefinition colDef = new ColumnDefinition();
            grid.ColumnDefinitions.Add(colDef);

            RowDefinition rowDef = new RowDefinition();
            rowDef.Height = GridLength.Auto;
            grid.RowDefinitions.Add(rowDef);
            rowDef = new RowDefinition();
            rowDef.Height = GridLength.Auto;
            grid.RowDefinitions.Add(rowDef);
            rowDef = new RowDefinition();
            rowDef.Height = GridLength.Auto;
            grid.RowDefinitions.Add(rowDef);

            // Add Title
            Border border = new Border();
            border.BorderBrush = titleBorderBrush;
            border.BorderThickness = new Thickness(4);
            TextBlock txt = new TextBlock();
            txt.Text = configDisplay.Name;
            txt.FontSize = 14;
            txt.HorizontalAlignment = HorizontalAlignment.Center;
            border.Child = txt;
            Grid.SetColumn(border, 0);
            Grid.SetRow(border, 0);
            grid.Children.Add(border);

            // Create the legend for chart
            int legendHeight = 0;

            if ((chartLabels[numOpenFactors - 1] != null) &&
                (chartLabels[numOpenFactors - 1].Count > 6))
            {
                legendHeight = 75;
            }
            else
            {
                legendHeight = 40;
            }

            if (!skipLegend)
            {
                XYChart legend = new XYChart(configDisplay.Width, legendHeight);
                Image img = new Image();
                LegendBox legendBox = legend.addLegend(0, 0, false);
                DockPanel dockPanel = new DockPanel();

                legendBox.setBackground(0xffffff, 0xffffff);
                legendBox.setCols(-5);

                uint[] currentColors = null;
                if (useTransColors)
                {
                    currentColors = barcodeColorsTrans;
                }
                else {
                    currentColors = barcodeColors;
                }

                if (chartLabels[numOpenFactors-1] == null)
                {
                    legendBox.addKey(configDisplay.MetricName, (int)currentColors[0]);
                }
                else
                {
                    for (int z = 0; z < chartLabels[numOpenFactors-1].Count; z++)
                    {
                        if (z < barcodeColors.Length)
                        {
                            legendBox.addKey(chartLabels[numOpenFactors - 1][z], (int) currentColors[z]);
                        }
                        else
                        {
                            legendBox.addKey(chartLabels[numOpenFactors - 1][z], (int) currentColors[0]);
                        }
                    }
                }

                System.Drawing.Image imgWinForms = legend.makeImage();
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                MemoryStream ms = new MemoryStream();
                imgWinForms.Save(ms, ImageFormat.Bmp);
                ms.Seek(0, SeekOrigin.Begin);
                bi.StreamSource = ms;
                bi.EndInit();

                CroppedBitmap croppedBitmap = new CroppedBitmap(bi, new Int32Rect(0, 0, configDisplay.Width, legendHeight));
                img.Source = croppedBitmap;
                img.Height = legendHeight;
                img.Width = configDisplay.Width;
                img.HorizontalAlignment = HorizontalAlignment.Left;
                img.VerticalAlignment = VerticalAlignment.Center;

                Grid.SetColumn(dockPanel, 0);
                Grid.SetRow(dockPanel, 1);
                dockPanel.Children.Add(img);
                grid.Children.Add(dockPanel);
            }

            // Add Grid to config display panel
            configDisplayPanel.Children.Add(grid);
        }
Ejemplo 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)
        {
            // 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.Chart = c;

            // include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable");
        }
Ejemplo n.º 18
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[] 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'");
        }
Ejemplo 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)
        {
            // The data for the line 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 = { 36, 28, 25, 33, 38, 20, 22, 30, 25, 33, 30, 24, 28, 15, 21, 26, 46,
                               42, 48, 45, 43, 52, 64, 60, 70 };

            // The labels for the line 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 an XYChart object of size 600 x 300 pixels, with a light blue (EEEEFF)
            // background, black border, 1 pxiel 3D border effect and rounded corners
            XYChart c = new XYChart(600, 300, 0xeeeeff, 0x000000, 1);

            c.setRoundedFrame();

            // 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 (0xcccccc)
            c.setPlotArea(55, 58, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);

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

            // Add a title box to the chart using 15pt Times Bold Italic font, on a light blue
            // (CCCCFF) background with glass effect. white (0xffffff) on a dark red (0x800000)
            // background, with a 1 pixel 3D border.
            c.addTitle("Application Server Throughput", "Times New Roman Bold Italic", 15
                       ).setBackground(0xccccff, 0x000000, Chart.glassEffect());

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

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

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

            // Add a title to the x axis
            c.xAxis().setTitle("Jun 12, 2006");

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

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

            // Add the three data sets to the line layer. For demo purpose, we use a dash line color
            // for the last line
            layer.addDataSet(data0, 0xff0000, "Server #1");
            layer.addDataSet(data1, 0x008800, "Server #2");
            layer.addDataSet(data2, c.dashLineColor(0x3333ff, Chart.DashLine), "Server #3");

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='[{dataSetName}] Hour {xLabel}: {value} MBytes'");
        }
Ejemplo n.º 20
0
    private void SetYearlyGraph()
    {
        int yearFrom = Convert.ToInt32((txtYearFrom.Text.Trim() == "" ? "0" : txtYearFrom.Text.Trim())) - 543;
        int yearTo = Convert.ToInt32((txtYearTo.Text.Trim() == "" ? "0" : txtYearTo.Text.Trim())) - 543;
        if (yearFrom < 0)
            yearFrom = 0;
        if (yearTo < 0)
            yearTo = 0;
        int tmp = yearFrom;
        if (yearFrom > yearTo)
        {
            yearFrom = yearTo;
            yearTo = tmp;
        }
        yearFrom += 543;
        yearTo += 543;

        string[] labels = { "Á.¤.", "¡.¾.", "ÁÕ.¤.", "àÁ.Â.", "¾.¤.", "ÁÔ.Â.", "¡.¤.", "Ê.¤.", "¡.Â.", "µ.¤.", "¾.Â.", "¸.¤." };

        XYChart c = new XYChart(750, 380, 15663086, 14540253, 0);
        string title = GetTitle() + (yearFrom == yearTo ? "ã¹»Õ ¾.È. " + yearFrom.ToString() : " µÑé§áµè»Õ ¾.È. " + yearFrom.ToString() + "-" + yearTo.ToString());
        c.addTitle(title, "Tahoma Bold", 12);

        c.setPlotArea(70, 80, 640, 230, c.gradientColor(0, 60, 0, 350, 16777215, 11189196), -1, Chart.Transparent, 1111);

        c.addLegend(30, 25, false, "Tahoma Bold", 8).setBackground(Chart.Transparent);
        c.xAxis().setLabels(labels);
        c.yAxis().setTickDensity(30);
        c.xAxis().setLabelStyle("Tahoma", 8, 001122, 90);
        c.yAxis().setLabelStyle("Tahoma", 8);
        c.yAxis().setLabelFormat("{value|0,}");
        c.xAxis().setWidth(2);
        c.yAxis().setWidth(2);
        c.yAxis().setTitle("¨Ó¹Ç¹", "Tahoma Bold", 10);
        c.xAxis().setTitle("à´×͹", "Tahoma Bold", 10);

        LineLayer layer = c.addLineLayer();
        layer.setLineWidth(1);
        AddData(layer, yearFrom - 543, yearTo - 543);
        vwChart.Image = c.makeWebImage(Chart.PNG);
        vwChart.ImageMap = c.getHTMLImageMap(GetReportPath() + "?type=" + Request["type"] + "&warehouse=" + this.cmbWarehouse.SelectedItem.Value.ToString() + "&producttype=" + this.cmbProductType.SelectedItem.Value.ToString() + "&productgroup=" + this.cmbProductGroup.SelectedItem.Value.ToString() + "&product=" + this.cmbProduct.SelectedItem.Value.ToString() + "&currentyear={xLabel}&yearfrom=" + yearFrom.ToString() + "&yearto=" + yearTo.ToString(), "",
            "title='»Õ {dataSetName} à´×͹ {xLabel}\r\n{value|,} ÃÒ¡Òà ({percent}%)'");
    }
Ejemplo n.º 21
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The data for the bar chart
            double[] data0 = { 100, 125, 245, 147, 67 };
            double[] data1 = { 85, 156, 179, 211, 123 };
            double[] data2 = { 97, 87, 56, 267, 157 };

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

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

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

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

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

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

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

            legendBox.setAlignment(Chart.TopRight);

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

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

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

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

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

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

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

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

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

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

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "",
                                                "title='{dataSetName} revenue on {xLabel}: US${value}K ({percent}%)'");
        }
Ejemplo n.º 22
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 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}'");
        }
Ejemplo 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 chart
            double[] data = { 50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58, 59,
                              73, 77, 84, 82, 80, 84, 89 };

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

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

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

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

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

            legendBox.setBackground(Chart.Transparent);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Output the chart
            viewer.Chart = c;

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

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

            c.setRoundedFrame();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Revenue of {dataSetName} in {xLabel}: US$ {value}M'");
        }
        private void LoadChart(DataTable dtCuocGoiTheoNgay)
        {
            if (dtCuocGoiTheoNgay.Rows.Count > 0)
            {
                double[]   arrCuocGoiTaxi         = new double[dtCuocGoiTheoNgay.Rows.Count];
                double[]   arrCuocGoiDonDuocKhach = new double[dtCuocGoiTheoNgay.Rows.Count];
                double[]   arrCuocGoiTruotHoan    = new double[dtCuocGoiTheoNgay.Rows.Count];
                double[]   arrCuocGoiKhongxe      = new double[dtCuocGoiTheoNgay.Rows.Count];
                double[]   arrCuocGoiMoiGioi      = new double[dtCuocGoiTheoNgay.Rows.Count];
                double[]   arrCuocGoiVangLai      = new double[dtCuocGoiTheoNgay.Rows.Count];
                DateTime[] lableVertical          = new DateTime[dtCuocGoiTheoNgay.Rows.Count];
                int        MaxCuocGoi             = 0;
                int        i = 0;
                foreach (DataRow dr in dtCuocGoiTheoNgay.Rows)
                {
                    //Ngay, TongCuocGoiTaxi,CuocGoiDonDuoc,CuocGoiTruotHoan ,CuocGoiKhongXe,CuocGoiMoiGioi,CuocGoiVangLai
                    arrCuocGoiTaxi[i]         = (int)dr["TongCuocGoiTaxi"];
                    arrCuocGoiDonDuocKhach[i] = (int)dr["CuocGoiDonDuoc"];
                    arrCuocGoiTruotHoan[i]    = (int)dr["CuocGoiTruotHoan"];
                    arrCuocGoiKhongxe[i]      = (int)dr["CuocGoiKhongXe"];
                    arrCuocGoiMoiGioi[i]      = (int)dr["CuocGoiMoiGioi"];
                    arrCuocGoiVangLai[i]      = (int)dr["CuocGoiVangLai"];
                    lableVertical[i]          = DateTime.Parse(dr["Ngay"].ToString().Substring(0, 10));
                    if (MaxCuocGoi < (int)dr["TongCuocGoiTaxi"])
                    {
                        MaxCuocGoi = (int)dr["TongCuocGoiTaxi"];
                    }

                    i++;
                }

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

                // 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 (0xcccccc)
                c.setPlotArea(50, 40, 430, 280, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
                //  c.setAntiAlias();



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

                // Add a title box to the chart using 15 pts Times Bold Italic font, on a
                // light blue (CCCCFF) background with glass effect. white (0xffffff) on
                // a dark red (0x800000) background, with a 1 pixel 3D border.
                c.addTitle("Biểu đồ cuộc gọi taxi ",
                           "Times New Roman Bold Italic", 15).setBackground(0xccccff, 0x000000,
                                                                            Chart.glassEffect());

                // Add a title to the y axis
                c.yAxis().setTitle("Số cuộc gọi");
                //c.yAxis().setLabels(lableVertical);
                // Set the labels on the x axis.
                c.xAxis().setTitle("Ngày");
                // c.addStepLineLayer();
                c.xAxis().setLabels(lableVertical, "{value|dd/mm}");


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

                // Add a title to the x axis
                // c.xAxis().setTitle("Jun 12, 2006");

                // Add a line layer to the chart
                //LineLayer layer = c.addLineLayer2();
                BarLayer layer = c.addBarLayer2(Chart.Stack, 8);
                // Set the default line width to 2 pixels
                //layer.setLineWidth(2);

                // Add the three data sets to the line layer. For demo purpose, we use a
                // dash line color for the last line
                // layer.addDataSet(arrCuocGoiTaxi , 0xff0000, "Gọi taxi");
                layer.addDataSet(arrCuocGoiDonDuocKhach, 0x00eea0, "Đón được");
                layer.addDataSet(arrCuocGoiTruotHoan, 0x333303, "Trượt hoãn");
                layer.addDataSet(arrCuocGoiKhongxe, 0x88ff0f, "Không xe");
                //layer.addDataSet(arrCuocGoiMoiGioi, 0xaa00ff, "Môi giới");
                // layer.addDataSet(arrCuocGoiVangLai, 0xcc00ff, "Vãng lai");

                // Enable bar label for the whole bar
                layer.setAggregateLabelStyle();

                // Enable bar label for each segment of the stacked bar
                layer.setDataLabelStyle();

                // output the chart
                viewer.Image = c.makeImage();
                viewer.Image.Save(Configuration.GetReportPath() + "\\BieuDo1.jpg");
                //include tool tip for the chart
                viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                    "title='[{dataSetName}] Ngày {xLabel}: {value} Cuộc gọi'");
            }
        }
Ejemplo n.º 26
0
        public static XYChart SetOptions(XYChart c, int width, int height, int fontSize, int yLabelWidth = 20, int bottomLabelHeight = 10, bool isShowLegendBox = true)
        {
            // 加入 Title
            //ChartDirector.TextBox tbTitle = c.addTitle("", "Arial Bold Italic", 15.0, 0);
            //tbTitle.getHeight();

            // 手動調整 x 軸的範圍
            //c.xAxis().setLinearScale(min.X, max.X);
            //c.xAxis().setRounding(false, false);
            //c.xAxis().setTickDensity(75);

            // 設定繪圖區大小
            int paddingWidth  = 15;
            int paddingHeight = 10;

            yLabelWidth       += fontSize;
            bottomLabelHeight += fontSize;

            int paddingLeft_X = paddingWidth + yLabelWidth;
            int paddingTop_Y  = paddingHeight;
            int plotWidth     = width - paddingLeft_X - paddingWidth;
            int plotHeight    = height - paddingTop_Y - paddingHeight;

            c.setPlotArea(paddingLeft_X, paddingTop_Y, plotWidth, plotHeight);

            // 設定 Legend
            if (isShowLegendBox)
            {
                LegendBox lb = c.addLegend(paddingLeft_X, paddingHeight / 2, false, "", fontSize);
                lb.setBackground(Chart.Transparent);

                c.layoutLegend();

                int lbHeight = lb.getHeight();

                if (lbHeight < height * 0.4)
                {
                    paddingTop_Y = lbHeight + paddingHeight / 2;
                    plotHeight  -= lbHeight;
                }
                else
                {
                    // hide LegendBox
                    lb.setPos(width * 10, height * 10);
                    plotHeight -= 8;
                }
            }

            // 重新設定繪圖區大小
            c.setPlotArea(paddingLeft_X, paddingTop_Y, plotWidth, plotHeight - bottomLabelHeight);

            // Enable clipping mode to clip the part of the data that is outside the plot area.
            c.setClipping();

            //c.setBackground(0xFFFFFF);
            //c.getPlotArea().setBackground(0xFFFFEE);
            c.setBackground(0xE5E5E5);
            c.setBorder(0x333333);

            return(c);
        }
Ejemplo n.º 27
0
        private void LoadChart(DataTable dtCuocGoiTheoCa)
        {
            try
            {
                if (dtCuocGoiTheoCa.Rows.Count > 0)
                {
                    double[] arrCuocGoiTaxi         = new double[dtCuocGoiTheoCa.Rows.Count];
                    double[] arrCuocGoiDonDuocKhach = new double[dtCuocGoiTheoCa.Rows.Count];
                    double[] arrCuocGoiTruotHoan    = new double[dtCuocGoiTheoCa.Rows.Count];
                    double[] arrCuocGoiKhongxe      = new double[dtCuocGoiTheoCa.Rows.Count];
                    double[] arrCuocGoiMoiGioi      = new double[dtCuocGoiTheoCa.Rows.Count];
                    double[] arrCuocGoiVangLai      = new double[dtCuocGoiTheoCa.Rows.Count];
                    string[] lableVertical          = new string[dtCuocGoiTheoCa.Rows.Count];
                    int      MaxCuocGoi             = 0;
                    int      i = 0;
                    foreach (DataRow dr in dtCuocGoiTheoCa.Rows)
                    {
                        // Ca , Tu, Den,TongTaxi,TongGoiLai,TOngKhieuNai,TongGoiKhac,Tong,TongGoiNho,TongDonDuoc,PhanTramDonDuoc, TongTruotHoan,,
                        // TongKhongXe,PhanTramKhongXe, TongKhongXacDinh , PhanTramKhongXacDinh, TongCuocTaxiMoiGioi
                        if (dr["TongTaxi"] != null && dr["TongTaxi"].ToString().Length > 0)
                        {
                            arrCuocGoiTaxi[i] = Convert.ToInt32(dr["TongTaxi"].ToString());
                        }
                        else
                        {
                            arrCuocGoiTaxi[i] = 0;
                        }
                        if (dr["TongDonDuoc"] != null && dr["TongDonDuoc"].ToString().Length > 0)
                        {
                            arrCuocGoiDonDuocKhach[i] = (int)dr["TongDonDuoc"];
                        }
                        else
                        {
                            arrCuocGoiDonDuocKhach[i] = 0;
                        }
                        if (dr["TongTruotHoan"] != null && dr["TongTruotHoan"].ToString().Length > 0)
                        {
                            arrCuocGoiTruotHoan[i] = (int)dr["TongTruotHoan"];
                        }
                        else
                        {
                            arrCuocGoiTruotHoan[i] = 0;
                        }
                        if (dr["TongKhongXe"] != null && dr["TongKhongXe"].ToString().Length > 0)
                        {
                            arrCuocGoiKhongxe[i] = (int)dr["TongKhongXe"];
                        }
                        else
                        {
                            arrCuocGoiKhongxe[i] = 0;
                        }
                        if (dr["TongCuocTaxiMoiGioi"] != null && dr["TongCuocTaxiMoiGioi"].ToString().Length > 0)
                        {
                            arrCuocGoiMoiGioi[i] = (int)dr["TongCuocTaxiMoiGioi"];
                        }
                        else
                        {
                            arrCuocGoiMoiGioi[i] = 0;
                        }
                        arrCuocGoiVangLai[i] = arrCuocGoiTaxi[i] - arrCuocGoiMoiGioi[i];
                        lableVertical[i]     = "Ca " + dr["Ca"].ToString();
                        i++;
                    }

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

                    // 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 (0xcccccc)
                    c.setPlotArea(50, 40, 380, 225, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
                    //  c.setAntiAlias();



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

                    // Add a title box to the chart using 15 pts Times Bold Italic font, on a
                    // light blue (CCCCFF) background with glass effect. white (0xffffff) on
                    // a dark red (0x800000) background, with a 1 pixel 3D border.
                    c.addTitle("Biểu đồ cuộc gọi taxi theo ca",
                               "Times New Roman Bold Italic", 15).setBackground(0xccccff, 0x000000,
                                                                                Chart.glassEffect());

                    // Add a title to the y axis
                    c.yAxis().setTitle("Số cuộc gọi");
                    //c.yAxis().setLabels(lableVertical);
                    // Set the labels on the x axis.
                    c.xAxis().setTitle("Ngày " + string.Format("{0:dd/MM/yyyy}", calTuNgay.Value));
                    // c.addStepLineLayer();
                    c.xAxis().setLabels(lableVertical);


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

                    // Add a title to the x axis
                    // c.xAxis().setTitle("Jun 12, 2006");

                    // Add a line layer to the chart
                    //LineLayer layer = c.addLineLayer2();
                    BarLayer layer = c.addBarLayer2(Chart.Stack, 8);
                    // Set the default line width to 2 pixels
                    //layer.setLineWidth(2);

                    // Add the three data sets to the line layer. For demo purpose, we use a
                    // dash line color for the last line
                    // layer.addDataSet(arrCuocGoiTaxi , 0xff0000, "Gọi taxi");
                    layer.addDataSet(arrCuocGoiDonDuocKhach, 0x008800, "Đón được");
                    layer.addDataSet(arrCuocGoiTruotHoan, c.dashLineColor(0x3333ff, Chart.DashLine),
                                     "Trượt hoãn");
                    layer.addDataSet(arrCuocGoiKhongxe, 0xff00ff, "Không xe");
                    //layer.addDataSet(arrCuocGoiMoiGioi, 0xaa00ff, "Môi giới");
                    // layer.addDataSet(arrCuocGoiVangLai, 0xcc00ff, "Vãng lai");

                    // Enable bar label for the whole bar
                    layer.setAggregateLabelStyle();

                    // Enable bar label for each segment of the stacked bar
                    layer.setDataLabelStyle();

                    // output the chart
                    ChartVungKieu1.Image = c.makeImage();
                    // ChartVungKieu1.Image.Save(Configuration.GetReportPath() + "\\BieuDo1.jpg");
                    //include tool tip for the chart
                    ChartVungKieu1.ImageMap = c.getHTMLImageMap("clickable", "",
                                                                "title='[{dataSetName}] {xLabel}: {value} Cuộc gọi'");
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 28
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 = { 600, 800, 1200, 1500, 1800, 1900, 2000, 1950 };
            double[] data1 = { 300, 450, 500, 1000, 1500, 1600, 1650, 1600 };

            // The labels for the chart
            string[] labels = { "1995", "1996", "1997", "1998", "1999", "2000",
                                "2001", "2002" };

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

            // Set the plotarea at (60, 45) and of size 360 x 170 pixels, using white
            // (0xffffff) as the plot area background color. Turn on both horizontal
            // and vertical grid lines with light grey color (0xc0c0c0)
            c.setPlotArea(60, 45, 360, 170, 0xffffff, -1, -1, 0xc0c0c0, -1);

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

            // Add a title to the chart using 12 pts Arial Bold/white font. Use a 1 x
            // 2 bitmap pattern as the background.
            c.addTitle("Information Resource Usage", "Arial Bold", 12, 0xffffff
                       ).setBackground(c.patternColor(new int[] { 0x000040, 0x000080 }, 2));

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

            // Reserve 8 pixels margins at both side of the x axis to avoid the first
            // and last symbols drawing outside of the plot area
            c.xAxis().setMargin(8, 8);

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

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

            // Add the first line using small_user.png as the symbol.
            layer.addDataSet(data0, 0xcf4040, "Users").setDataSymbol2(
                "small_user.png");

            // Add the first line using small_computer.png as the symbol.
            layer.addDataSet(data1, 0x40cf40, "Computers").setDataSymbol2(
                "small_computer.png");

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

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Number of {dataSetName} at {xLabel}: {value}'");
        }
Ejemplo n.º 29
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // 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.Image = c.makeWebImage(Chart.PNG);

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "",
                                                "title='[{dataSetName}] Alpha = {x}, Beta = {value}'");
        }
Ejemplo n.º 30
0
        public void createChartCenter(WinChartViewer viewer, string img)
        {
            // The data for the chart
            //double[] data0;
            //double[] data1;
            //double[] data2;
            //double[] data3;
            //string[] labels;
            //int idate;
            ////double[] data0 = { 185, 176, 135, 144,99, 120, 175, 128, 175, 142, 172, 120, 175, 123, 120, 185, 145, 185, 152, 142, 156, 156, 175, 185, 175, 148, 142 };
            ////double[] data1 = { 145, 153, 123, 175, 120, 105, 142, 147, 145, 184, 124, 132, 102, 125, 165, 156, 125, 156, 125, 143, 142, 148, 129, 145, 169, 136, 187 };
            ////double[] data2 = { 135, 120, 145, 126, 100, 145, 120, 120, 156, 129, 168, 185, 165, 135, 158, 125, 126, 125, 163, 165, 132, 143, 138, 136, 185, 159, 144 };
            ////double[] data3 = { 150, 110, 187, 173, 85, 100, 135, 156, 155, 120, 127, 122, 125, 145, 134, 185, 132, 185, 128, 123, 185, 129, 136, 162, 125, 189, 165 };
            //if (_dt_grid != null && _dt_grid.Rows.Count > 0)
            //{
            //    idate = _dt_grid.Rows.Count;
            //    data0 = new double[idate];
            //    data1 = new double[idate];
            //    data2 = new double[idate];
            //    data3 = new double[idate];
            //    labels = new string[idate];
            //    for (int i = 0; i < idate - 1; i++)
            //    {
            //        data0[i] = Convert.ToDouble(_dt_grid.Rows[i]["F1"].ToString());
            //        data1[i] = Convert.ToDouble(_dt_grid.Rows[i]["F2"].ToString());
            //        data2[i] = Convert.ToDouble(_dt_grid.Rows[i]["F3"].ToString());
            //        data3[i] = Convert.ToDouble(_dt_grid.Rows[i]["F4"].ToString());
            //        labels[i] = _dt_grid.Rows[i]["DD"].ToString();
            //    }
            //}
            //else return;

            // 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(viewer.Width, viewer.Height);

            c.setBorder(10);
            // 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, c.getWidth() - 110, c.getHeight() - 150, 0xf4f4f4,
                          -1, Chart.Transparent, c.dashLineColor(0xffffff, Chart.Transparent));
            // , Chart.Transparent, -1, 0xffffff, 0xffffff
            // Add a legend box at (55, 32) (top of the chart) with horizontal
            // layout. Use 9 pts 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 15 pts 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=star.png*><*img=star.png*> " +
            //    "Performance Enhancer <*img=star.png*><*img=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=clock.png*>  Elapsed Time (hour)" +
            //    "<*/*>");
            c.yAxis().setLinearScale(0, _max_chart + 50);
            // Set the axes width to 2 pixels
            c.xAxis().setWidth(2);
            //c.yAxis().setWidth(2);

            c.xAxis().setTitle(" (Date)  ", "Arial Bold ", 15);


            c.addLegend(55, 5, false, "Arial Bold", 13).setBackground(
                Chart.Transparent);

            // Add a spline layer to the chart

            c.yAxis().setLabelStyle("Calibri Bold", 12);
            c.xAxis().setLabelStyle("Calibri Bold", 11);
            c.yAxis().setWidth(2);

            c.setNumberFormat(',');

            SplineLayer layer = c.addSplineLayer();

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

            // Add a data set to the spline layer, using blue (0000c0) as the line
            // color, with yellow (ffff00) circle symbols.
            layer.addDataSet(data0, 0x0000c0, "Fatory 1").setDataSymbol(
                Chart.NoShape, 20, 0xffff00);

            // Add a data set to the spline layer, using brown (982810) as the line
            // color, with pink (f040f0) diamond symbols.
            layer.addDataSet(data1, 0x982810, "Fatory 2").setDataSymbol(
                Chart.NoShape, 20, 0xf040f0);

            layer.addDataSet(data2, 0xdb6e25, "Fatory 3").setDataSymbol(
                Chart.NoShape, 20, 0x0050f0);

            layer.addDataSet(data3, 0x004000, "Fatory 4").setDataSymbol(
                Chart.NoShape, 20, 0xf04000);

            // 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='{dataSetName} at t = {xLabel} hour: {value} KJ/liter'");
        }
Ejemplo n.º 31
0
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WPFChartViewer viewer, int chartIndex)
        {
            // The data for the bars and the marks
            double[] barData  = { 100, 125, 245, 147, 67, 96, 160, 145, 97, 167, 220, 125 };
            double[] markData = { 85, 156, 220, 120, 80, 110, 140, 130, 111, 180, 175, 100 };

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

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

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

            // Add a title to the chart using 15 points Arial Italic font. Set top/bottom margins to
            // 12 pixels.
            ChartDirector.TextBox title = c.addTitle("Bars with Marks Demonstration",
                                                     "Arial Italic", 15);
            title.setMargin2(0, 0, 12, 12);

            // Tentatively set the plotarea to 50 pixels from the left edge to allow for the y-axis,
            // and to just under the title. Set the width to 65 pixels less than the chart width,
            // and the height to reserve 90 pixels at the bottom for the x-axis and the legend box.
            // Use pale blue (e8f0f8) background, transparent border, and grey (888888) dotted
            // horizontal grid lines.
            c.setPlotArea(50, title.getHeight(), c.getWidth() - 65, c.getHeight() - title.getHeight(
                              ) - 90, 0xe8f0f8, -1, Chart.Transparent, c.dashLineColor(0x888888, Chart.DotLine));

            // Add a legend box where the bottom-center is anchored to the 15 pixels above the
            // bottom-center of the chart. Use horizontal layout and 8 points Arial font.
            LegendBox legendBox = c.addLegend(c.getWidth() / 2, c.getHeight() - 15, false, "Arial",
                                              8);

            legendBox.setAlignment(Chart.BottomCenter);

            // Set the legend box background and border to pale blue (e8f0f8) and bluish grey
            // (445566)
            legendBox.setBackground(0xe8f0f8, 0x445566);

            // Use rounded corners of 5 pixel radius for the legend box
            legendBox.setRoundedCorners(5);

            // Use line style legend key
            legendBox.setLineStyleKey();

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

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

            // Add a box-whisker layer with just the middle mark visible for the marks. Use red
            // (ff0000) color for the mark, with a line width of 2 pixels and 10% horizontal gap
            BoxWhiskerLayer markLayer = c.addBoxWhiskerLayer(null, null, null, null, markData, -1,
                                                             0xff0000);

            markLayer.setLineWidth(2);
            markLayer.setDataGap(0.1);

            // Add the legend key for the mark line
            legendBox.addKey("Target", 0xff0000, 2);

            // Tool tip for the mark layer
            markLayer.setHTMLImageMap("", "", "title='Target at {xLabel}: {med}'");

            // Add a blue (0066cc) bar layer using the given data.
            BarLayer barLayer = c.addBarLayer(barData, 0x0066cc, "Actual");

            // Use soft lighting effect for the bars with light direction from left.
            barLayer.setBorderColor(Chart.Transparent, Chart.softLighting(Chart.Left));

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

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

            // Output the chart
            viewer.Chart = c;

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable");
        }
Ejemplo n.º 32
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 XY points for the bubble chart. The bubble chart has independent bubble size on
            // the X and Y direction.
            double[] dataX0  = { 1000, 1500, 1700 };
            double[] dataY0  = { 25, 20, 65 };
            double[] dataZX0 = { 500, 200, 600 };
            double[] dataZY0 = { 15, 30, 20 };

            double[] dataX1  = { 500, 1000, 1300 };
            double[] dataY1  = { 35, 50, 75 };
            double[] dataZX1 = { 800, 300, 500 };
            double[] dataZY1 = { 8, 27, 25 };

            double[] dataX2  = { 150, 300 };
            double[] dataY2  = { 20, 60 };
            double[] dataZX2 = { 160, 400 };
            double[] dataZY2 = { 30, 20 };

            // 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 a light grey border
            // (0xc0c0c0). Turn on both horizontal and vertical grid lines with light grey color
            // (0xc0c0c0)
            c.setPlotArea(55, 65, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1);

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

            // Add a title to the chart using 18pt Times Bold Itatic font.
            c.addTitle("Plasma Battery Comparison", "Times New Roman Bold Italic", 18);

            // Add titles to the axes using 12pt Arial Bold Italic font
            c.yAxis().setTitle("Operating Current", "Arial Bold Italic", 12);
            c.xAxis().setTitle("Operating Voltage", "Arial Bold Italic", 12);

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

            // Add (dataX0, dataY0) as a standard scatter layer, and also as a "bubble" scatter
            // layer, using circles as symbols. The "bubble" scatter layer has symbol size modulated
            // by (dataZX0, dataZY0) using the scale on the x and y axes.
            c.addScatterLayer(dataX0, dataY0, "Vendor A", Chart.CircleSymbol, 9, 0xff3333, 0xff3333)
            ;
            c.addScatterLayer(dataX0, dataY0, "", Chart.CircleSymbol, 9, unchecked ((int)0x80ff3333),
                              unchecked ((int)0x80ff3333)).setSymbolScale(dataZX0, Chart.XAxisScale, dataZY0,
                                                                          Chart.YAxisScale);

            // Add (dataX1, dataY1) as a standard scatter layer, and also as a "bubble" scatter
            // layer, using squares as symbols. The "bubble" scatter layer has symbol size modulated
            // by (dataZX1, dataZY1) using the scale on the x and y axes.
            c.addScatterLayer(dataX1, dataY1, "Vendor B", Chart.SquareSymbol, 7, 0x3333ff, 0x3333ff)
            ;
            c.addScatterLayer(dataX1, dataY1, "", Chart.SquareSymbol, 9, unchecked ((int)0x803333ff),
                              unchecked ((int)0x803333ff)).setSymbolScale(dataZX1, Chart.XAxisScale, dataZY1,
                                                                          Chart.YAxisScale);

            // Add (dataX2, dataY2) as a standard scatter layer, and also as a "bubble" scatter
            // layer, using diamonds as symbols. The "bubble" scatter layer has symbol size
            // modulated by (dataZX2, dataZY2) using the scale on the x and y axes.
            c.addScatterLayer(dataX2, dataY2, "Vendor C", Chart.DiamondSymbol, 9, 0x00ff00, 0x00ff00
                              );
            c.addScatterLayer(dataX2, dataY2, "", Chart.DiamondSymbol, 9,
                              unchecked ((int)0x8033ff33), unchecked ((int)0x8033ff33)).setSymbolScale(dataZX2,
                                                                                                       Chart.XAxisScale, dataZY2, Chart.YAxisScale);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Voltage = {x} +/- {={zx}/2} V, Current = {value} +/- {={zy}/2} A'");
        }
Ejemplo n.º 33
0
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, int chartIndex)
        {
            // Data for the chart
            double[] data0 = { 1700, 3900, 2900, 3800, 4100, 4600, 2900, 4100, 4400, 5700, 5900,
                               5200, 3700, 3400, 5100, 5600, 5600, 6000, 7000, 7600, 6300, 6700, 7500, 6400, 8800 };
            double[] data1 = { 500, 550, 670, 990, 820, 730, 800, 720, 730, 790, 860, 800, 840, 680,
                               740, 890, 680, 790, 730, 770, 840, 820, 800, 840, 670 };
            double[] data2 = { 46, 68, 35, 33, 38, 20, 12, 18, 15, 23, 30, 24, 28, 15, 21, 26, 46,
                               42, 38, 25, 23, 32, 24, 20, 25 };
            double[] data3 = { 0.84, 0.82, 0.82, 0.38, 0.25, 0.52, 0.54, 0.52, 0.38, 0.51, 0.46,
                               0.29,  0.5, 0.55, 0.47, 0.34, 0.52, 0.33, 0.21,  0.3, 0.25, 0.15,0.18, 0.22, 0.14 };

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

            // Create a XYChart object of size 600 x 360 pixels. Use a vertical gradient color from
            // sky blue (aaccff) to white (ffffff) as background. Set border to grey (888888). Use
            // rounded corners. Enable soft drop shadow.
            XYChart c = new XYChart(600, 360);

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

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

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

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

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

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

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

            // Add a title to the x-axis
            c.xAxis().setTitle("Hour of Day");

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

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

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

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

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

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

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

            layer0.setLineWidth(2);

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

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

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

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

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

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

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} at hour {xLabel} = {value}'");
        }
Ejemplo n.º 34
0
        protected void Generate_Forecast(int productid)
        {
            Product info = ControllerManager.Product.GetById(productid);
            IList <TransactionHistoryWeekly> history = ControllerManager.TransactionHistoryWeekly.GetInfo(info.Id, Config.CurrentWeek, Config.CurrentDate.Year, 1);

            this.Label12.Text = info.ProductCode.ToString();
            this.Label3.Text  = info.Description.ToString();
            this.Label5.Text  = info.Provider.Name;
            this.Label7.Text  = (history[0].Stock + history[0].Purchase - history[0].Sale).ToString();
            this.Label9.Text  = info.RepositionLevel.ToString();
            this.Label11.Text = info.RepositionPoint.ToString();
            this.Label16.Text = info.LeadTime.ToString();
            this.Label1.Text  = info.Safety.ToString();

            IList <Forecast> forecast = ControllerManager.Forecast.GetForecast(info, Config.CurrentWeek, Config.CurrentDate.Year);

            this.GridView1.DataSource = forecast;
            this.GridView1.DataBind();

            //------GRAFICO-------------------------------------------
            if (forecast.Count > 0)
            {
                string[] Titulos = new string[forecast.Count];
                double[] Stock   = new double[forecast.Count];
                double[] Ventas  = new double[forecast.Count];
                double[] Compras = new double[forecast.Count];
                for (int cont = 0; cont < forecast.Count; cont++)
                {
                    Stock.SetValue(forecast[cont].FinalStock, cont);
                    Ventas.SetValue(forecast[cont].Sale, cont);
                    Compras.SetValue(forecast[cont].Purchase, cont);
                    Titulos.SetValue(forecast[cont].Week.ToString(), cont);
                }

                XYChart c = new XYChart(480, 300, 0xeeeeff, 0x000000, 3);
                c.setPlotArea(50, 70, 410, 180, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
                c.addLegend(50, 50, false, "Arial Bold", 8).setBackground(Chart.Transparent);
                c.addTitle("Graficos Estadisticos", "Verdana Bold", 12).setBackground(0xccccff, 0x000000, Chart.glassEffect());
                c.xAxis().setTitle("Semanas");
                c.yAxis().setTitle("Cantidad");

                Mark actual = c.xAxis().addMark(10, 0x000000, "SEMANA ACTUAL");
                actual.setLineWidth(1);
                actual.setAlignment(Chart.TopRight);
                actual.setFontAngle(90);
                Mark actual0 = c.xAxis().addMark(10 + info.LeadTime, 0x000000, "LEADTIME");
                actual0.setLineWidth(1);
                actual0.setAlignment(Chart.TopLeft);
                actual0.setFontAngle(90);
                LineLayer linea = c.addLineLayer();
                linea.setLineWidth(3);
                linea.addDataSet(Stock, 0x000000, "Stock Final");
                linea.addDataSet(Ventas, 0x00ff00, "Ventas");
                linea.addDataSet(Compras, 0x0000FF, "Compras");
                c.addAreaLayer(Stock, c.yZoneColor(forecast[10].Safety, unchecked ((int)0x50ff3c3c), unchecked ((int)0x500080c0)));
                c.xAxis().addZone(10, 10 + info.LeadTime, 0xdcdcdc);
                c.xAxis().setLabels(Titulos);
                c.xAxis().setLabelStep(2);
                WebChartViewer1.Image    = c.makeWebImage(Chart.PNG);
                WebChartViewer1.ImageMap = c.getHTMLImageMap("", "", "title='Semana {xLabel}: {value}'");
                WebChartViewer1.Visible  = true;
            }
        }
        //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 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}%)'");
        }
        //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 };
            string[] labels = { "Mon", "Tue", "Wed", "Thur", "Fri" };

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

            // Add a title to the chart using 18pt Times Bold Italic font
            c.addTitle("Average Weekly Network Load", "Times New Roman Bold Italic", 18);

            // Set the plotarea at (50, 55) and of 440 x 280 pixels in size. Use a vertical gradient
            // color from grey (888888) to black (000000) as background. Set border and grid lines
            // to white (ffffff).
            c.setPlotArea(50, 55, 440, 280, c.linearGradientColor(0, 55, 0, 335, 0x888888, 0x000000
                                                                  ), -1, 0xffffff, 0xffffff);

            // Add a legend box at (50, 25) using horizontal layout. Use 10pt Arial Bold as font,
            // with transparent background.
            c.addLegend(50, 25, false, "Arial Bold", 10).setBackground(Chart.Transparent);

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

            // Draw the ticks between label positions (instead of at label positions)
            c.xAxis().setTickOffset(0.5);

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

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

            // Add axis title
            c.yAxis().setTitle("Throughput (MBytes Per Hour)");

            // Add a multi-bar layer with 3 data sets and 4 pixels 3D depth
            BarLayer layer = c.addBarLayer2(Chart.Side, 4);

            layer.addDataSet(data0, 0x66aaee, "Server #1");
            layer.addDataSet(data1, 0xeebb22, "Server #2");
            layer.addDataSet(data2, 0xcc0000, "Server #3");

            // Set bar border to transparent. Use bar gradient lighting with light intensity from
            // 0.75 to 1.75.
            layer.setBorderColor(Chart.Transparent, Chart.barLighting(0.75, 1.75));

            // Configure the bars within a group to touch each others (no gap)
            layer.setBarGap(0.2, Chart.TouchBar);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} on {xLabel}: {value} MBytes/hour'");
        }
Ejemplo n.º 37
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("Real-Time Controller Responses", "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, "Alpha");
            layer.addDataSet(viewPortDataSeriesB, 0x0000ff, "Beta");

            //================================================================================
            // 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;
        }
Ejemplo n.º 38
0
    private void SetYearlyGraph()
    {
        int yearFrom = Convert.ToInt32((txtYearFrom.Text.Trim() == "" ? "0" : txtYearFrom.Text.Trim())) - 543;
        int yearTo = Convert.ToInt32((txtYearTo.Text.Trim() == "" ? "0" : txtYearTo.Text.Trim())) - 543;
        if (yearFrom < 0)
            yearFrom = 0;
        if (yearTo < 0)
            yearTo = 0;
        int tmp = yearFrom;
        if (yearFrom > yearTo)
        {
            yearFrom = yearTo;
            yearTo = tmp;
        }
        yearFrom += 543;
        yearTo += 543;

        string[] labels = { "�.�.", "�.�.", "��.�.", "��.�.", "�.�.", "��.�.", "�.�.", "�.�.", "�.�.", "�.�.", "�.�.", "�.�." };

        XYChart c = new XYChart(750, 380, 15663086, 14540253, 0);
        string title = GetTitle() + (yearFrom == yearTo ? "㹻� �.�. " + yearFrom.ToString() : " ������ �.�. " + yearFrom.ToString() + "-" + yearTo.ToString());
        c.addTitle(title, "Tahoma Bold", 12);

        c.setPlotArea(70, 80, 640, 230, c.gradientColor(0, 60, 0, 350, 16777215, 11189196), -1, Chart.Transparent, 1111);

        c.addLegend(30, 25, false, "Tahoma Bold", 8).setBackground(Chart.Transparent);
        c.xAxis().setLabels(labels);
        c.yAxis().setTickDensity(30);
        c.xAxis().setLabelStyle("Tahoma", 8, 001122, 90);
        c.yAxis().setLabelStyle("Tahoma", 8);
        c.yAxis().setLabelFormat("{value|0,}");
        c.xAxis().setWidth(2);
        c.yAxis().setWidth(2);
        c.yAxis().setTitle("�ӹǹ", "Tahoma Bold", 10);
        c.xAxis().setTitle("��͹", "Tahoma Bold", 10);

        LineLayer layer = c.addLineLayer();
        layer.setLineWidth(1);
        AddData(layer, yearFrom - 543, yearTo - 543);
        vwChart.Image = c.makeWebImage(Chart.PNG);
    }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // 4 data points to represent the cash flow for the Q1 - Q4
            double[] data = { 230, -140, 220, 330 };

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "", "title='{xLabel}: {={top}-{bottom}} millions'");
        }
Ejemplo n.º 40
0
        public byte[] CreateBar(double[] dateItem,
                                    string[] labels, string title, string bottom_text, string left_text, string scaleFromat)
        {
            string font_1 = "微軟正黑體";
            string font_2 = "新細明體";

            int CanvasWidth = CommWebSetup.Chart_Canvas_Width;
            int DiagramWidth = CommWebSetup.Chart_Diagram_Width;

            XYChart xyCht = new XYChart(CanvasWidth, CommWebSetup.Chart_Canvas_Height, 0xffffff, 0xffffff, 0); //設定畫布區大小
            //parm 5:奇數列顏色
            //parm 6:偶數列顏色
            //parm 7:外框顏色
            xyCht.setPlotArea(60, 72, DiagramWidth, CommWebSetup.Chart_Diagram_Height, 0xffffff, 0xffffff, 0xffffff, 0x999999, 0xffffff); //繪制圖表的位置及大小

            xyCht.setRoundedFrame();

            TextBox getTitleText = xyCht.addTitle(title, CommWebSetup.Chart_Title_FontFamily, CommWebSetup.Chart_Title_FontSize, CommWebSetup.Chart_Title_FontColor, 0xffffff);
            getTitleText.setHeight(CommWebSetup.Chart_Title_Height);
            getTitleText.setAlignment(Chart.Center);

            //設定上方資訊綜合區
            LegendBox legendBox = xyCht.addLegend(72, getTitleText.getHeight(), false, font_1, 10);
            legendBox.setAlignment(Chart.TopLeft);
            legendBox.setBackground(Chart.Transparent, Chart.Transparent);

            //左側處理
            TextBox getY = xyCht.yAxis().setTitle(left_text, font_2, 14);
            getY.setFontAngle(0, true);
            xyCht.yAxis().setWidth(2);
            getY.setHeight(CommWebSetup.Chart_Diagram_Height);

            var getScaleText = xyCht.yAxis().setLabelStyle(font_2, 9);

            if (scaleFromat != null)
            {
                xyCht.yAxis().setLabelFormat(scaleFromat); //設定左邊刻度格式
                //xyCht.yAxis().setLabelFormat("{value}度");
            }

            //底部處理
            var getBottomText = xyCht.xAxis().setTitle(bottom_text, font_1, 14);
            var getBottomlabel = xyCht.xAxis().setLabels(labels);
            getBottomlabel.setFontSize(9);
            getBottomlabel.setFontStyle(font_2);
            //xyCht.xAxis().setLabelStep(3); //設定Label間隔(橫向) 如果Label太密集可在此設定
            var col1 = Convert.ToInt32("EA8D8D", 16);
            var col2 = Convert.ToInt32("FFE699", 16);
            var col3 = Convert.ToInt32("9DC3E6", 16);
            var col4 = Convert.ToInt32("70AD47", 16);
            var col5 = Convert.ToInt32("ED7D31", 16);

            var colors = new int[] { col1, col2, col3, col4, col5 };
            //var names = new string[] { "紅一", "紅二", "紅三", "紅四", "紅五" };

            var layer = xyCht.addBarLayer3(dateItem, colors);
            layer.setAggregateLabelStyle("Arial", 8);
            layer.setBarWidth(32);

            return xyCht.makeChart(Chart.PNG);
        }
Ejemplo n.º 41
0
        //
        // Draw the chart.
        //
        private void drawChart(WPFChartViewer 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));

                // Extract the visible data
                if (timeStamps[endIndex] >= viewPortStartDate)
                {
                    int noOfPoints = endIndex - startIndex + 1;
                    viewPortTimeStamps  = (double[])Chart.arraySlice(timeStamps, startIndex, noOfPoints);
                    viewPortDataSeriesA = (double[])Chart.arraySlice(dataSeriesA, startIndex, noOfPoints);
                    viewPortDataSeriesB = (double[])Chart.arraySlice(dataSeriesB, startIndex, noOfPoints);
                }

                // Keep track of the latest available data at chart plotting time
                trackLineEndPos = 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(640, 350);

            // Set the plotarea at (20, 30) with width 41 pixels less than chart width, and height 50 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(21, 30, c.getWidth() - 41, c.getHeight() - 50, c.linearGradientColor(0, 30, 0,
                                                                                               c.getHeight() - 20, 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("   Real-Time Chart with Viewport Control", "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, 0x336699);

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

            // Configure the y-axis label to be inside the plot area and above the horizontal grid lines
            c.yAxis().setLabelGap(-1);
            c.yAxis().setLabelAlignment(1);
            c.yAxis().setMargin(20);

            // Configure the x-axis labels to be to the left of the vertical grid lines
            c.xAxis().setLabelAlignment(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, 0xff0000, "Alpha");
            layer.addDataSet(viewPortDataSeriesB, 0x00cc00, "Beta");

            //================================================================================
            // 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(40);

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

            // Set the auto-scale margin to 0.05, and the zero affinity to 0.6
            c.yAxis().setAutoScale(0.05, 0.05, 0.6);

            //================================================================================
            // 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 (!WPFChartViewer1.IsInMouseMoveEvent)
            {
                trackLineLabel(c, trackLineIsAtEnd ? c.getWidth() : viewer.PlotAreaMouseX);
            }

            viewer.Chart = c;
        }
Ejemplo n.º 42
0
    private void SetMonthlyGraph()
    {
        int yearFrom = Convert.ToInt32((txtYearFrom.Text.Trim() == "" ? "0" : txtYearFrom.Text.Trim())) - 543;
        int yearTo = Convert.ToInt32((txtYearTo.Text.Trim() == "" ? "0" : txtYearTo.Text.Trim())) - 543;
        int currentmonth = 0;

        if (yearFrom < 0)
            yearFrom = 0;
        if (yearTo < 0)
            yearTo = 0;
        int tmp = yearFrom;
        if (yearFrom > yearTo)
        {
            yearFrom = yearTo;
            yearTo = tmp;
        }
        yearFrom += 543;
        yearTo += 543;

        switch (Request["currentyear"])
        {
            case "Á.¤.":
                currentmonth = 1;
                break;

            case "¡.¾.":
                currentmonth = 2;
                break;

            case "ÁÕ.¤.":
                currentmonth = 3;
                break;

            case "àÁ.Â.":
                currentmonth = 4;
                break;

            case "¾.¤.":
                currentmonth = 5;
                break;

            case "ÁÔ.Â.":
                currentmonth = 6;
                break;

            case "¡.¤.":
                currentmonth = 7;
                break;

            case "Ê.¤.":
                currentmonth = 8;
                break;

            case "¡.Â.":
                currentmonth = 9;
                break;

            case "µ.¤.":
                currentmonth = 10;
                break;

            case "¾.Â.":
                currentmonth = 11;
                break;

            case "¸.¤.":
                currentmonth = 12;
                break;
        }
        this.lnkYear.Text = GetTitle() + (yearFrom == yearTo ? "ã¹»Õ ¾.È. " + yearFrom.ToString() : " µÑé§áµè»Õ ¾.È. " + yearFrom.ToString() + "-" + yearTo.ToString());
        this.lblMonth.Text = ">> à´×͹ " + Request["currentyear"].ToString();
        this.pnlMonth.Visible = true;
        string[] labels = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" };

        XYChart c = new XYChart(750, 380, 15663086, 14540253, 0);
        string title = GetTitle() + (yearFrom == yearTo ? "ã¹»Õ ¾.È. " + yearFrom.ToString() : " µÑé§áµè»Õ ¾.È. " + yearFrom.ToString() + "-" + yearTo.ToString());
        c.addTitle(title, "Tahoma Bold", 12);

        c.setPlotArea(70, 80, 640, 230, c.gradientColor(0, 60, 0, 350, 16777215, 11189196), -1, Chart.Transparent, 1111);

        c.addLegend(30, 25, false, "Tahoma Bold", 8).setBackground(Chart.Transparent);
        c.xAxis().setLabels(labels);
        c.yAxis().setTickDensity(30);
        c.xAxis().setLabelStyle("Tahoma", 8, 001122, 90);
        c.yAxis().setLabelStyle("Tahoma", 8);
        c.yAxis().setLabelFormat("{value|0,}");
        c.xAxis().setWidth(2);
        c.yAxis().setWidth(2);
        c.yAxis().setTitle("¨Ó¹Ç¹", "Tahoma Bold", 10);
        c.xAxis().setTitle("Çѹ·Õè", "Tahoma Bold", 10);

        LineLayer layer = c.addLineLayer();
        layer.setLineWidth(1);
        AddData(layer, yearFrom - 543, yearTo - 543, currentmonth);
        vwChart.Image = c.makeWebImage(Chart.PNG);
        vwChart.ImageMap = c.getHTMLImageMap("", "", "title='Çѹ·Õè {xLabel}\r\n{value|,} ÃÒ¡Òà ({percent}%)'");
        this.pnlChart.Visible = true;
    }
Ejemplo n.º 43
0
        public override void InitVisualization(StackPanel configDisplayPanel)
        {
            List<string>[] chartLabels = null;

            this.configDisplayPanel = configDisplayPanel;

            // Initialize chart
            // Get the Factor Labels
            chartLabels = GetConfigDisplayLabels();
            if (chartLabels == null)
            {
                return;
            }

            // Create a grid of pie charts
            Grid pieGrid = new Grid();
            pieGrid.Width = configDisplay.Width;
            pieGrid.Height = configDisplay.Height;
            pieGrid.HorizontalAlignment = HorizontalAlignment.Left;
            pieGrid.VerticalAlignment = VerticalAlignment.Top;

            // Tan border
            SolidColorBrush titleBorderBrush = new SolidColorBrush();
            titleBorderBrush.Color = Color.FromRgb(248, 245, 232);

            // Define the Columns
            for (int i = 0; i < chartLabels[0].Count + 1; i++)
            {
                ColumnDefinition colDef = new ColumnDefinition();
                if (i == 0)
                {
                    colDef.Width = GridLength.Auto;
                }
                pieGrid.ColumnDefinitions.Add(colDef);
            }

            // Add Title and legend rows
            RowDefinition rowDef = new RowDefinition();
            rowDef.Height = GridLength.Auto;
            pieGrid.RowDefinitions.Add(rowDef);

            rowDef = new RowDefinition();
            rowDef.Height = GridLength.Auto;
            pieGrid.RowDefinitions.Add(rowDef);

            // Define the Rows
            for (int i = 0; i < chartLabels[1].Count + 1; i++)
            {
                rowDef = new RowDefinition();
                if (i == chartLabels[1].Count)
                {
                    rowDef.Height = GridLength.Auto;
                }
                pieGrid.RowDefinitions.Add(rowDef);
            }

            Border border = null;

            // Add Title
            border = new Border();
            border.BorderBrush = titleBorderBrush;
            border.BorderThickness = new Thickness(4);
            TextBlock txt = new TextBlock();
            txt.Text = configDisplay.Name;
            txt.FontSize = 14;
            txt.HorizontalAlignment = HorizontalAlignment.Center;
            border.Child = txt;
            Grid.SetColumn(border, 0);
            Grid.SetRow(border, 0);
            Grid.SetColumnSpan(border, chartLabels[0].Count + 1);
            pieGrid.Children.Add(border);

            // Label highlight brush
            SolidColorBrush labelHighlightBrush = new SolidColorBrush();
            labelHighlightBrush.Color = Color.FromRgb(188, 201, 214);

            DockPanel dockPanel = null;

            // Add Labels
            for (int i = 0; i < chartLabels[0].Count; i++)
            {
                border = new Border();
                border.BorderBrush = Brushes.Black;
                border.BorderThickness = new Thickness(1);
                dockPanel = new DockPanel();
                dockPanel.Background = labelHighlightBrush;
                txt = new TextBlock();
                txt.Text = chartLabels[0][i];
                txt.HorizontalAlignment = HorizontalAlignment.Center;
                dockPanel.Children.Add(txt);
                border.Child = dockPanel;
                Grid.SetColumn(border, i + 1);
                Grid.SetRow(border, chartLabels[1].Count + 2);
                pieGrid.Children.Add(border);
            }

            for (int i = 0; i < chartLabels[1].Count; i++)
            {
                border = new Border();
                border.BorderBrush = Brushes.Black;
                border.BorderThickness = new Thickness(1);
                dockPanel = new DockPanel();
                dockPanel.Background = labelHighlightBrush;
                txt = new TextBlock();
                txt.Text = chartLabels[1][i];
                txt.VerticalAlignment = VerticalAlignment.Center;
                dockPanel.Children.Add(txt);
                border.Child = dockPanel;
                Grid.SetColumn(border, 0);
                Grid.SetRow(border, i + 2);
                pieGrid.Children.Add(border);
            }

            // Create the legend for the multi-pie chart
            {
                XYChart legend = new XYChart(300, 50);
                Image img = new Image();
                LegendBox legendBox = legend.addLegend(0, 0, false);
                dockPanel = new DockPanel();

                legendBox.setBackground(0xffffff, 0xffffff);

                for (int z = 0; z < chartLabels[2].Count - 1; z++)
                {
                    legendBox.addKey(chartLabels[2][z], pieChartColors[z]);
                }

                System.Drawing.Image imgWinForms = legend.makeImage();
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                MemoryStream ms = new MemoryStream();
                imgWinForms.Save(ms, ImageFormat.Bmp);
                ms.Seek(0, SeekOrigin.Begin);
                bi.StreamSource = ms;
                bi.EndInit();

                CroppedBitmap croppedBitmap = new CroppedBitmap(bi, new Int32Rect(0, 0, 300, 40));
                img.Source = croppedBitmap;
                img.Height = 40;
                img.Width = 300;
                img.HorizontalAlignment = HorizontalAlignment.Left;
                img.VerticalAlignment = VerticalAlignment.Center;

                Grid.SetColumn(dockPanel, 0);
                Grid.SetRow(dockPanel, 1);
                Grid.SetColumnSpan(dockPanel, chartLabels[0].Count + 1);
                dockPanel.Children.Add(img);
                pieGrid.Children.Add(dockPanel);
            }


            // Add Grid to config display panel
            configDisplayPanel.Children.Add(pieGrid);
        }