Example #1
0
        public void createChart()
        {
            string[] xLabels = null;
            if (data.Count != 0)
            {
                xLabels = new string[data.Count];

                for (int i = 0; i < xLabels.Length; i++)
                {
                    xLabels[i] = (i + 1).ToString();
                }
            }

            XYChart c = new XYChart(795, 455);

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

            //LegendBox legendBox = c.addLegend(450, 80, false, "Arial", 8);
            //legendBox.setAlignment(Chart.BottomCenter);
            //legendBox.setBackground(Chart.Transparent, Chart.Transparent);
            //legendBox.setLineStyleKey();
            //legendBox.setFontSize(8);

            ChartDirector.TextBox title = c.addTitle("傅里叶数据分析", "Arial Bold", 13);
            title.setPos(0, 20);

            c.setPlotArea(50, 60, 730, 345, 0xffffff, -1, -1, c.dashLineColor(
                              0xaaaaaa, Chart.DotLine), -1);

            c.xAxis().setLabels(xLabels);
            c.xAxis().setLabelStep(9);
            c.xAxis().setIndent(true);
            c.xAxis().setTitle("数据序号");
            c.yAxis().setTitle("数据值").setAlignment(Chart.TopLeft2);

            LineLayer layer;
            int       hzColor = Chart.CColor(Color.DeepPink);

            layer = c.addLineLayer2();
            layer.addDataSet(data.ToArray(), hzColor, "数据值");            //.setDataSymbol(Chart.CircleSymbol, 3); ;
            layer.setLineWidth(2);
            layer.setFastLineMode();

            if (minX == maxX)
            {
                c.layout();
                minX = c.xAxis().getMinValue();
                minY = c.yAxis().getMinValue();
                maxX = c.xAxis().getMaxValue();
                maxY = c.yAxis().getMaxValue();
            }

            //SetXYChartScale(minX, minY, maxX, maxY, winChartViewer1, c);
            //winChartViewer1.syncLinearAxisWithViewPort("x", c.xAxis());
            //winChartViewer1.syncLinearAxisWithViewPort("y", c.yAxis());

            winChartViewer1.Chart    = c;
            winChartViewer1.ImageMap =
                winChartViewer1.Chart.getHTMLImageMap("clickable", "", "title='数据序号: {xLabel}, {dataSetName}: {value}'");
        }
Example #2
0
        //Main code for creating chart.
        //Note: the argument img is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, string img)
        {
            // The XY points for the scatter chart
            double[] dataX = { 150, 400, 300, 1500, 800 };
            double[] dataY = { 0.6, 8, 5.4, 2, 4 };

            // The labels for the points
            string[] labels = { "Nano\n100",       "SpeedTron\n200 Lite", "SpeedTron\n200",
                                "Marathon\nExtra", "Marathon\n2000" };

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

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

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

            // Add a title to the y axis using 12 pts Arial Bold Italic font
            c.yAxis().setTitle("Capacity (tons)", "Arial Bold Italic", 12);

            // Add a title to the x axis using 12 pts Arial Bold Italic font
            c.xAxis().setTitle("Range (miles)", "Arial Bold Italic", 12);

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

            // Add the data as a scatter chart layer, using a 15 pixel circle as the
            // symbol
            ScatterLayer layer = c.addScatterLayer(dataX, dataY, "",
                                                   Chart.GlassSphereShape, 15, 0xff3333, 0xff3333);

            // Add labels to the chart as an extra field
            layer.addExtraField(labels);

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

            // Use 8pts Arial Bold to display the labels
            ChartDirector.TextBox textbox = layer.setDataLabelStyle("Arial Bold", 8);

            // Set the background to purple with a 1 pixel 3D border
            textbox.setBackground(0xcc99ff, Chart.Transparent, 1);

            // Put the text box 4 pixels to the right of the data point
            textbox.setAlignment(Chart.Left);
            textbox.setPos(4, 0);

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Range = {x} miles, Capacity = {value} tons'");
        }
Example #3
0
        //Main code for creating chart.
        //Note: the argument img is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, string img)
        {
            // The data for the bar chart
            double[] data = { 3.9, 8.1, 10.9, 14.2, 18.1, 19.0, 21.2, 23.2, 25.7, 36 };

            // The labels for the bar chart
            string[] labels = { "Bastic Group", "Simpa",        "YG Super", "CID",
                                "Giga Tech",    "Indo Digital", "Supreme",  "Electech","THP Thunder",
                                "Flash Light" };

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

            // Add a title to the chart using Arial Bold Italic font
            c.addTitle("Revenue Estimation - Year 2002", "Arial Bold Italic");

            // Set the plotarea at (100, 30) and of size 400 x 200 pixels. Set the
            // plotarea border, background and grid lines to Transparent
            c.setPlotArea(100, 30, 400, 200, Chart.Transparent, Chart.Transparent,
                          Chart.Transparent, Chart.Transparent, Chart.Transparent);

            // Add a bar chart layer using the given data. Use a gradient color for
            // the bars, where the gradient is from dark green (0x008000) to white
            // (0xffffff)
            BarLayer layer = c.addBarLayer(data, c.gradientColor(100, 0, 500, 0,
                                                                 0x008000, 0xffffff));

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

            // Set the bar gap to 10%
            layer.setBarGap(0.1);

            // Use the format "US$ xxx millions" as the bar label
            layer.setAggregateLabelFormat("US$ {value} millions");

            // Set the bar label font to 10 pts Times Bold Italic/dark red (0x663300)
            layer.setAggregateLabelStyle("Times New Roman Bold Italic", 10, 0x663300)
            ;

            // Set the labels on the x axis
            ChartDirector.TextBox textbox = c.xAxis().setLabels(labels);

            // Set the x axis label font to 10pt Arial Bold Italic
            textbox.setFontStyle("Arial Bold Italic");
            textbox.setFontSize(10);

            // Set the x axis to Transparent, with labels in dark red (0x663300)
            c.xAxis().setColors(Chart.Transparent, 0x663300);

            // Set the y axis and labels to Transparent
            c.yAxis().setColors(Chart.Transparent, Chart.Transparent);

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{xLabel}: US${value} millions'");
        }
        //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 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 = { "A", "B", "C", "D", "E", "F", "G", "H" };

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

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

            // Add a title box using grey (0x555555) 18pt Arial font
            ChartDirector.TextBox title = c.addTitle("     Pattern Recognition Accuracy", "Arial",
                                                     18, 0x555555);

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

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

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

            // Add a box whisker layer using light blue (0x99ccee) for the fill color and blue
            // (0x6688aa) for the whisker color. Set line width to 2 pixels. Use rounded corners and
            // bar lighting effect.
            BoxWhiskerLayer b = c.addBoxWhiskerLayer(Q3Data, Q1Data, Q4Data, Q0Data, Q2Data,
                                                     0x99ccee, 0x6688aa);

            b.setLineWidth(2);
            b.setRoundedCorners();
            b.setBorderColor(Chart.Transparent, Chart.barLighting());

            // Adjust the plot area to fit under the title with 10-pixel margin on the other three
            // sides.
            c.packPlotArea(10, title.getHeight(), c.getWidth() - 10, c.getHeight() - 10);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='[{xLabel}] min/med/max = {min}/{med}/{max}\nInter-quartile range: " +
                                                "{bottom} to {top}'");
        }
Example #5
0
        //Main code for creating chart.
        //Note: the argument img is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, string img)
        {
            // The data for the pie chart
            double[] data = { 35, 30, 25, 7, 6, 5, 4, 3, 2, 1 };

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

            // Create a PieChart object of size 560 x 270 pixels, with a golden
            // background and a 1 pixel 3D border
            PieChart c = new PieChart(560, 270, Chart.goldColor(), -1, 1);

            // Add a title box using 15 pts Times Bold Italic font and metallic pink
            // background color
            c.addTitle("Project Cost Breakdown", "Times New Roman Bold Italic", 15
                       ).setBackground(Chart.metalColor(0xff9999));

            // Set the center of the pie at (280, 135) and the radius to 110 pixels
            c.setPieSize(280, 135, 110);

            // Draw the pie in 3D with 20 pixels 3D depth
            c.set3D(20);

            // Use the side label layout method
            c.setLabelLayout(Chart.SideLayout);

            // Set the label box background color the same as the sector color, with
            // glass effect, and with 5 pixels rounded corners
            ChartDirector.TextBox t = c.setLabelStyle();
            t.setBackground(Chart.SameAsMainColor, Chart.Transparent,
                            Chart.glassEffect());
            t.setRoundedCorners(5);

            // Set the border color of the sector the same color as the fill color.
            // Set the line color of the join line to black (0x0)
            c.setLineColor(Chart.SameAsMainColor, 0x000000);

            // Set the start angle to 135 degrees may improve layout when there are
            // many small sectors at the end of the data array (that is, data sorted
            // in descending order). It is because this makes the small sectors
            // position near the horizontal axis, where the text label has the least
            // tendency to overlap. For data sorted in ascending order, a start angle
            // of 45 degrees can be used instead.
            c.setStartAngle(135);

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

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{label}: US${value}K ({percent}%)'");
        }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // Get the selected year and month
            int selectedYear  = int.Parse(Request["year"]);
            int selectedMonth = int.Parse(Request["x"]) + 1;

            //
            // In real life, the data may come from a database based on selectedYear. In this example, we
            // just use a random number generator.
            //
            int      seed     = (selectedYear - 1992) * (100 + 3 * selectedMonth);
            RanTable rantable = new RanTable(seed, 1, 4);

            rantable.setCol(0, seed * 0.003, seed * 0.017);

            double[] data = rantable.getCol(0);

            // The labels for the pie chart
            string[] labels = { "Services", "Hardware", "Software", "Others" };

            // Create a PieChart object of size 600 x 240 pixels
            PieChart c = new PieChart(600, 280);

            // Set the center of the pie at (300, 140) and the radius to 120 pixels
            c.setPieSize(300, 140, 120);

            // Add a title to the pie chart using 18pt Times Bold Italic font
            c.addTitle("Revenue Breakdown for " + selectedMonth + "/" + selectedYear,
                       "Times New Roman Bold Italic", 18);

            // Draw the pie in 3D with 20 pixels 3D depth
            c.set3D(20);

            // Set label format to display sector label, value and percentage in two lines
            c.setLabelFormat("{label}<*br*>${value|2}M ({percent}%)");

            // Set label style to 10pt Arial Bold Italic font. Set background color to the same as the
            // sector color, with reduced-glare glass effect and rounded corners.
            ChartDirector.TextBox t = c.setLabelStyle("Arial Bold Italic", 10);
            t.setBackground(Chart.SameAsMainColor, Chart.Transparent, Chart.glassEffect(
                                Chart.ReducedGlare));
            t.setRoundedCorners();

            // Use side label layout method
            c.setLabelLayout(Chart.SideLayout);

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

            // Create the image and save it in a temporary location
            viewer.Image = c.makeWebImage(Chart.PNG);

            // Create an image map for the chart
            viewer.ImageMap = c.getHTMLImageMap(Url.Action("", "piestub"), "",
                                                "title='{label}:US$ {value|2}M'");
        }
        public void createChartWeekly(WinChartViewer viewer, DataTable errorData, int per)
        {
            try
            {
                Chart.setLicenseCode("DEVP-2LSU-B4LX-YCTY-2DF2-77EE");


                double[] data   = null;
                int[]    color  = null;
                string[] labels = null;
                //  this.chartWidth = this.Width;
                //plottWidth = 900;

                GetDataForChart(errorData, ref labels, ref data, ref color);

                PieChart c = new PieChart(viewer.Width, viewer.Height);
                c.setBorder(10);

                c.addTitle(" BY TYPE", "Calibri Bold", 30
                           ).setBackground(Chart.metalColor(0xff9999));


                c.setPieSize(450, viewer.Height / 2, 150);

                c.set3D(40);

                c.setLabelLayout(Chart.SideLayout);


                ChartDirector.TextBox t = c.setLabelStyle("Arial Bold", 10, Chart.CColor(Color.Blue));
                t.setBackground(Chart.SameAsMainColor, Chart.Transparent,
                                Chart.glassEffect());
                t.setText("{label} ({value})");

                t.setRoundedCorners(4);

                c.setLineColor(Chart.SameAsMainColor);

                c.setStartAngle(15);

                c.setData(data, labels);

                viewer.Chart = c;

                viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                    "title='{label}'");
            }
            catch (Exception)
            {
            }
        }
Example #8
0
        //Main code for creating charts
        public void createChart(WPFChartViewer viewer, int chartIndex)
        {
            // The value to display on the meter
            double value = 72.3;

            // The background and border colors of the meters
            int[] bgColor     = { 0x88ccff, 0xffdddd, 0xffddaa, 0xffccff, 0xdddddd, 0xccffcc };
            int[] borderColor = { 0x000077, 0x880000, 0xee6600, 0x440088, 0x000000, 0x006000 };

            // Create an AngularMeter object of size 250 x 250 pixels with transparent background
            AngularMeter m = new AngularMeter(250, 250, Chart.Transparent);

            // Demonstration two different meter scale angles
            if (chartIndex % 2 == 0)
            {
                // Center at (125, 125), scale radius = 111 pixels, scale angle -140 to +140 degrees
                m.setMeter(125, 125, 111, -140, 140);
            }
            else
            {
                // Center at (125, 125), scale radius = 111 pixels, scale angle -180 to +90 degrees
                m.setMeter(125, 125, 111, -180, 90);
            }

            // Background gradient color with brighter color at the center
            double[] bgGradient = { 0, m.adjustBrightness(bgColor[chartIndex], 3), 0.75, bgColor[
                                        chartIndex] };
            // Add circle with radius 123 pixels as background using the background gradient
            m.addRing(0, 123, m.relativeRadialGradient(bgGradient));
            // Add a ring between radii 116 and 123 pixels as border
            m.addRing(116, 123, borderColor[chartIndex]);

            // Meter scale is 0 - 100, with major/minor/micro ticks every 10/5/1 units
            m.setScale(0, 100, 10, 5, 1);

            // Set the scale label style to 15pt Arial Italic. Set the major/minor/micro tick
            // lengths to 12/9/6 pixels pointing inwards, and their widths to 2/1/1 pixels.
            m.setLabelStyle("Arial Italic", 15);
            m.setTickLength(-12, -9, -6);
            m.setLineWidth(0, 2, 1, 1);

            // Demostrate different types of color scales and putting them at different positions
            double[] smoothColorScale = { 0, 0x3333ff, 25, 0x0088ff, 50, 0x00ff00, 75, 0xdddd00, 100,
                                          0xff0000 };
            double[] stepColorScale    = { 0, 0x00cc00, 60, 0xffdd00, 80, 0xee0000, 100 };
            double[] highLowColorScale = { 0, 0x00ff00, 70, Chart.Transparent, 100, 0xff0000 };

            if (chartIndex == 0)
            {
                // Add the smooth color scale at the default position
                m.addColorScale(smoothColorScale);
            }
            else if (chartIndex == 1)
            {
                // Add the smooth color scale starting at radius 62 with zero width and ending at
                // radius 40 with 22 pixels outer width
                m.addColorScale(smoothColorScale, 62, 0, 40, 22);
            }
            else if (chartIndex == 2)
            {
                // Add green, yellow and red zones between radii 44 and 60
                m.addZone(0, 60, 44, 60, 0x00dd00);
                m.addZone(60, 80, 44, 60, 0xffff00);
                m.addZone(80, 100, 44, 60, 0xff0000);
            }
            else if (chartIndex == 3)
            {
                // Add the high/low color scale at the default position
                m.addColorScale(highLowColorScale);
            }
            else if (chartIndex == 4)
            {
                // Add the smooth color scale at radius 44 with 16 pixels outer width
                m.addColorScale(smoothColorScale, 44, 16);
            }
            else
            {
                // Add the step color scale at the default position
                m.addColorScale(stepColorScale);
            }

            // Add a text label centered at (125, 175) with 15pt Arial Italic font
            m.addText(125, 175, "CPU", "Arial Italic", 15, Chart.TextColor, Chart.Center);

            // Add a readout to some of the charts as demonstration
            if (chartIndex == 0 || chartIndex == 2)
            {
                // Put the value label center aligned at (125, 232), using white (0xffffff) 14pt
                // Arial font on a black (0x000000) background. Set box width to 50 pixels with 5
                // pixels rounded corners.
                ChartDirector.TextBox t = m.addText(125, 232, m.formatValue(value,
                                                                            "<*block,width=50,halign=center*>{value|1}"), "Arial", 14, 0xffffff,
                                                    Chart.BottomCenter);
                t.setBackground(0x000000);
                t.setRoundedCorners(5);
            }

            // Add a red (0xff0000) pointer at the specified value
            m.addPointer2(value, 0xff0000);

            // Output the chart
            viewer.Chart = m;
        }
        private void createChart()
        {
            string[] xLabels = null;
            if (lst_data.Count != 0)
            {
                xLabels = new string[lst_data.Count];

                for (int i = 0; i < xLabels.Length; i++)
                {
                    xLabels[i] = (i + 1).ToString();
                }
            }

            XYChart chart = new XYChart(795, 455);//(857, 448);

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

            ChartDirector.TextBox title1_txt = chart.addTitle("能量强度变化分析", "Arial Bold", 13);
            title1_txt.setPos(0, 20);

            chart.setPlotArea(50, 60, 620, 340, 0xffffff, -1, -1, chart.dashLineColor(Chart.CColor(Color.AliceBlue), Chart.DotLine), -1);
            chart.xAxis().setLabels(xLabels);
            chart.xAxis().setLabelStep(1);
            chart.xAxis().setIndent(true);
            chart.xAxis().setTitle("点数");

            chart.yAxis().setTitle("噪声强度");

            LineLayer layer;

            layer = chart.addLineLayer();
            layer.addDataSet(lst_data.ToArray(), Chart.CColor(Color.Green), "噪声强度");
            layer.setLineWidth(2);
            layer.setFastLineMode(true);

            layer = chart.addLineLayer();
            layer.addDataSet(lst_stdev.ToArray(), Chart.CColor(Color.DarkViolet), "绝对差");
            layer.setLineWidth(2);
            layer.setFastLineMode(true);

            //标准平均值
            Mark standAMPmark = chart.yAxis().addMark(Standard_average, Chart.CColor(Color.Crimson), "", "Arial Bold");

            standAMPmark.setLineWidth(2);
            standAMPmark.setPos(-15, 10);
            standAMPmark.setFontAngle(90);

            //静态漏水标准幅度值
            Mark standAVmark = chart.yAxis().addMark(StandardAMP, Chart.CColor(Color.Cyan), "", "Arial Bold");

            standAVmark.setLineWidth(2);
            standAVmark.setPos(-15, 10);
            standAVmark.setFontAngle(90);

            Mark energymark = chart.yAxis().addMark(energyvalue, Chart.CColor(Color.Chartreuse), "", "Arial Bold");

            LegendBox legendbox = chart.addLegend(672, 60);

            legendbox.addKey("标准平均值", Chart.CColor(Color.Crimson));
            legendbox.addKey("静态漏水标准", Chart.CColor(Color.Cyan));
            legendbox.addKey("能量强度", Chart.CColor(Color.Chartreuse));
            //legendbox.addKey("噪声强度", Chart.CColor(Color.Green));
            //legendbox.addKey("绝对差", Chart.CColor(Color.DarkViolet));

            chart.layout();

            winChartViewer1.Chart    = chart;
            winChartViewer1.ImageMap =
                winChartViewer1.Chart.getHTMLImageMap("clickable", "", "title='点数: {xLabel},强度: {value}'");
        }
Example #10
0
        //Main code for creating chart.
        //Note: the argument img is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, string img)
        {
            // The data for the pie chart
            double[] data = { 25, 18, 15, 12, 8, 30, 35 };

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

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

            c.setRoundedFrame(0xffffff, 20);

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

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

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

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

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

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

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

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

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

            b.setAlignment(Chart.Left);

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

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

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

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{label}: US${value}K ({percent}%)'");
        }
Example #11
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // Data for outer ring
            double[] data = { 88, 124, 96 };

            // Data for inner ring
            double[] data2 = { 77, 87, 45 };

            // Labels for the sectors
            string[] labels = { "Hardware", "Software", "Services" };

            // Colors for the sectors
            int[] colors = { 0xff9999, 0x9999ff, 0x66ff66 };

            //
            // Create the main chart, which contains the chart title, the outer ring, and the legend box
            //

            // Create a PieChart object of size 450 x 360 pixels, with transparent background
            PieChart c = new PieChart(450, 360);

            // Add a title to the chart with 18pt Times Bold Italic font
            c.addTitle("Concentric Donut Chart", "Times New Roman Bold Italic", 18);

            // Set donut center at (160, 200), and outer/inner radii as 150/100 pixels
            c.setDonutSize(160, 200, 150, 100);

            // Add a label at the bottom-right corner of the ring to label the outer ring Use 12pt Arial
            // Bold Italic font in white (ffffff) color, on a green (008800) background, with soft
            // lighting effect and 5 pixels rounded corners
            ChartDirector.TextBox t = c.addText(260, 300, " Year 2006 ", "Arial Bold Italic", 12,
                                                0xffffff);
            t.setBackground(0x008800, Chart.Transparent, Chart.softLighting());
            t.setRoundedCorners(5);

            // Set the legend box at (320, 50) with 12pt Arial Bold Italic font, with no border
            c.addLegend(320, 50, true, "Arial Bold Italic", 13).setBackground(Chart.Transparent,
                                                                              Chart.Transparent);

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

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

            // Set pie border color to white (ffffff)
            c.setLineColor(0xffffff);

            // Set pie label to value in $###M format, percentage in (##.#%) format, in two lines.
            c.setLabelFormat("${value}M<*br*>({percent|1}%)");

            // Use 10pt Airal Bold for the sector labels
            c.setLabelStyle("Arial Bold", 10);

            // Set the label position to -25 pixels from the sector (which would be internal to the
            // sector)
            c.setLabelPos(-25);

            //
            // Create the inner ring.
            //

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

            // Set donut center at (110, 110), and outer/inner radii as 100/50 pixels
            c2.setDonutSize(110, 110, 100, 50);

            // Add a label at the center of the ring to label the inner ring. Use 12pt Arial Bold Italic
            // font in white (ffffff) color, on a deep blue (0000cc) background, with soft lighting
            // effect and 5 pixels rounded corners
            ChartDirector.TextBox t2 = c2.addText(110, 110, " Year 2005 ", "Arial Bold Italic", 12,
                                                  0xffffff, Chart.Center);
            t2.setBackground(0x0000cc, Chart.Transparent, Chart.softLighting());
            t2.setRoundedCorners(5);

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

            // Set the pie colors
            c2.setColors2(Chart.DataColor, colors);

            // Set pie border color to white (ffffff)
            c2.setLineColor(0xffffff);

            // Set pie label to value in $###M format, percentage in (##.#%) format, in two lines.
            c2.setLabelFormat("${value}M<*br*>({percent|1}%)");

            // Use 10pt Airal Bold for the sector labels
            c2.setLabelStyle("Arial Bold", 10);

            // Set the label position to -25 pixels from the sector (which would be internal to the
            // sector)
            c2.setLabelPos(-25);

            // merge the inner ring into the outer ring at (50, 90)
            c.makeChart3().merge(c2.makeChart3(), 50, 90, Chart.TopLeft, 0);

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

            // include tool tip for the chart
            viewer.ImageMap = c2.getHTMLImageMap("", "",
                                                 "title='{label} revenue for 2005: US${value}M ({percent}%)'", 50, 90) +
                              c.getHTMLImageMap("", "", "title='{label} revenue for 2006: US${value}M ({percent}%)'");
        }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The data for the pie chart
            double[] data = { 21, 18, 15, 12, 8, 24 };

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

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

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

            // Use the white on black palette, which means the default text and line colors are white
            c.setColors(Chart.whiteOnBlackPalette);

            // Use a vertical gradient color from deep blue (000066) to blue (0000cc) as background. Use
            // rounded corners of 20 pixels radius. Enable soft drop shadow.
            c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight(), 0x000066, 0x0000cc));
            c.setRoundedFrame(0xffffff, 20);
            c.setDropShadow();

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

            // Set the center of the pie at (300, 195) and the radius to 110 pixels
            c.setPieSize(300, 195, 110);

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

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

            // Use local gradient shading for the sectors, with 5 pixels wide semi-transparent white
            // (bbffffff) borders
            c.setSectorStyle(Chart.LocalGradientShading, unchecked ((int)0xbbffffff), 5);

            // Use the side label layout method
            c.setLabelLayout(Chart.SideLayout);

            // Use 10pt Arial Bold as the default label font. Set the label box background color the same
            // as the sector color. Use soft lighting effect with light direction from right. Use 8
            // pixels rounded corners.
            ChartDirector.TextBox t = c.setLabelStyle("Arial Bold", 10, 0x000000);
            t.setBackground(Chart.SameAsMainColor, Chart.Transparent, Chart.softLighting(Chart.Right, 0))
            ;
            t.setRoundedCorners(8);

            // Set the sector label format. The label is centered in a 110 pixels wide bounding box. It
            // consists of two lines. The first line is the sector name. The second line shows the data
            // value and percentage.
            c.setLabelFormat(
                "<*block,halign=center,width=110*>{label}\n<*font=Arial,size=8*>US$ {value}M " +
                "({percent}%)<*/*>");

            // Explode all sectors 10 pixels from the center
            c.setExplode(-1, 10);

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "", "title='{label}: US${value}M ({percent}%)'");
        }
Example #13
0
        /// <summary>
        /// 绘制噪声数据比较分析图
        /// </summary>
        private void CreateChart(int line)
        {
            if (sRecorder == null)
            {
                return;
            }

            XYChart c = new XYChart(700, 360);

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

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

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

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

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

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


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


            LineLayer layer1;

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

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

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

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

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

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

            winChartViewer1.Chart    = c;
            winChartViewer1.ImageMap = c.getHTMLImageMap("clickable", "",
                                                         "title='噪声频率: {x}Hz, \n{dataSetName}: {value}%'");
        }
        //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'");
        }
        //
        // 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'");
        }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The data for the bar chart
            double[] data = { 1350, 1600, 1950, 2300, 2700 };

            // The labels for the bar chart
            string[] labels = { "2001", "2002", "2003", "2004", "2005" };

            // The colors for the bars
            int[] colors = { 0xcc0000, 0x66aaee, 0xeebb22, 0xcccccc, 0xcc88ff };

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

            // Use the white on black palette, which means the default text and line colors are white
            c.setColors(Chart.whiteOnBlackPalette);

            // Use a vertical gradient color from blue (0000cc) to deep blue (000044) as background. Use
            // rounded corners of 30 pixels radius for the top-left and bottom-right corners.
            c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight(), 0x0000cc, 0x000044));
            c.setRoundedFrame(0xffffff, 30, 0, 30, 0);

            // Add a title using 18pt Times New Roman Bold Italic font. Add 6 pixels top and bottom
            // margins to the title.
            ChartDirector.TextBox title = c.addTitle("Annual Revenue for Star Tech",
                                                     "Times New Roman Bold Italic", 18);
            title.setMargin2(0, 0, 6, 6);

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

            // Tentatively set the plotarea at (70, 80) and of 480 x 240 pixels in size. Use transparent
            // border and white grid lines
            c.setPlotArea(70, 80, 480, 240, -1, -1, Chart.Transparent, 0xffffff);

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

            // Add a multi-color bar chart layer using the supplied data. Use bar gradient lighting with
            // the light intensity from 0.75 to 2.0
            c.addBarLayer3(data, colors).setBorderColor(Chart.Transparent, Chart.barLighting(0.75, 2.0));

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

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

            // Set the bottom y-axis title using 10pt Arial Bold font
            c.yAxis().setTitle("USD (millions)", "Arial Bold", 10);

            // Set y-axes to transparent
            c.yAxis().setColors(Chart.Transparent);
            c.yAxis2().setColors(Chart.Transparent);

            // Disable ticks on the x-axis by setting the tick color to transparent
            c.xAxis().setTickColor(Chart.Transparent);

            // Set the label styles of all axes to 8pt Arial Bold font
            c.xAxis().setLabelStyle("Arial Bold", 8);
            c.yAxis().setLabelStyle("Arial Bold", 8);
            c.yAxis2().setLabelStyle("Arial Bold", 8);

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

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "", "title='Year {xLabel}: US$ {value}M'");
        }
Example #17
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The data for the chart
            double[] data = { 40, 15, 7, 5, 2 };

            // The labels for the chart
            string[] labels = { "Hard Disk", "PCB", "Printer", "CDROM", "Keyboard" };

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

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

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

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

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

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

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

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

            // Add the pareto line using deep blue (0000ff) as the color, with circle symbols
            lineLayer.addDataSet(lineData.result(), 0x0000ff).setDataSymbol(Chart.CircleShape, 9,
                                                                            0x0000ff, 0x0000ff);

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

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

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

            // Add a multi-color bar layer using the given data.
            BarLayer barLayer = c.addBarLayer3(data);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Add a legend box and anchored the top center at the horizontal center
            // of the chart, just under the title. Use 10pts Arial Bold as font, with
            // transparent background and border.
            LegendBox legendBox = c.addLegend(c.getWidth() / 2, title.getHeight(),
                                              false, "Arial Bold", 10);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            c.setRoundedFrame();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='Revenue of {dataSetName} in {xLabel}: US$ {value}M'");
        }
Example #20
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[]   dataY = { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1 };
            DateTime[] dataX = { new DateTime(2008,                                                 7, 1,  0,  0,  0), new DateTime(2008,                 7, 1,  2, 17, 2
                                                                                                                                    ), new DateTime(2008, 7,  1,  8,   5,               30), new DateTime(2008, 7,  1, 10,  54, 10),
                                 new DateTime(2008,                                                 7, 1, 15, 40,  0), new DateTime(2008,                 7, 1, 18, 22, 20),
                                 new DateTime(2008,                                                 7, 1, 22, 17, 14), new DateTime(2008,                 7, 2,  2, 55, 50),
                                 new DateTime(2008,                                                 7, 2,  8, 17, 14), new DateTime(2008,                 7, 2, 11, 55, 50),
                                 new DateTime(2008,                                                 7, 2, 13, 17, 14), new DateTime(2008,                 7, 2, 17, 55, 50),
                                 new DateTime(2008,                                                 7, 2, 20, 17, 14), new DateTime(2008,                 7, 3,  0,  0, 0) };

            // In this example, we only use position 1, 3, 5 for the data series. Positions 0, 2, 4,
            // 6 are empty and serve as gaps.
            string[] labels = { "",                                                                             "ON Only Filling", "",
                                "<*font,color=cc2200*>ON<*/font*> / <*font,color=00aa22*>OFF<*/font*> Filling", "",
                                "Logic Line",                                                                   "" };

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

            // Add a title to the chart using 10 points Arial Bold font. Set top/bottom margins to
            // 12 pixels.
            ChartDirector.TextBox title = c.addTitle("Binary Data Series Demonstration",
                                                     "Arial Bold", 10);

            // Tentatively set the plotarea at (100, 30) and of size 470 x 120 pixels. Use
            // transparent border. Use grey (888888) solid line and light grey (ccccc) dotted line
            // as major and minor vertical grid lines.
            c.setPlotArea(100, 30, 470, 120, -1, -1, Chart.Transparent).setGridColor(
                Chart.Transparent, 0x888888, Chart.Transparent, c.dashLineColor(0xcccccc,
                                                                                Chart.DotLine));

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

            // Set the y axis labels
            c.yAxis().setLabels(labels);

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

            // Set x-axis major and minor tick density to 50 and 5 pixels. ChartDirector
            // auto-scaling will use this as the guideline when putting ticks on the x-axis.
            c.xAxis().setTickDensity(50, 5);

            // Use "<*font=Arial Bold*>{value|mmm dd}" for the first label of an hour, and
            // "{value|hh:nn}" for all other labels.
            c.xAxis().setMultiFormat(Chart.StartOfDayFilter(), "<*font=Arial Bold*>{value|mmm dd}",
                                     Chart.AllPassFilter(), "{value|hh:nn}");

            //
            // A Logic Line can be achieved using a StepLineLayer in ChartDirector
            //

            // Shift the data by 4.5, so instead of 0 - 1, it is now 4.5 to 5.5, or fluctuate around
            // the y = 5 (Logic Line label) position.
            double[] shiftedLine0 = new ArrayMath(dataY).add(4.5).result();

            // Add step lines using the original and the reversed data
            StepLineLayer layer0 = c.addStepLineLayer(shiftedLine0, 0x0000ff);

            layer0.setXData(dataX);

            //
            // To perform ON/OFF filling, we draw the logic line, and its reverse, and fill the
            // region in between
            //

            // Shift the data by 2.5, so instead of 0 - 1, it is now 2.5 to 3.5, or fluctuate around
            // the y = 3 (ON/OFF Filing label) position.
            double[] shiftedLine1 = new ArrayMath(dataY).add(2.5).result();
            // Reverse the data, so the 0 becomes 1 and 1 becomes 0, and shift it as well.
            double[] reverseShiftedLine1 = new ArrayMath(dataY).mul(-1).add(3.5).result();

            // Add step lines using the original and the reversed data
            StepLineLayer layer1 = c.addStepLineLayer(shiftedLine1, Chart.Transparent);

            layer1.addDataSet(reverseShiftedLine1, Chart.Transparent);
            layer1.setXData(dataX);

            // Fill the region between the two step lines with green (00aa22) or red (cc2200),
            // depending on whether the original or the reserve is higher.
            c.addInterLineLayer(layer1.getLine(0), layer1.getLine(1), 0x00aa22, 0xcc2200);

            //
            // The ON Only filling is the same as ON/OFF filling, except the OFF filling color is
            // transparent
            //

            // Shift the data by 0.5, so instead of 0 - 1, it is now 0.5 to 1.5, or fluctuate around
            // the y = 1 (ON Only Filing label) position.
            double[] shiftedLine2 = new ArrayMath(dataY).add(0.5).result();
            // Reverse the data, so the 0 becomes 1 and 1 becomes 0, and shift it as well.
            double[] reverseShiftedLine2 = new ArrayMath(dataY).mul(-1).add(1.5).result();

            // Add step lines using the original and the reversed data
            StepLineLayer layer2 = c.addStepLineLayer(shiftedLine2, Chart.Transparent);

            layer2.addDataSet(reverseShiftedLine2, Chart.Transparent);
            layer2.setXData(dataX);

            // Fill the region between the two step lines with green (00aa22) or transparent,
            // depending on whether the original or the reserve is higher.
            c.addInterLineLayer(layer2.getLine(0), layer2.getLine(1), 0x00aa22, Chart.Transparent);

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

            // Output the chart
            viewer.Chart = c;
        }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer, int chartIndex)
        {
            // The value to display on the meter
            double value = 74.25;

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

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

            // Set the scale region top-left corner at (14, 23), with size of 218 x 20 pixels. The scale
            // labels are located on the top (implies horizontal meter)
            m.setMeter(14, 23, 218, 20, Chart.Top);

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

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

            if (chartIndex == 0)
            {
                // Add the smooth color scale at the default position
                m.addColorScale(smoothColorScale);
            }
            else if (chartIndex == 1)
            {
                // Add the high low scale at the default position
                m.addColorScale(highLowColorScale);
            }
            else if (chartIndex == 2)
            {
                // Add the smooth color scale starting at y = 43 (bottom of scale) with zero width and
                // ending at y = 23 with 20 pixels width
                m.addColorScale(smoothColorScale, 43, 0, 23, 20);
            }
            else
            {
                // Add the step color scale at the default position
                m.addColorScale(stepColorScale);
            }

            // Add a blue (0x0000cc) pointer at the specified value
            m.addPointer(value, 0x0000cc);

            // Add a label left aligned to (10, 61) using 8pt Arial Bold font
            m.addText(10, 61, "Temperature C", "Arial Bold", 8, Chart.TextColor, Chart.Left);

            // Add a text box right aligned to (235, 61). Display the value using white (0xffffff) 8pt
            // Arial Bold font on a black (0x000000) background with depressed rounded border.
            ChartDirector.TextBox t = m.addText(235, 61, m.formatValue(value, "2"), "Arial Bold", 8,
                                                0xffffff, Chart.Right);
            t.setBackground(0x000000, 0x000000, -1);
            t.setRoundedCorners(3);

            // Output the chart
            viewer.Image = m.makeWebImage(Chart.PNG);
        }
Example #22
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 bars and the marks
            double[] barData  = { 100, 125, 245, 147, 67, 96, 160, 145, 97, 167, 220, 125 };
            double[] markData = { 85, 156, 220, 120, 80, 110, 140, 130, 111, 180, 175, 100 };

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

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

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

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

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

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

            legendBox.setAlignment(Chart.BottomCenter);

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Output the chart
            viewer.Chart = c;

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable");
        }
Example #23
0
        //Main code for creating chart.
        //Note: the argument img is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, string img)
        {
            // Data for the chart
            double[] data0 = { 1700, 3900, 2900, 3800, 4100, 4600, 2900, 4100, 4400,
                               5700, 5900, 5200, 3700, 3400, 5100, 5600, 5600, 6000, 7000, 7600,
                               6300, 6700, 7500, 6400, 8800 };
            double[] data1 = { 500, 550, 670, 990, 820, 730, 800, 720, 730, 790, 860,
                               800, 840, 680, 740, 890, 680, 790, 730, 770, 840, 820, 800, 840, 670 }

            ;
            double[] data2 = { 46, 68, 35, 33, 38, 20, 12, 18, 15, 23, 30, 24, 28, 15,
                               21, 26, 46, 42, 38, 25, 23, 32, 24, 20, 25 };
            double[] data3 = { 0.84, 0.82, 0.82, 0.38, 0.25, 0.52, 0.54, 0.52, 0.38,
                               0.51, 0.46, 0.29,  0.5, 0.55, 0.47, 0.34, 0.52, 0.33,0.21, 0.3, 0.25,
                               0.15, 0.18, 0.22, 0.14 };

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            layer0.setLineWidth(2);

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

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

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

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

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

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

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

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} at hour {xLabel} = {value}'");
        }
Example #24
0
        //Main code for creating charts
        public void createChart(WPFChartViewer viewer, int chartIndex)
        {
            // The value to display on the meter
            double value = 72.55;

            // Create an AngularMeter object of size 240 x 170 pixels with very light grey
            // (0xeeeeee) background, and a rounded 4-pixel thick light grey (0xcccccc) border
            AngularMeter m = new AngularMeter(240, 170, 0xeeeeee, 0xcccccc);

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

            // Set the default text and line colors to dark grey (0x222222)
            m.setColor(Chart.TextColor, 0x222222);
            m.setColor(Chart.LineColor, 0x222222);

            // Center at (120, 145), scale radius = 128 pixels, scale angle -60 to +60 degrees
            m.setMeter(120, 145, 128, -60, 60);

            // Meter scale is 0 - 100, with major/minor/micro ticks every 20/10/5 units
            m.setScale(0, 100, 20, 10, 5);

            // Set the scale label style to 14pt Arial Italic. Set the major/minor/micro tick
            // lengths to 16/16/10 pixels pointing inwards, and their widths to 2/1/1 pixels.
            m.setLabelStyle("Arial Italic", 14);
            m.setTickLength(-16, -16, -10);
            m.setLineWidth(0, 2, 1, 1);

            // Demostrate different types of color scales and putting them at different positions
            double[] smoothColorScale = { 0, 0x3333ff, 25, 0x0088ff, 50, 0x00ff00, 75, 0xdddd00, 100,
                                          0xff0000 };
            double[] stepColorScale    = { 0, 0x00cc00, 60, 0xffdd00, 80, 0xee0000, 100 };
            double[] highLowColorScale = { 0, 0x00ff00, 70, Chart.Transparent, 100, 0xff0000 };

            if (chartIndex == 0)
            {
                // Add the smooth color scale at the default position
                m.addColorScale(smoothColorScale);
            }
            else if (chartIndex == 1)
            {
                // Add the smooth color scale starting at radius 128 with zero width and ending at
                // radius 128 with 16 pixels inner width
                m.addColorScale(smoothColorScale, 128, 0, 128, -16);
            }
            else if (chartIndex == 2)
            {
                // Add the smooth color scale starting at radius 70 with zero width and ending at
                // radius 60 with 20 pixels outer width
                m.addColorScale(smoothColorScale, 70, 0, 60, 20);
            }
            else if (chartIndex == 3)
            {
                // Add the high/low color scale at the default position
                m.addColorScale(highLowColorScale);
            }
            else if (chartIndex == 4)
            {
                // Add the step color scale at the default position
                m.addColorScale(stepColorScale);
            }
            else
            {
                // Add the smooth color scale at radius 60 with 15 pixels outer width
                m.addColorScale(smoothColorScale, 60, 15);
            }

            // Add a text label centered at (120, 120) with 15pt Arial Italic font
            m.addText(120, 120, "CPU", "Arial Italic", 15, Chart.TextColor, Chart.BottomCenter);

            // Add a red (0xff0000) pointer at the specified value
            m.addPointer2(value, 0xff0000);

            // Add a semi-transparent light grey (0x3fcccccc) rectangle at (0, 120) and of size 240
            // x 60 pixels to cover the bottom part of the meter for decoration
            ChartDirector.TextBox cover = m.addText(0, 120, "");
            cover.setSize(240, 60);
            cover.setBackground(0x3fcccccc);

            // Output the chart
            viewer.Chart = m;
        }
        //Main code for creating charts
        public void createChart(WPFChartViewer viewer, int chartIndex)
        {
            // The value to display on the meter
            double value = 66.77;

            // Create a LinearMeter object of size 70 x 260 pixels with black background and rounded
            // corners
            LinearMeter m = new LinearMeter(70, 260, 0x000000);

            m.setRoundedFrame(Chart.Transparent);

            // Set the default text and line colors to white (0xffffff)
            m.setColor(Chart.TextColor, 0xffffff);
            m.setColor(Chart.LineColor, 0xffffff);

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

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

            // Add the chart title at the top center
            ChartDirector.TextBox title = m.addText(m.getWidth() / 2, 5, "Temp C", "Arial Bold", 8,
                                                    Chart.TextColor, Chart.TopCenter);

            // Move the scale labels 8 pixels from the meter scale to make room for the color scale
            m.setLabelPos(false, 8);

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

            if (chartIndex == 0)
            {
                // Add a blue (0x0088ff) bar from 0 to value with glass effect and 4 pixel rounded
                // corners
                m.addBar(0, value, 0x0088ff, Chart.glassEffect(Chart.NormalGlare, Chart.Left), 4);
                // Add a 4-pixel thick smooth color scale at x = 29 (left of meter scale)
                m.addColorScale(smoothColorScale, 29, 4);
            }
            else if (chartIndex == 1)
            {
                // Add a yellow (0xCC9922) bar from 0 to value with bar lighting effect
                m.addBar(0, value, 0xcc9922, Chart.barLighting());
                // Add a 4-pixel thick smooth color scale at x = 29 (left of meter scale)
                m.addColorScale(smoothColorScale, 29, 4);

                // Set the title style to black text on a yellow (0xcc9922) background with rounded
                // corners
                title.setFontColor(0x000000);
                title.setBackground(0xcc9922);
                title.setRoundedCorners(2);
            }
            else if (chartIndex == 2)
            {
                // Add a grey (0xaaaaaa) bar from 0 to value with bar lighting effect
                m.addBar(0, value, 0xaaaaaa, Chart.barLighting());
                // Add a 4-pixel high/low color scale at x = 29 (left of meter scale)
                m.addColorScale(highLowColorScale, 29, 4);
            }
            else if (chartIndex == 3)
            {
                // Add a brown (0xbb6622) bar from 0 to value with cylinder lighting effect
                m.addBar(0, value, 0xbb6622, Chart.cylinderEffect());
                // Add a 4 pixel thick brown (0xbb6622) frame
                m.setThickFrame(4, 0xbb6622);
                // Add a high only color scale at x = 29 (left of meter scale)
                m.addColorScale(highColorScale, 29, 4);
            }
            else if (chartIndex == 4)
            {
                // Add a purple (0x7755ee) bar from 0 to value
                m.addBar(0, value, 0x7755ee);
                // Add a 4 pixel thick purple (0x880088) frame
                m.setThickFrame(4, 0x880088);
                // Add a 4-pixel high/low color scale at x = 29 (left of meter scale)
                m.addColorScale(highLowColorScale, 29, 4);
            }
            else
            {
                // Add a green (0x00bb00) bar from 0 to value with soft lighting effect and 4 pixel
                // rounded corners
                m.addBar(0, value, 0x00bb00, Chart.softLighting(), 4);
                // Add a 4-pixel step color scale at x = 29 (left of meter scale)
                m.addColorScale(stepColorScale, 29, 4);
            }

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

            // Output the chart
            viewer.Chart = m;
        }
Example #26
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer, int chartIndex)
        {
            // The value to display on the meter
            double value = 75.35;

            // The bar colors for the meters
            int[] barColor = { 0x0088ff, 0x00cc00, 0x8833dd, 0xff8800 };

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

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

            // This example demonstrates putting the text labels at the top or bottom. This is by setting
            // the label alignment, as well as the scale, color scale and label positions.
            int[] alignment     = { Chart.Top, Chart.Top, Chart.Bottom, Chart.Bottom };
            int[] meterYPos     = { 24, 24, 36, 36 };
            int[] labelYPos     = { 65, 65, 16, 16 };
            int[] colorScalePos = { 48, 48, 27, 27 };

            // Set the scale region
            m.setMeter(18, meterYPos[chartIndex], 222, 20, alignment[chartIndex]);

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

            // Add a 5-pixel thick smooth color scale
            double[] smoothColorScale = { 0, 0x0000ff, 25, 0x0088ff, 50, 0x00ff00, 75, 0xdddd00, 100,
                                          0xff0000 };
            m.addColorScale(smoothColorScale, colorScalePos[chartIndex], 5);

            // Add a bar from 0 to value with glass effect and 4 pixel rounded corners
            m.addBar(0, value, barColor[chartIndex], Chart.glassEffect(Chart.NormalGlare, Chart.Top), 4);

            //
            // In this example, some charts have the "Temperauture" label on the left side and the value
            // readout on the right side, and some charts have the reverse
            //

            if (chartIndex % 2 == 0)
            {
                // Add a label on the left side using 8pt Arial Bold font
                m.addText(15, labelYPos[chartIndex], "Temperature C", "Arial Bold", 8, Chart.TextColor,
                          Chart.Left);

                // Add a text box on the right side. Display the value using white (0xffffff) 8pt Arial
                // Bold font on a black (0x000000) background with depressed rounded border.
                ChartDirector.TextBox t = m.addText(240, labelYPos[chartIndex], m.formatValue(value, "2"
                                                                                              ), "Arial", 8, 0xffffff, Chart.Right);
                t.setBackground(0x000000, 0x000000, -1);
                t.setRoundedCorners(3);
            }
            else
            {
                // Add a label on the right side using 8pt Arial Bold font
                m.addText(243, labelYPos[chartIndex], "Temperature C", "Arial Bold", 8, Chart.TextColor,
                          Chart.Right);

                // Add a text box on the left side. Display the value using white (0xffffff) 8pt Arial
                // Bold font on a black (0x000000) background with depressed rounded border.
                ChartDirector.TextBox t = m.addText(18, labelYPos[chartIndex], m.formatValue(value, "2"),
                                                    "Arial", 8, 0xffffff, Chart.Left);
                t.setBackground(0x000000, 0x000000, -1);
                t.setRoundedCorners(3);
            }

            // Output the chart
            viewer.Image = m.makeWebImage(Chart.PNG);
        }
Example #27
0
        //Main code for creating charts
        public void createChart(WinChartViewer viewer, int chartIndex)
        {
            // The value to display on the meter
            double value = 75.35;

            // The background, border and bar colors of the meters
            int[] bgColor     = { 0xbbddff, 0xccffcc, 0xffddff, 0xffffaa, 0xffdddd, 0xeeeeee };
            int[] borderColor = { 0x000088, 0x006600, 0x880088, 0xee6600, 0x880000, 0x666666 };
            int[] barColor    = { 0x0088ff, 0x00cc00, 0x8833dd, 0xff8800, 0xee3333, 0x888888 };

            // Create a LinearMeter object of size 260 x 80 pixels with a 3-pixel thick rounded
            // frame
            LinearMeter m = new LinearMeter(260, 80, bgColor[chartIndex], borderColor[chartIndex]);

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

            // Set the scale region top-left corner at (18, 24), with size of 222 x 20 pixels. The
            // scale labels are located on the top (implies horizontal meter)
            m.setMeter(18, 24, 222, 20, Chart.Top);

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

            if (chartIndex % 4 == 0)
            {
                // Add a 5-pixel thick smooth color scale at y = 48 (below the meter scale)
                double[] smoothColorScale = { 0,   0x0000ff, 25, 0x0088ff, 50, 0x00ff00, 75, 0xdddd00,
                                              100, 0xff0000 };
                m.addColorScale(smoothColorScale, 48, 5);
            }
            else if (chartIndex % 4 == 1)
            {
                // Add a 5-pixel thick step color scale at y = 48 (below the meter scale)
                double[] stepColorScale = { 0, 0x00cc00, 50, 0xffdd00, 80, 0xff3333, 100 };
                m.addColorScale(stepColorScale, 48, 5);
            }
            else if (chartIndex % 4 == 2)
            {
                // Add a 5-pixel thick high/low color scale at y = 48 (below the meter scale)
                double[] highLowColorScale = { 0,                 0x0000ff, 40, Chart.Transparent, 60,
                                               Chart.Transparent,      100, 0xff0000 };
                m.addColorScale(highLowColorScale, 48, 5);
            }
            else
            {
                // Add a 5-pixel thick high only color scale at y = 48 (below the meter scale)
                double[] highColorScale = { 70, Chart.Transparent, 100, 0xff0000 };
                m.addColorScale(highColorScale, 48, 0, 48, 8);
            }

            // Add a bar from 0 to value with glass effect and 4 pixel rounded corners
            m.addBar(0, value, barColor[chartIndex], Chart.glassEffect(Chart.NormalGlare, Chart.Top
                                                                       ), 4);

            // Add a label right aligned to (243, 65) using 8pt Arial Bold font
            m.addText(243, 65, "Temperature C", "Arial Bold", 8, Chart.TextColor, Chart.Right);

            // Add a text box left aligned to (18, 65). Display the value using white (0xffffff) 8pt
            // Arial Bold font on a black (0x000000) background with depressed rounded border.
            ChartDirector.TextBox t = m.addText(18, 65, m.formatValue(value, "2"), "Arial", 8,
                                                0xffffff, Chart.Left);
            t.setBackground(0x000000, 0x000000, -1);
            t.setRoundedCorners(3);

            // Output the chart
            viewer.Chart = m;
        }
Example #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 pie chart
            double[] data = { 20, 10, 15, 12 };

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{label}: US${value}K ({percent}%)'");
        }
Example #29
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // In this example, the data points are unevenly spaced on the x-axis
            double[]   dataY = { 4.7, 4.7, 6.6, 2.2, 4.7, 4.0, 4.0, 5.1, 4.5, 4.5, 6.8, 4.5, 4, 2.1, 3, 2.5,
                                 2.5, 3.1 };
            DateTime[] dataX = { new DateTime(1999,                                                                   7,  1), new DateTime(2000,                 1,  1), new DateTime(2000,                 2,
                                                                                                                                                                                      1), new DateTime(2000,   4,                1), new DateTime(2000,   5,                8), new DateTime(2000,  7, 5),
                                 new DateTime(2001,                                                                   3,  5), new DateTime(2001,                 4,  7), new DateTime(2001,                 5, 9),
                                 new DateTime(2002,                                                                   2,  4), new DateTime(2002,                 4,  4), new DateTime(2002,                 5, 8),
                                 new DateTime(2002,                                                                   7,  7), new DateTime(2002,                 8, 30), new DateTime(2003,                 1, 2),
                                 new DateTime(2003,                                                                   2, 16), new DateTime(2003,                11,  6), new DateTime(2004,                 1, 4) };

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

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

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

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

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

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

            legendBox.setAlignment(Chart.BottomCenter);

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "", "title='{x|mmm dd, yyyy}: {value}%'");
        }
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WPFChartViewer viewer, int chartIndex)
        {
            // The data for the bar chart
            double[] data0 = { 100, 125, 245, 147, 67 };
            double[] data1 = { 85, 156, 179, 211, 123 };
            double[] data2 = { 97, 87, 56, 267, 157 };

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

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

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

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

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

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

            legendBox.setAlignment(Chart.TopRight);

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

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

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

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

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

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

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

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

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

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

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} revenue on {xLabel}: US${value}K ({percent}%)'");
        }