Esempio 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();
        }
 protected override Image DoCreateChartImage()
 {
     var chart = new XYChart(Parameters.ChartWidth, Parameters.ChartHeight);
     chart.setPlotArea(30, 20, (int)Math.Round(Parameters.ChartWidth - (Parameters.ChartWidth * 0.2)), (int)Math.Round(Parameters.ChartHeight - (Parameters.ChartHeight * 0.2)));
     chart.addLineLayer(Parameters.SeriaData.Select(p => (double)p.Key).ToArray());
     chart.xAxis().setLabelStep(3);
     return chart.makeImage();
 }
        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);
        }
Esempio n. 4
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // Sample data for the Box-Whisker chart. Represents the minimum, 1st quartile, medium, 3rd
            // quartile and maximum values of some quantities
            double[] Q0Data = { 40, 45, 40, 30, 20, 50, 25, 44 };
            double[] Q1Data = { 55, 60, 50, 40, 38, 60, 51, 60 };
            double[] Q2Data = { 62, 70, 60, 50, 48, 70, 62, 70 };
            double[] Q3Data = { 70, 80, 65, 60, 53, 78, 69, 76 };
            double[] Q4Data = { 80, 90, 75, 70, 60, 85, 80, 84 };

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

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

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

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

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

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

            // Add a Box Whisker layer using light blue 0x9999ff as the fill color and blue (0xcc) as the
            // line color. Set the line width to 2 pixels
            c.addBoxWhiskerLayer(Q3Data, Q1Data, Q4Data, Q0Data, Q2Data, 0x9999ff, 0x0000cc
                                 ).setLineWidth(2);

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "",
                                                "title='{xLabel}: min/med/max = {min}/{med}/{max}\nInter-quartile range: {bottom} to " +
                                                "{top}'");
        }
Esempio n. 5
0
        //
        // Draw the differences between the track lines
        //
        void drawTrackDiff(XYChart c, Dictionary <string, double> log0, Dictionary <string, double> log1)
        {
            double x0, x1;

            if (!((null != log0) && log0.TryGetValue("x", out x0) && (null != log1) && log1.TryGetValue("x", out x1)))
            {
                return;
            }

            // Two columns in the table
            var leftCol  = new System.Text.StringBuilder();
            var rightCol = new System.Text.StringBuilder();

            leftCol.Append("Change in x: ");
            rightCol.Append(c.formatValue(x1 - x0, "{value|2}"));

            // Iterate through all layers to draw the data labels
            for (int i = 0; i < c.getLayerCount(); ++i)
            {
                Layer layer = c.getLayerByZ(i);

                // Iterate through all the data sets in the layer
                for (int j = 0; j < layer.getDataSetCount(); ++j)
                {
                    var dataSetName = layer.getDataSet(j).getDataName();

                    double v0, v1;
                    if (!(log0.TryGetValue(dataSetName, out v0) && log1.TryGetValue(dataSetName, out v1)))
                    {
                        continue;
                    }
                    leftCol.Append("\nChange in ").Append(dataSetName).Append(": ");
                    rightCol.Append("\n").Append(c.formatValue(v1 - v0, "{value|2}"));
                }
            }

            string table = "<*block,bgColor=80ffffff,margin=4*><*block*>" + leftCol.ToString() +
                           "<*/*><*block,halign=right*>" + rightCol.ToString() + "<*/*><*/*>";

            TTFText t = c.getDrawArea().text(table, "Arial", 10);

            t.draw(c.getPlotArea().getRightX() - t.getWidth(), c.getPlotArea().getTopY(), 0x000000);
        }
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WPFChartViewer viewer, int chartIndex)
        {
            // The data for the bar chart
            double[] data = { 85, 156, 179.5, 211, 123 };

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

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

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

            // Set the plotarea at (45, 40) and of 300 x 160 pixels in size. Use alternating light
            // grey (f8f8f8) / white (ffffff) background.
            c.setPlotArea(45, 40, 300, 160, 0xf8f8f8, 0xffffff);

            // Add a multi-color bar chart layer
            BarLayer layer = c.addBarLayer3(data);

            // Set layer to 3D with 10 pixels 3D depth
            layer.set3D(10);

            // Set bar shape to circular (cylinder)
            layer.setBarShape(Chart.CircleShape);

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

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

            // Add a title to the x axis
            c.xAxis().setTitle("Work Week 25");

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{xLabel}: {value} MBytes'")
            ;
        }
Esempio n. 7
0
        //Main code for creating chart.
        //Note: the argument img is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, string img)
        {
            // The data for the 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
            XYChart c = new XYChart(500, 320);

            // Set the plotarea at (100, 40) and of size 280 x 240 pixels
            c.setPlotArea(100, 40, 280, 240);

            // Add a legend box at (405, 100)
            c.addLegend(405, 100);

            // Add a title to the chart
            c.addTitle("Weekday Network Load");

            // Add a title to the y axis. Draw the title upright (font angle = 0)
            c.yAxis().setTitle("Average\nWorkload\n(MBytes\nPer Hour)").setFontAngle(
                0);

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

            // Add three bar layers, each representing one data set. The bars are
            // drawn in semi-transparent colors.
            c.addBarLayer(data0, unchecked ((int)0x808080ff), "Server # 1", 5);
            c.addBarLayer(data1, unchecked ((int)0x80ff0000), "Server # 2", 5);
            c.addBarLayer(data2, unchecked ((int)0x8000ff00), "Server # 3", 5);

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} on {xLabel}: {value} MBytes/hour'");
        }
Esempio n. 8
0
        //Main code for creating chart.
        //Note: the argument img is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, string img)
        {
            // The data for the line chart
            double[] data = { 30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 91,
                              60, 55, 53, 35, 50, 66, 56, 48, 52, 65, 62 };

            // 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 a XYChart object of size 300 x 280 pixels
            XYChart c = new XYChart(300, 280);

            // Set the plotarea at (45, 30) and of size 200 x 200 pixels
            c.setPlotArea(45, 30, 200, 200);

            // Add a title to the chart using 12 pts Arial Bold Italic font
            c.addTitle("Daily Server Utilization", "Arial Bold Italic", 12);

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

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

            // Add a blue (0x6666ff) 3D line chart layer using the give data
            c.addLineLayer(data, 0x6666ff).set3D();

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

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Hour {xLabel}: {value} MBytes'");
        }
Esempio n. 9
0
        //Main code for creating charts
        public void createChart(WinChartViewer viewer, int chartIndex)
        {
            double bargap = chartIndex * 0.25 - 0.25;

            // The data for the bar chart
            double[] data = { 100, 125, 245, 147, 67 };

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

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

            // Set the plotarea at (27, 20) and of size 120 x 100 pixels
            c.setPlotArea(27, 20, 120, 100);

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

            if (bargap >= 0)
            {
                // Add a title to display to bar gap using 8pt Arial font
                c.addTitle("      Bar Gap = " + bargap, "Arial", 8);
            }
            else
            {
                // Use negative value to mean TouchBar
                c.addTitle("      Bar Gap = TouchBar", "Arial", 8);
                bargap = Chart.TouchBar;
            }

            // Add a bar chart layer using the given data and set the bar gap
            c.addBarLayer(data).setBarGap(bargap);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Production on {xLabel}: {value} kg'");
        }
Esempio n. 10
0
        private void UpdateHistogramForImage()
        {
            if (this.InvokeRequired)
            {
                Action a = new Action(UpdateHistogramForImage);
                this.BeginInvoke(a);
            }
            else
            {
                HImage currentImage = this.ImageToBeSaved.CopyImage();

                HImage rImg, gImg, bImg;

                rImg = currentImage.Decompose3(out gImg, out bImg);

                HTuple RGrayValues = Globals.GetGrayValuesOfPixel(rImg);
                HTuple GGrayValues = Globals.GetGrayValuesOfPixel(gImg);
                HTuple BGrayValues = Globals.GetGrayValuesOfPixel(bImg);

                double[] redData;
                double[] greenData;
                double[] blueData;

                XYChart c = new XYChart(chartViewer.Width - 10, chartViewer.Height - 10, 0xffdddd, 0x000000, 1);

                c.setPlotArea(50, 10, chartViewer.Width - 100, chartViewer.Height - 60, 0xffffff, -1, -1);

                redData   = RGrayValues;
                greenData = GGrayValues;
                blueData  = BGrayValues;

                // Add a line chart layer using the given data
                c.addSplineLayer(redData, 0xFF0000);
                c.addSplineLayer(greenData, 0x00FF00);
                c.addSplineLayer(blueData, 0x0000FF);

                c.xAxis().setLinearScale(0, 255, 255);

                chartViewer.Chart = c;
            }
        }
        // mosue wheel event handler

        private void winChartViewer1_MouseWheel(object sender, MouseEventArgs e)
        {
            // we zoom in or out by 10% depeding on the mouse wheel direction
            double r = e.Delta > 0 ? 0.9 : 1 / 0.5;

            // do not zoom in beyongd the zoom in width limit
            if ((r = Math.Max(r, winChartViewer1.ZoomInWidthLimit / winChartViewer1.ViewPortWidth)) == 1)
            {
                return;
            }

            XYChart c = (XYChart)winChartViewer1.Chart;

            double mouseOffset = (e.X - c.getPlotArea().getLeftX()) / (double)c.getPlotArea().getWidth();

            winChartViewer1.ViewPortLeft  += mouseOffset * (1 - r) * winChartViewer1.ViewPortWidth;
            winChartViewer1.ViewPortWidth *= r;

            // trigger a view port changed event to update the  chart
            winChartViewer1.updateViewPort(true, false);
        }
Esempio n. 12
0
 private void InitChart()
 {
     chartOptions = new XYChartOptions()
     {
         Title             = "Resource Monitor".ToYellow(),
         YMinOverride      = 0,
         YAxisRangePadding = .7f,
         XAxisFormatter    = new DateTimeFormatter(),
         YAxisFormatter    = new NumberFormatter(),
         Data = new List <Series>()
         {
             new Series()
             {
                 Title         = resources[listView.SelectedRowIndex].DisplayName,
                 PlotCharacter = new ConsoleCharacter('O', ConsoleColor.Cyan),
                 Points        = new List <DataPoint>(),
             }
         }
     };
     chart = layout.Add(new XYChart(chartOptions), 1, 0);
 }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The data for the area chart
            double[] data = { 30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89, 60, 55, 53, 35, 50,
                              66, 56, 48, 52, 65, 62 };

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

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

            // Set the plotarea at (45, 30) and of size 200 x 200 pixels
            c.setPlotArea(45, 30, 200, 200);

            // Add a title to the chart using 12pt Arial Bold Italic font
            c.addTitle("Daily Server Utilization", "Arial Bold Italic", 12);

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

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

            // Add a green (0x00ff00) 3D area chart layer using the give data
            c.addAreaLayer(data, 0x00ff00).set3D();

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

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "", "title='Hour {xLabel}: Traffic {value} MBytes'");
        }
        protected virtual void SetChartData(List <XYColumnChartData> dataList)
        {
            #region Input Validation
            if (dataList == null)
            {
                throw new ArgumentNullException("dataList");
            }
            #endregion // Input Validation

            Series series1 = null;
            object el      = FindName("series1");
            if (el is Series)
            {
                series1 = el as Series;
            }

            XYChart xyChart = null;
            el = FindName("xyChart");
            if (el is XYChart)
            {
                xyChart = el as XYChart;
            }

            bool shouldShowY2 = false;

            foreach (XYColumnChartData xyc in dataList)
            {
                if (xyc.Y2.HasValue)
                {
                    shouldShowY2 = true;
                    break;
                }
            }

            if (shouldShowY2 && series1 != null)
            {
                series1.Visibility = System.Windows.Visibility.Visible;
            }
            xyChart.DataSource = dataList;
        }
Esempio n. 15
0
        private void LoadDataToChart(WinChartViewer viewer, DataTable errorData, int per)
        {
            Chart.setLicenseCode("DEVP-2LSU-B4LX-YCTY-2DF2-77EE");
            this.chartWidth = this.Width;
            plottWidth      = chartWidth - 80;
            double[] data   = null;
            int[]    color  = null;
            string[] labels = null;
            GetDataForChart(errorData, ref labels, ref data, ref color);

            XYChart c = new XYChart(chartWidth, chartHeight);

            c.setBackground(0xFFFFFF);


            c.setPlotArea(40, 80, plottWidth, plotHeight, 0xf8f8f8, 0xffffff);

            ArrayMath am = new ArrayMath(data);

            viewer.BorderStyle = BorderStyle.None;

            c.yAxis().setLinearScale(0, am.max());
            BarLayer layer = c.addBarLayer3(am.mul(percentage / 100.0).result());



            layer.set3D(20, 10);

            layer.setAggregateLabelStyle("Arial Bold", 14, layer.yZoneColor(0,
                                                                            0xcc3300, 0x3333ff));

            c.xAxis().setLabels(labels);
            c.xAxis().setLabelStyle("Calibri Bold", 12);
            c.yAxis().setLabelStyle("Calibri Bold", 12);

            viewer.Chart    = c;
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{xLabel}: {value}'");
        }
Esempio n. 16
0
        //Main code for creating charts
        public void createChart(WinChartViewer viewer, string img)
        {
            // The data for the chart
            double[] data   = { 100, 125, 265, 147, 67, 105 };
            string[] labels = { "Jan", "Feb", "Mar", "Apr", "May", "Jun" };

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

            // Set the plot area at (27, 25) and of size 200 x 200 pixels
            c.setPlotArea(27, 25, 200, 200);

            if (img == "1")
            {
                // High tick density, uses 10 pixels as tick spacing
                c.addTitle("Tick Density = 10 pixels");
                c.yAxis().setTickDensity(10);
            }
            else
            {
                // Normal tick density, just use the default setting
                c.addTitle("Default Tick Density");
            }

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

            // Add a color bar layer using the given data. Use a 1 pixel 3D border
            // for the bars.
            c.addBarLayer3(data).setBorderColor(-1, 1);

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Revenue for {xLabel}: US${value}M'");
        }
Esempio n. 17
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 bar chart
            double[] data = { 85, 156, 179.5, 211, 123 };

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

            // The colors for the bar chart
            int[] colors = { 0xb8bc9c, 0xa0bdc4, 0x999966, 0x333366, 0xc3c3e6 };

            // Create a XYChart object of size 300 x 220 pixels. Use golden
            // background color. Use a 2 pixel 3D border.
            XYChart c = new XYChart(300, 220, Chart.goldColor(), -1, 2);

            // Add a title box using 10 point Arial Bold font. Set the background
            // color to metallic blue (9999FF) Use a 1 pixel 3D border.
            c.addTitle("Daily Network Load", "Arial Bold", 10).setBackground(
                Chart.metalColor(0x9999ff), -1, 1);

            // Set the plotarea at (40, 40) and of 240 x 150 pixels in size
            c.setPlotArea(40, 40, 240, 150);

            // Add a multi-color bar chart layer using the given data and colors. Use
            // a 1 pixel 3D border for the bars.
            c.addBarLayer3(data, colors).setBorderColor(-1, 1);

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

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{xLabel}: {value} GBytes'");
        }
Esempio n. 18
0
        //
        // Draw track line with data labels
        //
        private void trackLineLabel(XYChart c)
        {
            // Clear the current dynamic layer and get the DrawArea object to draw on it.
            DrawArea d = c.initDynamicLayer();

            // In this example, we have two track lines.
            const int trackLineCount = 2;

            if (trackLinePos.Count == 0)
            {
                // Initialize the track line position by distributing them on the plot area
                PlotArea p = c.getPlotArea();
                for (int i = 0; i < trackLineCount; ++i)
                {
                    trackLinePos.Add(p.getLeftX() + (int)(p.getWidth() * (i + 0.5) / trackLineCount));
                }
            }

            // Record the positions with the track lines
            var trackLineLog = new Dictionary <string, double> [trackLineCount];

            // Draw the track lines if enabled
            if (trackLine1Enable.Checked)
            {
                drawTrackLine(c, trackLinePos[0], trackLineLog[0] = new Dictionary <string, double>());
            }
            if (trackLine2Enable.Checked)
            {
                drawTrackLine(c, trackLinePos[1], trackLineLog[1] = new Dictionary <string, double>());
            }

            // Draw the differences beteween the first two track lines
            if (trackLineCount >= 2)
            {
                drawTrackDiff(c, trackLineLog[0], trackLineLog[1]);
            }
        }
Esempio n. 19
0
        private void winChartViewer1_MouseWheel(object sender, MouseEventArgs e)
        {
            // We zoom in or out by 10% depending on the mouse wheel direction.
            double rx = e.Delta > 0 ? 0.9 : 1 / 0.9;
            double ry = rx;

            // We do not zoom in beyond the zoom in width or height limit.
            rx = Math.Max(rx, winChartViewer1.ZoomInWidthLimit / winChartViewer1.ViewPortWidth);
            ry = Math.Max(ry, winChartViewer1.ZoomInWidthLimit / winChartViewer1.ViewPortHeight);
            if ((rx == 1) && (ry == 1))
            {
                return;
            }

            XYChart c = (XYChart)winChartViewer1.Chart;

            //
            // Set the view port position and size so that it is zoom in/out around the mouse by the
            // desired ratio.
            //

            double mouseOffset = (winChartViewer1.ChartMouseX - c.getPlotArea().getLeftX()) /
                                 (double)c.getPlotArea().getWidth();

            winChartViewer1.ViewPortLeft  += mouseOffset * (1 - rx) * winChartViewer1.ViewPortWidth;
            winChartViewer1.ViewPortWidth *= rx;

            double mouseOffsetY = (winChartViewer1.ChartMouseY - c.getPlotArea().getTopY()) /
                                  (double)c.getPlotArea().getHeight();

            winChartViewer1.ViewPortTop    += mouseOffsetY * (1 - ry) * winChartViewer1.ViewPortHeight;
            winChartViewer1.ViewPortHeight *= ry;

            // Trigger a view port changed event to update the chart
            winChartViewer1.updateViewPort(true, false);
        }
Esempio n. 20
0
        private void CreateDataChart(ICollection <double> datas)
        {
            Dictionary <string, LineChartInfo> lineInfos = new Dictionary <string, LineChartInfo>()
            {
                { "Target", new LineChartInfo(0x0000FF, 2, 0) }
            };

            List <LineChartPoint> listOfPoint = new List <LineChartPoint>();

            for (int i = 0; i < datas.Count; i++)
            {
                double target = datas.ElementAt(i);

                listOfPoint.Add(new LineChartPoint(i, new Dictionary <string, double>()
                {
                    { "Target", target }
                }));
            }

            XYChart c = GetChart((int)ActualWidth, (int)ActualHeight,
                                 "Count", "", (int)AppConstant.GFontSize, lineInfos, listOfPoint);

            viewer.Chart = c;
        }
Esempio n. 21
0
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, int chartIndex)
        {
            // The data for the bar chart
            double[] data = { 85, 156, 179.5, 211, 123 };

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

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

            // Set the plotarea at (45, 30) and of size 200 x 200 pixels
            c.setPlotArea(45, 30, 200, 200);

            // Add a title to the chart
            c.addTitle("Weekly Server Load");

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

            // Add a title to the x axis
            c.xAxis().setTitle("Work Week 25");

            // Add a bar chart layer with green (0x00ff00) bars using the given data
            c.addBarLayer(data, 0x00ff00).set3D();

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

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{xLabel}: {value} MBytes'")
            ;
        }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The data for the chart
            double[] data = { 40, 45, 37, 24, 32, 39, 53, 52, 63, 49, 46, 40, 54, 50, 57, 57, 48, 49, 63,
                              67, 74, 72, 70, 89, 74 };
            string[] labels = { "0\nJun 4", "1",  "2",  "3",  "4",  "5",  "6",  "7",  "8",  "9",  "10", "11", "12",
                                "13",       "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "0\nJun 5" };

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

            // Set the plotarea at (80, 60) and of size 300 x 200 pixels. Turn off the grid lines by
            // setting their colors to Transparent.
            c.setPlotArea(80, 28, 300, 200).setGridColor(Chart.Transparent);

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

            // Set the y axis title upright (font angle = 0)
            textbox.setFontAngle(0);

            // Put the y axis title on top of the axis
            textbox.setAlignment(Chart.TopLeft2);

            // Add green (0x99ff99), yellow (0xffff99) and red (0xff9999) zones to the y axis to
            // represent the ranges 0 - 50, 50 - 80, and 80 - max.
            c.yAxis().addZone(0, 50, 0x99ff99);
            c.yAxis().addZone(50, 80, 0xffff99);
            c.yAxis().addZone(80, 9999, 0xff9999);

            // Add a purple (0x800080) mark at y = 70 using a line width of 2.
            c.yAxis().addMark(70, 0x800080, "Alert = 70").setLineWidth(2);

            // Add a green (0x008000) mark at y = 40 using a line width of 2.
            c.yAxis().addMark(40, 0x008000, "Watch = 40").setLineWidth(2);

            // Add a legend box at (165, 0) (top right of the chart) using 8pt Arial font. and horizontal
            // layout.
            LegendBox legend = c.addLegend(165, 0, false, "Arial Bold", 8);

            // Disable the legend box boundary by setting the colors to Transparent
            legend.setBackground(Chart.Transparent, Chart.Transparent);

            // Add 3 custom entries to the legend box to represent the 3 zones
            legend.addKey("Normal", 0x80ff80);
            legend.addKey("Warning", 0xffff80);
            legend.addKey("Critical", 0xff8080);

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

            // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
            c.xAxis().setLabelStep(3, 1);

            // Add a 3D bar layer with the given data
            BarLayer layer = c.addBarLayer(data, 0xbbbbff);

            // Set the bar gap to 0 so that the bars are packed tightly
            layer.setBarGap(0);

            // Set the border color of the bars same as the fill color, with 1 pixel 3D border effect.
            layer.setBorderColor(Chart.SameAsMainColor, 1);

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "", "title='Temperature at {x}:00 = {value} C'");
        }
Esempio n. 23
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);
    }
Esempio n. 24
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}%)'");
    }
Esempio n. 25
0
        //
        // Draw the chart.
        //
        private void drawChart(WinChartViewer viewer)
        {
            // Get the start date and end date that are visible on the chart.
            double viewPortStartDate = viewer.getValueAtViewPort("x", viewer.ViewPortLeft);
            double viewPortEndDate   = viewer.getValueAtViewPort("x", viewer.ViewPortLeft +
                                                                 viewer.ViewPortWidth);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Set the chart image to the WinChartViewer
            viewer.Chart = c;
        }
Esempio n. 26
0
        void drawTrackLine(XYChart c, int lineX, Dictionary <string, double> log)
        {
            // The drawarea and plotarea objects
            DrawArea d        = c.getDrawArea();
            PlotArea plotArea = c.getPlotArea();

            // Get the data x-value that is nearest to the mouse, and find its pixel coordinate.
            double xValue = c.getNearestXValue(lineX);
            int    xCoor  = c.getXCoor(xValue);

            // Draw empty track line if it is ahead of the data
            if ((currentIndex <= 0) || ((xCoor < lineX) && (xValue >= chartTimeLimit)))
            {
                d.vline(plotArea.getTopY(), plotArea.getBottomY(), lineX, 0x888888);
                return;
            }

            // Draw a vertical track line at the x-position
            d.vline(plotArea.getTopY(), plotArea.getBottomY(), xCoor, 0x888888);

            // Draw a label on the x-axis to show the track line position.
            string xlabel = "<*font,bgColor=000000*> " + c.xAxis().getFormattedLabel(xValue, "nn:ss.ff") +
                            " <*/font*>";
            TTFText t = d.text(xlabel, "Arial Bold", 10);

            log["x"] = xValue;

            // Restrict the x-pixel position of the label to make sure it stays inside the chart image.
            int xLabelPos = Math.Max(0, Math.Min(xCoor - t.getWidth() / 2, c.getWidth() - t.getWidth()));

            t.draw(xLabelPos, plotArea.getBottomY() + 6, 0xffffff);

            // Iterate through all layers to draw the data labels
            for (int i = 0; i < c.getLayerCount(); ++i)
            {
                Layer layer = c.getLayerByZ(i);

                // The data array index of the x-value
                int xIndex = layer.getXIndexOf(xValue);

                // Iterate through all the data sets in the layer
                for (int j = 0; j < layer.getDataSetCount(); ++j)
                {
                    ChartDirector.DataSet dataSet = layer.getDataSetByZ(j);

                    // Get the color and position of the data label
                    int color = dataSet.getDataColor();
                    int yCoor = c.getYCoor(dataSet.getPosition(xIndex), dataSet.getUseYAxis());

                    // Draw a track dot with a label next to it for visible data points in the plot area
                    if ((yCoor >= plotArea.getTopY()) && (yCoor <= plotArea.getBottomY()) && (color !=
                                                                                              Chart.Transparent) && (!string.IsNullOrEmpty(dataSet.getDataName())))
                    {
                        d.circle(xCoor, yCoor, 4, 4, color, color);

                        string label = "<*font,bgColor=" + color.ToString("x") + "*> " + c.formatValue(
                            dataSet.getValue(xIndex), "{value|P4}") + " <*/font*>";
                        t = d.text(label, "Arial Bold", 10);
                        log[dataSet.getDataName()] = dataSet.getValue(xIndex);

                        // Draw the label on the right side of the dot if the mouse is on the left side the
                        // chart, and vice versa. This ensures the label will not go outside the chart image.
                        if (xCoor <= (plotArea.getLeftX() + plotArea.getRightX()) / 2)
                        {
                            t.draw(xCoor + 5, yCoor, 0xffffff, Chart.Left);
                        }
                        else
                        {
                            t.draw(xCoor - 5, yCoor, 0xffffff, Chart.Right);
                        }
                    }
                }
            }
        }
Esempio n. 27
0
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WPFChartViewer viewer, int chartIndex)
        {
            // The data for the 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 Jun 4", "Tue Jun 5", "Wed Jun 6", "Thu Jun 7", "Fri Jun 8" };

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

            // Set the plot area to start at (120, 40) and of size 280 x 240 pixels
            c.setPlotArea(120, 40, 280, 240);

            // Add a title to the chart using 20pt Times Bold Italic (timesbi.ttf) font and using a
            // deep blue color (0x000080)
            c.addTitle("Weekly Server Load", "Times New Roman Bold Italic", 20, 0x000080);

            // Add a legend box at (420, 100) (right of plot area) using 12pt Times Bold font. Sets
            // the background of the legend box to light grey 0xd0d0d0 with a 1 pixel 3D border.
            c.addLegend(420, 100, true, "Times New Roman Bold", 12).setBackground(0xd0d0d0,
                                                                                  0xd0d0d0, 1);

            // Add a title to the y-axis using 12pt Arial Bold/deep blue (0x000080) font. Set the
            // background to yellow (0xffff00) with a 2 pixel 3D border.
            c.yAxis().setTitle("Throughput (per hour)", "Arial Bold", 12, 0x000080).setBackground(
                0xffff00, 0xffff00, 2);

            // Use 10pt Arial Bold/orange (0xcc6600) font for the y axis labels
            c.yAxis().setLabelStyle("Arial Bold", 10, 0xcc6600);

            // Set the axis label format to "nnn MBytes"
            c.yAxis().setLabelFormat("{value} MBytes");

            // Use 10pt Arial Bold/green (0x008000) font for the x axis labels. Set the label angle
            // to 45 degrees.
            c.xAxis().setLabelStyle("Arial Bold", 10, 0x008000).setFontAngle(45);

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

            // Add a 3D stack bar layer with a 3D depth of 5 pixels
            BarLayer layer = c.addBarLayer2(Chart.Stack, 5);

            // Use Arial Italic as the default data label font in the bars
            layer.setDataLabelStyle("Arial Italic");

            // Use 10pt Times Bold Italic (timesbi.ttf) as the aggregate label font. Set the
            // background to flesh (0xffcc66) color with a 1 pixel 3D border.
            layer.setAggregateLabelStyle("Times New Roman Bold Italic", 10).setBackground(0xffcc66,
                                                                                          Chart.Transparent, 1);

            // Add the first data set to the stacked bar layer
            layer.addDataSet(data0, -1, "Server #1");

            // Add the second data set to the stacked bar layer
            layer.addDataSet(data1, -1, "Server #2");

            // Add the third data set to the stacked bar layer, and set its data label font to Arial
            // Bold Italic.
            ChartDirector.TextBox textbox = layer.addDataSet(data2, -1, "Server #3"
                                                             ).setDataLabelStyle("Arial Bold Italic");

            // Set the data label font color for the third data set to yellow (0xffff00)
            textbox.setFontColor(0xffff00);

            // Set the data label background color to the same color as the bar segment, with a 1
            // pixel 3D border.
            textbox.setBackground(Chart.SameAsMainColor, Chart.Transparent, 1);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} on {xLabel}: {value} MBytes/hour'");
        }
Esempio n. 28
0
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, int chartIndex)
        {
            // The data for the bar chart
            double[] data0 = { 100, 115, 165, 107, 67 };
            double[] data1 = { 85, 106, 129, 161, 123 };
            double[] data2 = { 67, 87, 86, 167, 157 };

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} on {xLabel}: {value} MBytes/hour'");
        }
Esempio n. 29
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);
        }
Esempio n. 30
0
        /// <summary>
        /// This method uses the Chart Director API to plot the histogram
        /// </summary>
        /// <param name="chartWidth"></param>
        /// <param name="chartHeight"></param>
        /// <param name="data"></param>
        /// <param name="labels"></param>
        /// <param name="title"></param>
        /// <param name="xAxisLabel"></param>
        /// <param name="yAxisLabel"></param>
        private void plot(int chartWidth, int chartHeight, double[] data, string[] labels, string title, string xAxisLabel, string yAxisLabel)
        {
            // Create a XYChart object of size chartWidth x chartHeight pixels
            XYChart chart = new XYChart(chartWidth, chartHeight);

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

            // Add a title box using grey (0x555555) 24pt Arial Bold font
            chart.addTitle(title, "Arial Bold", 24, 0x555555);

            // Set the plotarea at (70, 60) and of size 500 x 200 pixels, with transparent
            // background and border and light grey (0xcccccc) horizontal grid lines
            chart.setPlotArea(chartXLocation, chartYLocation, plotWidth, plotHeight, Chart.Transparent, -1, Chart.Transparent, 0xcccccc);

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

            // Use 10 points Arial rotated by 45 degrees as the x-axis label font
            chart.xAxis().setLabelStyle("Arial", 10, Chart.TextColor, 45);
            chart.yAxis().setLabelStyle("Arial", 10);

            // Add a blue (0x6699bb) bar chart layer using the given data
            BarLayer layer = chart.addBarLayer(data, 0x6699bb);

            // Use bar gradient lighting with the light intensity from 0.8 to 1.3
            layer.setBorderColor(Chart.Transparent, Chart.barLighting(0.8, 1.3));

            // Set rounded corners for bars
            layer.setRoundedCorners();

            // Display labela on top of bars using 10pt Arial font
            layer.setAggregateLabelStyle("Arial", 10);

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

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

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

            // Add a title to the x axis using dark grey (0x555555) 12pt Arial Bold font
            chart.xAxis().setTitle(xAxisLabel, "Arial Bold", 12, 0x555555);

            //output the chart
            chartViewer.Chart = chart;
        }
Esempio n. 31
0
        public override void UpdateVisualization()
        {
            List<string>[] chartLabels = null;
            double[] dataArray = null;
            Image img = new Image();
            int i = 0;
            List<string> xLabels = new List<string>();
            List<string> yLabels = new List<string>();

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

            int zCount = 0;
            if (chartLabels[2] == null)
            {
                zCount = 1;
            }
            else
            {
                zCount = chartLabels[2].Count;
            }

            xLabels.Add("");
            for (i = 0; i < chartLabels[0].Count; i++)
            {
                xLabels.Add(chartLabels[0][i]);
            }
            xLabels.Add("");
            yLabels.Add("");
            for (i = 0; i < chartLabels[1].Count; i++)
            {
                yLabels.Add(chartLabels[1][i]);
            }
            yLabels.Add("");

            // Obtain grid
            if ((configDisplayPanel.Children == null) || (configDisplayPanel.Children.Count != 1) ||
                (!(configDisplayPanel.Children[0] is Grid)))
            {
                return;
            }
            Grid grid = configDisplayPanel.Children[0] as Grid;

            // Clear the grid images
            List<UIElement> removalList = new List<UIElement>();
            foreach (UIElement child in grid.Children)
            {
                if (child is Image)
                {
                    removalList.Add(child);
                }
            }
            if (removalList.Count > 0)
            {
                foreach (UIElement child in removalList)
                {
                    grid.Children.Remove(child);
                }
            }

            // Create the Stacked Histogram
            XYChart c = new XYChart(configDisplay.Width, configDisplay.Height);
            c.setPlotArea(100, 0, configDisplay.Width - 200, configDisplay.Height - 100);
            c.xAxis().setLabels(xLabels.ToArray());
            c.yAxis().setLabels(yLabels.ToArray());

            c.xAxis().setTickOffset(-0.5);
            c.yAxis().setTickOffset(-0.5);

            // Create x and y value list
            List<double>[] dataX = new List<double>[zCount];
            List<double>[] dataY = new List<double>[zCount];

            for (int z = 0; z < zCount; z++)
            {
                dataX[z] = new List<double>();
                dataY[z] = new List<double>();

                for (int y = 0; y < chartLabels[1].Count; y++)
                {
                    for (int x = 0; x < chartLabels[0].Count; x++)
                    {
                        dataX[z].Add(x + 1 + xOffsets[z]);
                        dataY[z].Add(y + 1 + yOffsets[z]);
                    }
                }
            }
            List<double> dataZ = new List<double>();
            double maxBubbleSize = (configDisplay.Width - 200) / xLabels.Count / 2.0;

            i = 0;
            for (int z = 0; z < zCount; z++)
            {
                if (GetConfigDisplayData(i, ref dataArray))
                {
                    ArrayMath a = new ArrayMath(dataArray.ToArray());
                    double maxValue = a.max();

                    if (maxValue < maxBubbleSize)
                    {
                        for (int j = 0; j < dataArray.Length; j++)
                        {
                            if (dataArray[j] == 0)
                            {
                                dataZ.Add(0.0);
                            }
                            else
                            {
                                dataZ.Add(dataArray[j] + 10);
                            }
                        }
                    }
                    else
                    {
                        for (int j = 0; j < dataArray.Length; j++)
                        {
                            if (dataArray[j] == 0)
                            {
                                dataZ.Add(0.0);
                            }
                            else
                            {
                                dataZ.Add(dataArray[j] / maxValue * maxBubbleSize + 10);
                            }
                        }
                    }
                }
                i++;

                if (chartLabels[2] == null)
                {
                    c.addScatterLayer(dataX[z].ToArray(), dataY[z].ToArray(), configDisplay.MetricName, Chart.CircleSymbol, 9,
                        (int) barcodeColorsTrans[z], (int) barcodeColorsTrans[z]).setSymbolScale(dataZ.ToArray());
                }
                else
                {
                    c.addScatterLayer(dataX[z].ToArray(), dataY[z].ToArray(), chartLabels[2][z], Chart.CircleSymbol, 9,
                        (int) barcodeColorsTrans[z], (int) barcodeColorsTrans[z]).setSymbolScale(dataZ.ToArray());
                }
                dataZ.Clear();
            }

            // Generate an image of the chart
            System.Drawing.Image imgWinForms = c.makeImage();
            BitmapImage bi = new BitmapImage();

            bi.BeginInit();

            MemoryStream ms = new MemoryStream();

            // Save to a memory stream...

            imgWinForms.Save(ms, ImageFormat.Bmp);

            // Rewind the stream...

            ms.Seek(0, SeekOrigin.Begin);

            // Tell the WPF image to use this stream...
            bi.StreamSource = ms;

            bi.EndInit();
            img.Source = bi;
            img.Stretch = Stretch.Uniform;

            Grid.SetColumn(img, 0);
            Grid.SetRow(img, 2);
            grid.Children.Add(img);
        }
Esempio 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 data for the chart
            double[] data = { 30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89, 60, 55, 53, 35,
                              50, 66, 56, 48, 52, 65, 62 };

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

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

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

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

            legendBox.setBackground(Chart.Transparent);

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

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

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

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

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

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

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

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

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

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Hour {xLabel}: {value} KJ/liter'");
        }
Esempio n. 33
0
        public override void UpdateVisualization()
        {
            List<string>[] chartLabels = null;
            double[] dataArray = null;
            Image img = new Image();
            List<string> xLabels = new List<string>();
            int minTime = 0;

            // Get the Factor Labels
            chartLabels = GetConfigDisplayLabels();
            if (chartLabels == null)
            {
                return;
            }
            for (int i = 0; i < chartLabels[0].Count - 1; i++)
            {
                xLabels.Add(chartLabels[0][i]);
            }

            // Obtain grid
            if ((configDisplayPanel.Children == null) || (configDisplayPanel.Children.Count != 1) ||
                (!(configDisplayPanel.Children[0] is Grid)))
            {
                return;
            }
            Grid grid = configDisplayPanel.Children[0] as Grid;
            double gridWidth = grid.ColumnDefinitions[0].ActualWidth;
            double gridHeight = configDisplay.Height - (grid.RowDefinitions[0].ActualHeight + grid.RowDefinitions[1].ActualHeight);

            // Clear the grid images
            List<UIElement> removalList = new List<UIElement>();
            foreach (UIElement child in grid.Children)
            {
                if (child is Image)
                {
                    removalList.Add(child);
                }
            }
            if (removalList.Count > 0)
            {
                foreach (UIElement child in removalList)
                {
                    grid.Children.Remove(child);
                }
            }

            // The task index, start date, end date and color for each bar
            double[] taskNo = { 0, 1 };
            double[] startValues = { .5, 2.5 };
            double[] endValues = { 1.5, 3.5 };

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

            c.setPlotArea(150, 50, (int)gridWidth - 200, (int)gridHeight - 100, 0xffffff, 0xeeeeee, Chart.LineColor,
                0xc0c0c0, 0xc0c0c0).setGridWidth(2, 1, 1, 1);

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

            // Get RT PME Data
            for (int i = 0; i < xLabels.Count; i++)
            {
                if (GetConfigDisplayData(i, ref dataArray))
                {
                    for (int j = 0; j < dataArray.Length; j++)
                    {
                        if (dataArray[j] > 0)
                        {
                            startList.Add((double)timeTick - 0.4);
                            endList.Add((double)timeTick + 0.4);
                            operatorNum.Add(i);
                            colorList.Add((int)barcodeColors[j]);
                        }
                    }
                }
            }

            timeTick++;
            // Remove old information from data lists
            if (timeTick - BARCODETIMESPAN < 0)
            {
                minTime = 0;
            }
            else
            {
                minTime = timeTick - BARCODETIMESPAN;
            }
            int pos = 0;
            while ((pos < startList.Count) && (startList[pos] <= minTime))
            {
                pos++;
            };
            if (pos != 0)
            {
                startList.RemoveRange(0, pos);
                endList.RemoveRange(0, pos);
                operatorNum.RemoveRange(0, pos);
                colorList.RemoveRange(0, pos);
            }

            // Add a multi-color box-whisker layer to represent the bars
            BoxWhiskerLayer layer = c.addBoxWhiskerLayer2(startList.ToArray(), endList.ToArray(), null, null, null, colorList.ToArray());
            layer.setXData(operatorNum.ToArray());
            layer.setBorderColor(Chart.SameAsMainColor);

            c.yAxis().setLinearScale((double)minTime, (double)timeTick + 0.5, 1, 0);

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

            // Set the labels on the x axis
            c.xAxis().setLabels(xLabels.ToArray());
            //c.yAxis().setLabels(yLabelsVals);

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

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

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

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

            /*
                        XYChart c = new XYChart(configDisplay.Width, configDisplay.Height);
                        c.setPlotArea(150, 50, configDisplay.Width - 200, configDisplay.Height - 100);
                        c.addLegend(20, 20);
                        c.xAxis().setLabels(xLabels.ToArray());

                        // Add a stacked bar layer and set the layer 3D depth to 8 pixels
                        BarLayer layer = c.addBarLayer2(Chart.Stack, 8);

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

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

                        for (int i = 0; i < xLabels.Count; i++)
                        {
                            if (rtpmeConnection.GetConfigDisplayData(configDisplay.ConfigDisplayID, i, ref dataArray))
                            {
                                layer.addDataSet(dataArray, colorValues[i], xLabels[i]);
                            }
                        }
                        */

            // Generate an image of the chart
            System.Drawing.Image imgWinForms = c.makeImage();
            BitmapImage bi = new BitmapImage();

            bi.BeginInit();

            MemoryStream ms = new MemoryStream();

            // Save to a memory stream...

            imgWinForms.Save(ms, ImageFormat.Bmp);

            // Rewind the stream...

            ms.Seek(0, SeekOrigin.Begin);

            // Tell the WPF image to use this stream...
            bi.StreamSource = ms;

            bi.EndInit();
            img.Source = bi;

            Grid.SetColumn(img, 0);
            Grid.SetRow(img, 2);
            grid.Children.Add(img);
        }            
Esempio n. 34
0
        //
        // Draw the track line with legend
        //
        private void crossHair(XYChart c, int mouseX, int mouseY)
        {
            //System.Threading.Thread.Sleep(500);
            // Clear the current dynamic layer and get the DrawArea object to draw on it.
            DrawArea d = c.initDynamicLayer();

            // The plot area object
            PlotArea plotArea = c.getPlotArea();

            // Draw a vertical line and a horizontal line as the cross hair
            d.vline(plotArea.getTopY(), plotArea.getBottomY(), mouseX, d.dashLineColor(0x000000, 0x0101));
            d.hline(plotArea.getLeftX(), plotArea.getRightX(), mouseY, d.dashLineColor(0x000000, 0x0101));

            // Draw y-axis label
            string label = "<*block,bgColor=FFFFDD,margin=3,edgeColor=000000*>" + c.formatValue(c.getYValue(
                mouseY, c.yAxis()), "{value|P4}") + "<*/*>";
            TTFText t = d.text(label, "Arial Bold", 8);
            t.draw(plotArea.getLeftX() - 5, mouseY, 0x000000, Chart.Right);

            // Draw x-axis label
            label = "<*block,bgColor=FFFFDD,margin=3,edgeColor=000000*>" + c.formatValue(c.getXValue(mouseX),
                "{value|P4}") + "<*/*>";
            t = d.text(label, "Arial Bold", 8);
            t.draw(mouseX, plotArea.getBottomY() + 5, 0x000000, Chart.Top);
        }
Esempio n. 35
0
        private void UpdatePlot(object sender, RunWorkerCompletedEventArgs e)
        {
            List<object> objlist = new List<object>();
            objlist.AddRange((List<object>)e.Result);
            double[] depart = (double[])objlist[0];
            double[] arrive = (double[])objlist[1];
            double[] departVel = (double[])objlist[2];
            string Plan1Name = (string)objlist[3];
            string Plan2Name = (string)objlist[4];

            XYChart c = new XYChart(800, 800);
            c.setPlotArea(75, 40, 600, 600, -1, -1, -1, c.dashLineColor(unchecked((int)0x80000000), Chart.DotLine), -1);
            // When auto-scaling, use tick spacing of 40 pixels as a guideline
            c.yAxis().setTickDensity(40);
            c.xAxis().setTickDensity(40);


            // Add a contour layer using the given data
            ContourLayer layer = c.addContourLayer(depart, arrive, departVel);
            c.getPlotArea().moveGridBefore(layer);
            ColorAxis cAxis = layer.setColorAxis(700, 40, Chart.TopLeft, 400, Chart.Right);
            double[] colorScale = { 3, 0x090446, 3.3, 0x16366B, 3.6, 0x236890, 3.9, 0x309AB5, 4.2, 0x53C45A, 4.5, 0x77EF00, 4.8, 0xBBF70F, 5.1, 0xFFFF1E, 5.4, 0xFF8111, 5.7, 0xFF0404 };
            cAxis.setColorScale(colorScale, 0x090446, 0xffffff);
            cAxis.setColorGradient(false);
            // Add a title to the color axis using 12 points Arial Bold Italic font
            cAxis.setTitle("Departure Velocity (km/s)", "Arial Bold Italic", 12);
            c.xAxis().setTitle("Departure Date (JDCT)");
            c.yAxis().setTitle("Arrival Date (JDCT)");
            c.addTitle("Departure Velocity from " + Plan1Name + " to " + Plan2Name);
            c.xAxis().setTickLength(10);
            c.yAxis().setTickLength(10);


            // Output the chart
            winChartViewer1.Chart = c;
            winChartViewer1.ImageMap = c.getHTMLImageMap("");
            /*
                        // The data for the bar chart
            double[] data = {85, 156, 179.5, 211, 123};

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

            XYChart c = new XYChart(250, 250);
            c.setPlotArea(30, 20, 200, 200);
            c.addBarLayer(data);
            c.xAxis().setLabels(labels);
            winChartViewer1.Chart = c;
            */

        }
Esempio n. 36
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}%)'");
    }
Esempio n. 37
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}%)'");
    }
Esempio n. 38
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();
		}
Esempio n. 39
0
		private void buildBarChart() {

			int topMargin = 30;
			int bottomnMargin = 70;
			int leftMargin = 50;
			int rightMargin = 30; 
			
			BarChartData data = (BarChartData)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);
			// Set the labels on the x axis.
			barChart.xAxis().setLabels(data.Labels);

			ChartDirector.BarLayer layer = barChart.addBarLayer3(data.Data, data.Colors, data.Labels);
			layer.setBorderColor(-1, 1);
			layer.set3D();

			// output the chart
			this.chartPanel.Image = barChart.makeImage();
		}
        //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)
        {
            // Create a finance chart demo containing 100 days of data
            int noOfDays = 100;

            // To compute moving averages starting from the first day, we need to get extra data
            // points before the first day
            int extraDays = 30;

            // In this exammple, we use a random number generator utility to simulate the data. We
            // set up the random table to create 6 cols x (noOfDays + extraDays) rows, using 9 as
            // the seed.
            RanTable rantable = new RanTable(9, 6, noOfDays + extraDays);

            // Set the 1st col to be the timeStamp, starting from Sep 4, 2014, with each row
            // representing one day, and counting week days only (jump over Sat and Sun)
            rantable.setDateCol(0, new DateTime(2014, 9, 4), 86400, true);

            // Set the 2nd, 3rd, 4th and 5th columns to be high, low, open and close data. The open
            // value starts from 100, and the daily change is random from -5 to 5.
            rantable.setHLOCCols(1, 100, -5, 5);

            // Set the 6th column as the vol data from 5 to 25 million
            rantable.setCol(5, 50000000, 250000000);

            // Now we read the data from the table into arrays
            double[] timeStamps = rantable.getCol(0);
            double[] highData   = rantable.getCol(1);
            double[] lowData    = rantable.getCol(2);
            double[] openData   = rantable.getCol(3);
            double[] closeData  = rantable.getCol(4);
            double[] volData    = rantable.getCol(5);

            // Custom data series should be of the same length as the OHLC data series
            double[] buySignal  = new double[closeData.Length];
            double[] sellSignal = new double[closeData.Length];

            //
            // The following is just an arbitrary algorithm to create some meaningless buySignal and
            // sellSignal. They are just for demonstrating the charting engine. Please do not use
            // them for actual trading.
            //

            double[] sma5  = new ArrayMath(closeData).movAvg(5).result();
            double[] sma20 = new ArrayMath(closeData).movAvg(20).result();

            for (int i = 0; i < sma5.Length; ++i)
            {
                buySignal[i]  = Chart.NoValue;
                sellSignal[i] = Chart.NoValue;
                if (i > 0)
                {
                    if ((sma5[i - 1] <= sma20[i - 1]) && (sma5[i] > sma20[i]))
                    {
                        buySignal[i] = lowData[i];
                    }
                    if ((sma5[i - 1] >= sma20[i - 1]) && (sma5[i] < sma20[i]))
                    {
                        sellSignal[i] = highData[i];
                    }
                }
            }

            // Create a FinanceChart object of width 640 pixels
            FinanceChart c = new FinanceChart(640);

            // Add a title to the chart
            c.addTitle("Finance Chart with Custom Symbols");

            // Set the data into the finance chart object
            c.setData(timeStamps, highData, lowData, openData, closeData, volData, extraDays);

            // Add the main chart with 240 pixels in height
            XYChart mainChart = c.addMainChart(240);

            // Add buy signal symbols to the main chart, using cyan (0x00ffff) upward pointing
            // arrows as symbols
            ScatterLayer buyLayer = mainChart.addScatterLayer(null, buySignal, "Buy",
                                                              Chart.ArrowShape(0, 1, 0.4, 0.4), 11, 0x00ffff);

            // Shift the symbol lower by 20 pixels
            buyLayer.getDataSet(0).setSymbolOffset(0, 20);

            // Add sell signal symbols to the main chart, using purple (0x9900cc) downward pointing
            // arrows as symbols
            ScatterLayer sellLayer = mainChart.addScatterLayer(null, sellSignal, "Sell",
                                                               Chart.ArrowShape(180, 1, 0.4, 0.4), 11, 0x9900cc);

            // Shift the symbol higher by 20 pixels
            sellLayer.getDataSet(0).setSymbolOffset(0, -20);

            // Add a 5 period simple moving average to the main chart, using brown color
            c.addSimpleMovingAvg(5, 0x663300);

            // Add a 20 period simple moving average to the main chart, using purple color
            c.addSimpleMovingAvg(20, 0x9900ff);

            // Add candlestick symbols to the main chart, using green/red for up/down days
            c.addCandleStick(0x66ff66, 0xff6666);

            // Add a volume indicator chart (75 pixels high) after the main chart, using
            // green/red/grey for up/down/flat days
            c.addVolIndicator(75, 0x99ff99, 0xff9999, 0x808080);

            // Append a 14-days RSI indicator chart (75 pixels high) after the main chart. The main
            // RSI line is purple (800080). Set threshold region to +/- 20 (that is, RSI = 50 +/-
            // 25). The upper/lower threshold regions will be filled with red (ff0000)/blue
            // (0000ff).
            c.addRSI(75, 14, 0x800080, 20, 0xff0000, 0x0000ff);

            // Output the chart
            viewer.Chart = c;
        }
Esempio n. 41
0
        public void createChart(WinChartViewer viewer, DateTime beginDate, Double dateRange)
        {
            //dateRange = dateRange / 3600.0;
            DateTime viewPortStartDate = beginDate.AddSeconds(Math.Round(viewer.ViewPortLeft * dateRange));
            DateTime viewPortEndDate = viewPortStartDate.AddSeconds(Math.Round(viewer.ViewPortWidth * dateRange));
            Double vpStart = Math.Round(viewer.ViewPortLeft * dateRange);
            Double vpEnd = vpStart + 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(viewer.Width - 5, viewer.Height - 5);
            // Add a title to the chart
            c.addTitle(chartName);

             // Set the plotarea at (50, 20) and of size 200 x 5200 pixels
            c.setPlotArea(50, 20, viewer.Width - 70, viewer.Height - 75);
            c.setClipping();

            // Add a bar chart layer using the given data
            if (chartOutputType.Equals(OutputType.INFO_ELEMENT))
            {
                c.addBarLayer(chartData.HighData.ToArray(), -1, chartOutputSubType);
            }
            else
            {
                c.addScatterLayer(new double[0],
                new ArrayMath(chartData.HighData.ToArray()).selectNEZ(chartData.IconType.ToArray(), ChartDirector.Chart.NoValue).result(),
                     chartOutputSubType, ChartDirector.Chart.CircleShape, 6, ChartDirector.Chart.CColor(Color.DarkOrange));

                LineLayer ll = c.addStepLineLayer();
                ll.addDataSet(chartData.HighData.ToArray(), ChartDirector.Chart.CColor(Color.DarkGray), "");
                ll.setLineWidth(3);
            }

            c.yAxis().setTitle(chartYAxis);
            c.yAxis().setLinearScale(0, 1.25, 0.25);
            ChartDirector.Mark mark = c.yAxis().addMark(1.0, 0x008000, "Max");
            mark.setLineWidth(2);
            mark.setDrawOnTop(false);

            // Set the labels on the x axis.
            //c.xAxis().setDateScale(viewPortStartDate, viewPortEndDate);
            c.xAxis().setLinearScale(vpStart, vpEnd, 1.0);
            c.xAxis().setMargin(10, 10);

            if (chartOutputType.Equals(OutputType.INFO_ELEMENT))
            {
                ChartDirector.BarLayer bl = c.addBarLayer();
                List<Double> barData = new List<Double>();
                int whiteColor = ChartDirector.Chart.CColor(Color.White);
                int redColor = ChartDirector.Chart.CColor(Color.Red);
                // add marks to the bar chart so we can see if a value should be there (even if it's zero)
                for (int i = 0; i < chartData.RealDataAtThisPoint.Count; i++)
                {
                    if (chartData.RealDataAtThisPoint[i])
                    {
                        barData.Add(0.05);
                        //c.xAxis().addMark(i, redColor);
                    }
                    else
                    {
                        barData.Add(0.0);
                    }
                        
                }
                bl.setBorderColor(redColor);
                bl.setBarWidth(0);
                bl.addDataSet(barData.ToArray(), whiteColor);
            }
                              
            // begin time in chart director format
            String beginCD = ""+ChartDirector.Chart.CTime(beginDate);
            // chart director uses seconds, convert our timeincrement to seconds and add them to the start time
            String partialTimeString = "{=("+beginCD+"+{value}*"+ChartExplorer.TimeIncrementInSecondsString+")|";
            c.xAxis().setMultiFormat(ChartDirector.Chart.StartOfDayFilter(), "<*font=bold*>"+partialTimeString+"m/d hhnn}", // show the day text once for each day
                                     ChartDirector.Chart.AllPassFilter(), partialTimeString+"hhnn}"); // military time for all others
            
            //c.xAxis().setLabels(chartData.TimeStamps.ToArray());
            c.xAxis().setTitle("Time Period: Hours");
            //c.xAxis().setLabelStep(4);
            //c.yAxis().setMultiFormat(ChartDirector.Chart.StartOfHourFilter(), "<*font=bold*>{value|w hhnn}", ChartDirector.Chart.AllPassFilter(), "{value|w hhnn}");


            // output the chart
            try
            {
                viewer.Image = c.makeImage();
                String query = "x={x}&xLabel={xLabel}&dataSet={dataSet}&dataSetName={dataSetName}&value={value}";
                viewer.ImageMap = c.getHTMLImageMap(query, query);
            }
            catch (Exception) // occasionally c.makeImage(); crashes - some sort of drawing exception?
                              // if we catch, the next redraw/resize should be fine...
            {

            }
        }
Esempio n. 42
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 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 18 pts 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 light red (ffdddd) to dark red (880000)
            // as background. Set border and grid lines to white (ffffff).
            c.setPlotArea(50, 55, 440, 280, c.linearGradientColor(0, 55, 0, 335,
                                                                  0xffdddd, 0x880000), -1, 0xffffff, 0xffffff);

            // Add a legend box at (50, 25) using horizontal layout. Use 10pts 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 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
            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, 0xffff00, "Server #1");
            layer.addDataSet(data1, 0x00ff00, "Server #2");
            layer.addDataSet(data2, 0x9999ff, "Server #3");

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

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

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} on {xLabel}: {value} MBytes/hour'");
        }
Esempio n. 43
0
		private void createBarChart() {

			int offset = 10;
			BarChartData data = (BarChartData)this.chartData;
			this.Label = data.Title;

			// Create a XYChart object.  Use a 2 pixel 3D border.
			XYChart c = new XYChart(this.chartPanel.Size.Width, this.chartPanel.Size.Height, 0xeeeeff, -1, 2);

			// Set the plotarea 
			c.setPlotArea(offset, offset, this.chartPanel.Size.Width - (2 * offset),
				this.chartPanel.Size.Height - (2 * offset), 0xffffff, -1, -1, 0xcccccc, 0xcccccc);

			// Add a multi-color bar chart layer using the given data and colors. Use
			// a 1 pixel 3D border for the bars.
			ChartDirector.BarLayer layer = c.addBarLayer3(data.Data, data.Colors);
			layer.setBorderColor(-1, 1);
			layer.set3D();
			

			// Set the labels on the x axis to null => no labels
			c.yAxis().setLabelFormat(null);

			// output the chart
			this.chartPanel.Image = c.makeImage();
		}
Esempio n. 44
0
        //Main code for creating chart.
        //Note: the argument img is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, string img)
        {
            // The x and y coordinates of the grid
            double[] dataX = { -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4,
                               5,    6,  7,  8,  9, 10 };
            double[] dataY = { -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4,
                               5,    6,  7,  8,  9, 10 };

            // The values at the grid points. In this example, we will compute the
            // values using the formula z = x * sin(y) + y * sin(x).
            double[] dataZ = new double[(dataX.Length) * (dataY.Length)];
            for (int yIndex = 0; yIndex < dataY.Length; ++yIndex)
            {
                double y = dataY[yIndex];
                for (int xIndex = 0; xIndex < dataX.Length; ++xIndex)
                {
                    double x = dataX[xIndex];
                    dataZ[yIndex * (dataX.Length) + xIndex] = x * Math.Sin(y) + y *
                                                              Math.Sin(x);
                }
            }

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

            // Add a title to the chart using 15 points Arial Bold Italic font
            c.addTitle("z = x * sin(y) + y * sin(x)      ", "Arial Bold Italic", 15);

            // Set the plotarea at (75, 40) and of size 400 x 400 pixels. Use
            // semi-transparent black (80000000) dotted lines for both horizontal and
            // vertical grid lines
            c.setPlotArea(75, 40, 400, 400, -1, -1, -1, c.dashLineColor(
                              unchecked ((int)0x80000000), Chart.DotLine), -1);

            // Set x-axis and y-axis title using 12 points Arial Bold Italic font
            c.xAxis().setTitle("X-Axis Title Place Holder", "Arial Bold Italic", 12);
            c.yAxis().setTitle("Y-Axis Title Place Holder", "Arial Bold Italic", 12);

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

            // When auto-scaling, use tick spacing of 40 pixels as a guideline
            c.yAxis().setTickDensity(40);
            c.xAxis().setTickDensity(40);

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

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

            // Add a color axis (the legend) in which the top left corner is anchored
            // at (505, 40). Set the length to 400 pixels and the labels on the right
            // side.
            ColorAxis cAxis = layer.setColorAxis(505, 40, Chart.TopLeft, 400,
                                                 Chart.Right);

            // Add a title to the color axis using 12 points Arial Bold Italic font
            cAxis.setTitle("Color Legend Title Place Holder", "Arial Bold Italic", 12
                           );

            // Set color axis labels to use Arial Bold font
            cAxis.setLabelStyle("Arial Bold");

            // Output the chart
            viewer.Image = c.makeImage();
        }
Esempio n. 45
0
		private void createMultiBarChart() {
			
			int offset = 10;
			MultiBarChartData data = (MultiBarChartData)this.chartData;
			this.Label = data.Title;

			// Create a XYChart object.  Use a 2 pixel 3D border.
			XYChart c = new XYChart(this.chartPanel.Size.Width, this.chartPanel.Size.Height, 0xeeeeff, -1, 2);

			// Set the plotarea 
			c.setPlotArea(offset, offset, this.chartPanel.Size.Width - (2 * offset),
				this.chartPanel.Size.Height - (2 * offset), 0xffffff, -1, -1, 0xcccccc, 0xcccccc);

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

			// Set the labels on the x axis to null => no labels
			c.yAxis().setLabelFormat(null);

			// output the chart
			this.chartPanel.Image = c.makeImage();
		}
Esempio n. 46
0
        private void createLinearChart() {

            int offset = 10;
            LinearChartData data = (LinearChartData)this.chartData;
            this.Label = 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.yAxis().setLabelFormat(null);
            c.yAxis().setTitle(data.YAxisLabel, "Arial", 7);
            c.xAxis().setTitle(data.XAxisLabel, "Arial", 7);


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

            this.chartPanel.Image = c.makeImage();
        }
Esempio n. 47
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;
        }
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WPFChartViewer viewer, int chartIndex)
        {
            //
            // Sample data for the CandleStick chart.
            //
            double[] highData = { 2043, 2039, 2076, 2064, 2048, 2058, 2070, 2033, 2027, 2029, 2071,
                                  2085, 2034, 2031, 2056, 2128, 2180, 2183, 2192, 2213, 2230, 2281, 2272 };

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{xLabel} Jan 2001\nHigh:{high}\nOpen:{open}\nClose:{close}\nLow:{low}'");
        }
Esempio n. 49
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);
        }
Esempio n. 50
0
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, int chartIndex)
        {
            // In this example, we simply use random data for the 3 data series.
            RanSeries r = new RanSeries(129);

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

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

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

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

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

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

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

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

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

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

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

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

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

            layer.setLineWidth(3);

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

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

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='[{x|mm/dd/yyyy}] {dataSetName}: {value}'");
        }
Esempio n. 51
0
        public override void UpdateVisualization()
        {
            List<string>[] chartLabels = null;
            double[] dataArray = null;
            Image img = new Image();
            List<string> xLabels = new List<string>();

            // Get the Factor Labels
            chartLabels = GetConfigDisplayLabels();
            if (chartLabels == null)
            {
                return;
            }
            for (int i = 0; i < chartLabels[0].Count; i++)
            {
                xLabels.Add(chartLabels[0][i]);
            }

            // Obtain grid
            if ((configDisplayPanel.Children == null) || (configDisplayPanel.Children.Count != 1) ||
                (!(configDisplayPanel.Children[0] is Grid)))
            {
                return;
            }
            Grid grid = configDisplayPanel.Children[0] as Grid;

            // Clear the grid images
            List<UIElement> removalList = new List<UIElement>();
            foreach (UIElement child in grid.Children)
            {
                if (child is Image)
                {
                    removalList.Add(child);
                }
            }
            if (removalList.Count > 0)
            {
                foreach (UIElement child in removalList)
                {
                    grid.Children.Remove(child);
                }
            }

            // Create the Stacked Histogram
            XYChart c = new XYChart(configDisplay.Width, configDisplay.Height);
            //c.setPlotArea(150, 50, configDisplay.Width - 200, configDisplay.Height - 100);
            c.setPlotArea(50, 50, configDisplay.Width - 100, configDisplay.Height - 175);
            //c.addLegend(20, 20);
            c.xAxis().setLabels(xLabels.ToArray());

            // Add a stacked bar layer and set the layer 3D depth to 8 pixels
            BarLayer layer = c.addBarLayer2(Chart.Stack, 8);

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

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

            for (int i = 0; i < chartLabels[1].Count; i++)
            {
                if (GetConfigDisplayData(i, ref dataArray))
                {
                    layer.addDataSet(dataArray, (int) barcodeColors[i], chartLabels[1][i]);
                }
            }

            // Generate an image of the chart
            System.Drawing.Image imgWinForms = c.makeImage();
            BitmapImage bi = new BitmapImage();

            bi.BeginInit();

            MemoryStream ms = new MemoryStream();

            // Save to a memory stream...

            imgWinForms.Save(ms, ImageFormat.Bmp);

            // Rewind the stream...

            ms.Seek(0, SeekOrigin.Begin);

            // Tell the WPF image to use this stream...
            bi.StreamSource = ms;

            bi.EndInit();
            img.Source = bi;
            img.Stretch = Stretch.Uniform;

            Grid.SetColumn(img, 0);
            Grid.SetRow(img, 2);
            grid.Children.Add(img);
        }
Esempio n. 52
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // In this example, the data points are unevenly spaced on the x-axis
            double[]   dataY = { 4.7, 4.7, 6.6, 2.2, 4.7, 4.0, 4.0, 5.1, 4.5, 4.5, 6.8, 4.5, 4, 2.1, 3, 2.5,
                                 2.5, 3.1 };
            DateTime[] dataX = { new DateTime(1999,                                                                   7,  1), new DateTime(2000,                 1,  1), new DateTime(2000,                 2,
                                                                                                                                                                                      1), new DateTime(2000,   4,                1), new DateTime(2000,   5,                8), new DateTime(2000,  7, 5),
                                 new DateTime(2001,                                                                   3,  5), new DateTime(2001,                 4,  7), new DateTime(2001,                 5, 9),
                                 new DateTime(2002,                                                                   2,  4), new DateTime(2002,                 4,  4), new DateTime(2002,                 5, 8),
                                 new DateTime(2002,                                                                   7,  7), new DateTime(2002,                 8, 30), new DateTime(2003,                 1, 2),
                                 new DateTime(2003,                                                                   2, 16), new DateTime(2003,                11,  6), new DateTime(2004,                 1, 4) };

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

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

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

            // Add a title to the chart using 15 points Arial Italic font. Set top/bottom margins to 12
            // pixels.
            ChartDirector.TextBox title = c.addTitle("Multi-Symbol Line Chart Demo", "Arial Italic", 15);
            title.setMargin2(0, 0, 12, 12);

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

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

            legendBox.setAlignment(Chart.BottomCenter);

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

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

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

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

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

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

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

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

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

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

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

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

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

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