Exemplo n.º 1
0
        private void drawFullChart(WPFViewPortControl vpc, WPFChartViewer viewer)
        {
            // Create an XYChart object of size 640 x 60 pixels
            XYChart c = new XYChart(640, 60);

            // Set the plotarea with the same horizontal position as that in the main chart for alignment.
            c.setPlotArea(55, 0, c.getWidth() - 80, c.getHeight() - 1, 0xc0d8ff, -1, 0x888888,
                          Chart.Transparent, 0xffffff);

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

            // Put the x-axis labels inside the plot area by setting a negative label gap. Use
            // setLabelAlignment to put the label at the right side of the tick.
            c.xAxis().setLabelGap(-1);
            c.xAxis().setLabelAlignment(1);

            // Set the y axis stem and labels to transparent (that is, hide the labels)
            c.yAxis().setColors(Chart.Transparent, Chart.Transparent);

            // Add a line layer for the lines with fast line mode enabled
            LineLayer layer = c.addLineLayer();

            layer.setFastLineMode();

            // Now we add the 3 data series to a line layer, using the color red (0xff3333), green
            // (0x008800) and blue (0x3333cc)
            layer.setXData(timeStamps);
            layer.addDataSet(dataSeriesA, 0xff3333);
            layer.addDataSet(dataSeriesB, 0x008800);
            layer.addDataSet(dataSeriesC, 0x3333cc);

            // The x axis scales should reflect the full range of the view port
            c.xAxis().setDateScale(viewer.getValueAtViewPort("x", 0), viewer.getValueAtViewPort("x", 1));

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

            // For the auto-scaled y-axis, as we hide the labels, we can disable axis rounding. This can
            // make the axis scale fit the data tighter.
            c.yAxis().setRounding(false, false);

            // Output the chart
            vpc.Chart = c;
        }
Exemplo n.º 2
0
        //
        // Draw the chart.
        //
        private void drawChart(WinChartViewer viewer)
        {
            // Get the start date and end date that are visible on the chart.
            double viewPortStartDate = viewer.getValueAtViewPort("x", viewer.ViewPortLeft);
            double viewPortEndDate   = viewer.getValueAtViewPort("x", viewer.ViewPortLeft +
                                                                 viewer.ViewPortWidth);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Set the chart image to the WinChartViewer
            viewer.Chart = c;
        }
        //
        // Draw the chart.
        //
        private void drawChart(WinChartViewer viewer)
        {
            // Get the start date and end date that are visible on the chart.
            DateTime viewPortStartDate = Chart.NTime(viewer.getValueAtViewPort("x", viewer.ViewPortLeft));
            DateTime viewPortEndDate   = Chart.NTime(viewer.getValueAtViewPort("x", viewer.ViewPortLeft +
                                                                               viewer.ViewPortWidth));

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            layer.setLineWidth(2);

            // In this demo, we do not have too many data points. In real code, the chart may contain a lot
            // of data points when fully zoomed out - much more than the number of horizontal pixels in this
            // plot area. So it is a good idea to use fast line mode.
            layer.setFastLineMode();

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

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

            // Set the x-axis as a date/time axis with the scale according to the view port x range.
            viewer.syncDateAxisWithViewPort("x", c.xAxis());

            // In this demo, we rely on ChartDirector to auto-label the axis. We ask ChartDirector to ensure
            // the x-axis labels are at least 75 pixels apart to avoid too many labels.
            c.xAxis().setTickDensity(75);

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

            viewer.Chart = c;
        }
Exemplo n.º 4
0
        //
        // Draw the chart.
        //
        private void drawChart(WPFChartViewer viewer)
        {
            // Get the start date and end date that are visible on the chart.
            DateTime viewPortStartDate = Chart.NTime(viewer.getValueAtViewPort("x", viewer.ViewPortLeft));
            DateTime viewPortEndDate   = Chart.NTime(viewer.getValueAtViewPort("x", viewer.ViewPortLeft +
                                                                               viewer.ViewPortWidth));

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

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

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

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

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

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

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

            // Add a title to the chart using 15pt Arial Bold font
            c.addTitle("   Zooming and Scrolling with Viewport Control", "Arial Bold", 15);

            // Set legend icon style to use line style icon, sized for 10pt font
            c.getLegend().setLineStyleKey();
            c.getLegend().setFontSize(10);

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

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

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

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

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

            layer.setLineWidth(2);

            // In this demo, we do not have too many data points. In real code, the chart may contain a lot
            // of data points when fully zoomed out - much more than the number of horizontal pixels in this
            // plot area. So it is a good idea to use fast line mode.
            layer.setFastLineMode();

            // Now we add the 3 data series to a line layer, using the color red (ff33333), green (008800)
            // and blue (3333cc)
            layer.setXData(viewPortTimeStamps);
            layer.addDataSet(viewPortDataSeriesA, 0xff3333, "Alpha");
            layer.addDataSet(viewPortDataSeriesB, 0x008800, "Beta");
            layer.addDataSet(viewPortDataSeriesC, 0x3333cc, "Gamma");

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

            // Set the x-axis as a date/time axis with the scale according to the view port x range.
            viewer.syncDateAxisWithViewPort("x", c.xAxis());

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

            //
            // In this demo, the time range can be from a few years to a few days. We demonstrate how to set
            // up different date/time format based on the time range.
            //

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

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

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

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

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

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

            viewer.Chart = c;
        }
Exemplo n.º 5
0
        //
        // Draw the chart.
        //
        private void drawChart(WPFChartViewer viewer)
        {
            // Get the start date and end date that are visible on the chart.
            double viewPortStartDate = viewer.getValueAtViewPort("x", viewer.ViewPortLeft);
            double viewPortEndDate   = viewer.getValueAtViewPort("x", viewer.ViewPortLeft + viewer.ViewPortWidth);

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

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

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

                // Keep track of the latest available data at chart plotting time
                trackLineEndPos = timeStamps[currentIndex - 1];
            }

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

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

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

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

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

            // Add a title to the chart using 18 pts Times New Roman Bold Italic font
            c.addTitle("   Multithreading Real-Time Chart", "Arial", 18);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            viewer.Chart = c;
        }
        //
        // Draw the chart.
        //
        private void drawChart(WPFChartViewer viewer)
        {
            // Get the start date and end date that are visible on the chart.
            DateTime viewPortStartDate = Chart.NTime(viewer.getValueAtViewPort("x", viewer.ViewPortLeft));
            DateTime viewPortEndDate   = Chart.NTime(viewer.getValueAtViewPort("x", viewer.ViewPortLeft +
                                                                               viewer.ViewPortWidth));

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            viewer.Chart = c;
        }
        //
        // Draw the chart
        //
        private void drawChart(RazorChartViewer viewer)
        {
            // Determine the visible x-axis range
            DateTime viewPortStartDate = Chart.NTime(viewer.getValueAtViewPort("x", viewer.ViewPortLeft))
            ;
            DateTime viewPortEndDate = Chart.NTime(viewer.getValueAtViewPort("x", viewer.ViewPortLeft +
                                                                             viewer.ViewPortWidth));

            // We need to get the data within the visible x-axis range. In real code, this can be by
            // using a database query or some other means as specific to the application. In this demo,
            // we just generate a random data table, and then select the data within the table.
            RanTable r = getRandomTable();

            // Select the data for the visible date range viewPortStartDate to viewPortEndDate. It is
            // possible there is no data point at exactly viewPortStartDate or viewPortEndDate. In this
            // case, we also need the data points that are just outside the visible date range to
            // "overdraw" the line a little bit (the "overdrawn" part will be clipped to the plot area)
            // In this demo, we do this by adding a one day margin to the date range when selecting the
            // data.
            r.selectDate(0, viewPortStartDate.AddDays(-1), viewPortEndDate.AddDays(1));

            // The selected data from the random data table
            DateTime[] timeStamps  = Chart.NTime(r.getCol(0));
            double[]   dataSeriesA = r.getCol(1);
            double[]   dataSeriesB = r.getCol(2);
            double[]   dataSeriesC = r.getCol(3);

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

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

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

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

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

            // Add a title to the chart using 18pt Times New Roman Bold Italic font
            c.addTitle("    Zooming and Scrolling with Track Line", "Times New Roman Bold Italic", 18);

            // Set the axis stem to transparent
            c.xAxis().setColors(Chart.Transparent);
            c.yAxis().setColors(Chart.Transparent);

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

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

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

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

            layer.setLineWidth(2);

            // In this demo, we do not have too many data points. In real code, the chart may contain a
            // lot of data points when fully zoomed out - much more than the number of horizontal pixels
            // in this plot area. So it is a good idea to use fast line mode.
            layer.setFastLineMode();

            // Add up to 3 data series to a line layer, depending on whether the user has selected the
            // data series.
            layer.setXData(timeStamps);
            if (viewer.GetCustomAttr("data0CheckBox") != "F")
            {
                layer.addDataSet(dataSeriesA, 0xff3333, "Alpha Series");
            }
            if (viewer.GetCustomAttr("data1CheckBox") != "F")
            {
                layer.addDataSet(dataSeriesB, 0x008800, "Beta Series");
            }
            if (viewer.GetCustomAttr("data2CheckBox") != "F")
            {
                layer.addDataSet(dataSeriesC, 0x3333cc, "Gamma Series");
            }

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

            // Set the x-axis as a date/time axis with the scale according to the view port x range.
            viewer.syncDateAxisWithViewPort("x", c.xAxis());

            //
            // In this demo, the time range can be from a few years to a few days. We demonstrate how to
            // set up different date/time format based on the time range.
            //

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

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

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

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

            //================================================================================
            // Step 5 - Output the chart
            //================================================================================

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

            // Output Javascript chart model to the browser to suppport tracking cursor
            viewer.ChartModel = c.getJsChartModel();
        }
Exemplo n.º 8
0
        //
        // Draw the chart
        //
        private void drawChart(WPFChartViewer viewer)
        {
            // Have not started collecting data ???
            if (currentIndex <= 0)
            {
                return;
            }

            // The start time is equal to the latest time minus the time range of the chart
            double startTime  = timeStamps[currentIndex - 1] - timeRange;
            int    startIndex = (int)Math.Ceiling(Chart.bSearch(timeStamps, 0, currentIndex, startTime) - 0.1);

            // For a sweep chart, if the line goes beyond the right border, it will wrap back to
            // the left. We need to determine the wrap position (the right border).
            double wrapTime   = Math.Floor(startTime / timeRange + 1) * timeRange;
            double wrapIndex  = Chart.bSearch(timeStamps, 0, currentIndex, wrapTime);
            int    wrapIndexA = (int)Math.Ceiling(wrapIndex);
            int    wrapIndexB = (int)Math.Floor(wrapIndex);

            // The data arrays and the colors and names of the data series
            var allArrays = new[] { timeStamps, channel1, channel2 };

            int[]    colors = { 0xff0000, 0x00cc00 };
            string[] names  = { "Channel 1", "Channel 2" };

            // Split all data arrays into two parts A and B at the wrap position. The B part is the
            // part that is wrapped back to the left.
            var allArraysA = new double[allArrays.Length][];
            var allArraysB = new double[allArrays.Length][];

            for (int i = 0; i < allArrays.Length; ++i)
            {
                allArraysA[i] = (double[])Chart.arraySlice(allArrays[i], startIndex, wrapIndexA - startIndex + 1);
                allArraysB[i] = (double[])Chart.arraySlice(allArrays[i], wrapIndexB, currentIndex - wrapIndexB);
            }

            // Normalize the plotted timeStamps (the first element of allArrays) to start from 0
            for (int i = 0; i < allArraysA[0].Length; ++i)
            {
                allArraysA[0][i] -= wrapTime - timeRange;
            }
            for (int i = 0; i < allArraysB[0].Length; ++i)
            {
                allArraysB[0][i] -= wrapTime;
            }

            //
            // Now we have prepared all the data and can plot the chart.
            //

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

            // Create an XYChart object the same size as WPFChartViewer, with a minimum of 300 x 150
            XYChart c = new XYChart(Math.Max(300, (int)viewer.ActualWidth), Math.Max(150, (int)viewer.ActualHeight));

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

            // In our code, we can overdraw the line slightly, so we clip it to the plot area.
            c.setClipping();

            // Add a legend box at the right side using horizontal layout. Use 10pt Arial Bold as font. Set
            // the background and border color to Transparent and use line style legend key.
            LegendBox b = c.addLegend(c.getWidth() - 1, 10, false, "Arial Bold", 10);

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

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

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

            // Configure the x-axis labels to be to the left of the vertical grid lines
            c.xAxis().setLabelAlignment(1);

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

            // Draw the lines, which consists of A segments and B segments (the wrapped segments)
            foreach (var dataArrays in new[] { allArraysA, allArraysB })
            {
                LineLayer layer = c.addLineLayer2();
                layer.setLineWidth(2);
                layer.setFastLineMode();

                // The first element of dataArrays is the timeStamp, and the rest are the data.
                layer.setXData(dataArrays[0]);
                for (int i = 1; i < dataArrays.Length; ++i)
                {
                    layer.addDataSet(dataArrays[i], colors[i - 1], names[i - 1]);
                }

                // Disable legend entries for the B lines to avoid duplication with the A lines
                if (dataArrays == allArraysB)
                {
                    layer.setLegend(Chart.NoLegend);
                }
            }

            // The B segments contain the latest data. We add a vertical line at the latest position.
            int  lastIndex = allArraysB[0].Length - 1;
            Mark m         = c.xAxis().addMark(allArraysB[0][lastIndex], -1);

            m.setMarkColor(0x0000ff, Chart.Transparent, Chart.Transparent);
            m.setDrawOnTop(false);

            // We also add a symbol and a label for each data series at the latest position
            for (int i = 1; i < allArraysB.Length; ++i)
            {
                // Add the symbol
                Layer layer = c.addScatterLayer(new double[] { allArraysB[0][lastIndex] }, new double[] {
                    allArraysB[i][lastIndex]
                }, "", Chart.CircleSymbol, 9, colors[i - 1], colors[i - 1]);
                layer.moveFront();

                // Add the label
                string label = "<*font,bgColor=" + colors[i - 1].ToString("x") + "*> {value|P4} <*/font*>";
                layer.setDataLabelFormat(label);

                // The label style
                ChartDirector.TextBox t = layer.setDataLabelStyle("Arial Bold", 10, 0xffffff);
                bool isOnLeft           = allArraysB[0][lastIndex] <= timeRange / 2;
                t.setAlignment(isOnLeft ? Chart.Left : Chart.Right);
                t.setMargin(isOnLeft ? 5 : 0, isOnLeft ? 0 : 5, 0, 0);
            }

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

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

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

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

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

            viewer.Chart = c;
        }
Exemplo n.º 9
0
        //public void createChart(WinChartViewer viewer, int chartIndex)
        public void drawChart(WinChartViewer viewer, double[] data, int color, bool init)
        {
            int startIndex, endIndex;

            // Get the start date and end date that are visible on the chart.
            DateTime viewPortStartDate = Chart.NTime(viewer.getValueAtViewPort("x", viewer.ViewPortLeft));
            DateTime viewPortEndDate   = Chart.NTime(viewer.getValueAtViewPort("x", viewer.ViewPortLeft +
                                                                               viewer.ViewPortWidth));

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

            if (init == true)
            {
                startIndex = 0;
                endIndex   = data.Length;
            }
            else
            {
                startIndex = (int)Math.Floor(Chart.bSearch2(timeStamps, 0, currentIndex, viewPortStartDate)); //Real Trend
                endIndex   = (int)Math.Ceiling(Chart.bSearch2(timeStamps, 0, currentIndex, viewPortEndDate)); //Real Trend
            }

            int noOfPoints = endIndex - startIndex + 1;

            viewPortTimeStamps = (DateTime[])Chart.arraySlice(timeStamps, startIndex, noOfPoints);
            viewPortData       = (double[])Chart.arraySlice(data, startIndex, noOfPoints);

            XYChart c = new XYChart(776, 197, 0x787878, 0x787878);

            /*            c.setPlotArea(30, 10, c.getWidth() - 40, c.getHeight() - 50,
             *              0x787878, -1, Chart.Transparent,
             *              c.dashLineColor(0xffffff, 0x000303), c.dashLineColor(0xffffff, 0x000303));
             */

            c.setPlotArea(30, 10, c.getWidth() - 40, c.getHeight() - 50, 0x000000, 0x000000, Chart.LineColor, 0xc0c0c0, 0x000000
                          ).setGridWidth(2, 1, 1, 1);

/*            c.setPlotArea(30, 10, c.getWidth() - 40, c.getHeight() - 50, c.linearGradientColor(0, 55, 0,
 *  c.getHeight() - 35, 0xf5f5f5, 0x787878), -1, Chart.Transparent, 0xffffff, 0xffffff);*/

            c.xAxis().setColors(0xffffff, 0xffffff, 0xffffff);
            c.yAxis().setColors(0xffffff, 0xffffff, 0xffffff);

            c.setClipping();

            sb_d.Clear();
            sb_d.AppendFormat("{{value|hh:nn:ss.f}}");

            c.xAxis().setLabelFormat(sb_d.ToString());

            c.setClipping();

            LineLayer layer = c.addLineLayer2();

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

            layer.setXData(viewPortTimeStamps);
            layer.addDataSet(viewPortData, color, "Heart");

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

            //viewer.syncDateAxisWithViewPort("x", c.xAxis());

            c.xAxis().setTickDensity(75);
            c.yAxis().setTickDensity(30);

            c.xAxis().setLabelStep(100);

            c.xAxis().setMinTickInc(1);

            viewer.Chart = c;

            if (viewer.ImageMap == null)
            {
                viewer.ImageMap = viewer.Chart.getHTMLImageMap("", "", "");
            }
        }
        private void drawChart(WinChartViewer viewer)
        {
            // get the start index that are visible on the chart
            double viewPortStartIndex = viewer.getValueAtViewPort("x", viewer.ViewPortLeft);
            double viewPortEndIndex   = viewer.getValueAtViewPort("x", viewer.ViewPortLeft + viewer.ViewPortWidth);

            // Get the array indexes that corresponds to the visible start and end
            int startIndex = (int)Math.Floor(Chart.bSearch(index, viewPortStartIndex));
            int endIndex   = (int)Math.Ceiling(Chart.bSearch(index, viewPortEndIndex));

            Console.WriteLine("port start: " + viewPortStartIndex + " port end: " + viewPortEndIndex + " start: " + startIndex + " end: " + endIndex + " index length: " + index.Length);

            int noOfPoints = endIndex - startIndex + 1;

            // declaration the data set
            double[] viewPortDataSeriesCpu;
            double[] viewPortDataSeriesGpu;
            double[] viewPortDataSeriesFps;
            double[] viewPortDataSeriesCmd;
            double[] viewPortDataSeriesObj;
            double[] viewPortDataSeriesTriangle;
            double[] viewPortDataSeriesDrawTime;
            double[] viewPortDataSeriesDataSize;
            double[] viewPortDataSeriesIbLock;
            double[] viewPortDataSeriesIbSize;
            double[] viewPortDataSeriesVbLock;
            double[] viewPortDataSeriesVbSize;
            double[] viewPortDataSeriesParamSize;
            double[] viewPortDataSeriesRemoteParamSize;
            double[] viewPortDataSeriesSurLock;
            double[] viewPortDataSeriesSurSize;
            double[] viewPortDataSeriesTexLock;
            double[] viewPortDataSeriesTexSize;
            double[] viewPortDataSeriesSetTexture;
            double[] viewPortDataSeriesStateBlock;
            double[] viewPortDataSeriesVShaderCmd;
            double[] viewPortDataSeriesVShaderConst;
            double[] viewPortDataSeriesPShaderCmd;
            double[] viewPortDataSeriesPShaderConst;

            double[] viewPortIndex = (double[])Chart.arraySlice(index, startIndex, noOfPoints);
            if (this.showCpu)
            {
                viewPortDataSeriesCpu = (double[])Chart.arraySlice(cpu, startIndex, noOfPoints);
            }
            if (this.showGpu)
            {
                viewPortDataSeriesGpu = (double[])Chart.arraySlice(gpu, startIndex, noOfPoints);
            }
            if (this.showFps)
            {
                viewPortDataSeriesFps = (double[])Chart.arraySlice(fps, startIndex, noOfPoints);
            }
            if (this.showCmd)
            {
                viewPortDataSeriesCmd = (double[])Chart.arraySlice(cmd, startIndex, noOfPoints);
            }

            if (this.showObj)
            {
                viewPortDataSeriesObj = (double[])Chart.arraySlice(obj, startIndex, noOfPoints);
            }
            if (this.showTriangle)
            {
                viewPortDataSeriesTriangle = (double[])Chart.arraySlice(triangle, startIndex, noOfPoints);
            }
            if (this.showDrawTime)
            {
                viewPortDataSeriesDrawTime = (double[])Chart.arraySlice(draw, startIndex, noOfPoints);
            }
            if (this.showDataSize)
            {
                viewPortDataSeriesDataSize = (double[])Chart.arraySlice(data, startIndex, noOfPoints);
            }
            if (this.showIbLock)
            {
                viewPortDataSeriesIbLock = (double[])Chart.arraySlice(ibLock, startIndex, noOfPoints);
            }
            if (this.showIbSize)
            {
                viewPortDataSeriesIbSize = (double[])Chart.arraySlice(ibSize, startIndex, noOfPoints);
            }

            if (this.showVbLock)
            {
                viewPortDataSeriesVbLock = (double[])Chart.arraySlice(vbLock, startIndex, noOfPoints);
            }
            if (this.showVbSize)
            {
                viewPortDataSeriesVbSize = (double[])Chart.arraySlice(vbSize, startIndex, noOfPoints);
            }
            if (this.showParamSize)
            {
                viewPortDataSeriesParamSize = (double[])Chart.arraySlice(parameterSize, startIndex, noOfPoints);
            }
            if (this.showRemoteParamSize)
            {
                viewPortDataSeriesRemoteParamSize = (double[])Chart.arraySlice(remoteParamSize, startIndex, noOfPoints);
            }
            if (this.showSurLock)
            {
                viewPortDataSeriesSurLock = (double[])Chart.arraySlice(surLock, startIndex, noOfPoints);
            }

            if (this.showSurSize)
            {
                viewPortDataSeriesSurSize = (double[])Chart.arraySlice(surSize, startIndex, noOfPoints);
            }
            if (this.showTexLock)
            {
                viewPortDataSeriesTexLock = (double[])Chart.arraySlice(texLock, startIndex, noOfPoints);
            }
            if (this.showTexSize)
            {
                viewPortDataSeriesTexSize = (double[])Chart.arraySlice(texSize, startIndex, noOfPoints);
            }
            if (this.showSetTexTime)
            {
                viewPortDataSeriesSetTexture = (double[])Chart.arraySlice(setTex, startIndex, noOfPoints);
            }
            if (this.showStateBlock)
            {
                viewPortDataSeriesStateBlock = (double[])Chart.arraySlice(stateBlock, startIndex, noOfPoints);
            }

            if (this.showVShaderCmd)
            {
                viewPortDataSeriesVShaderCmd = (double[])Chart.arraySlice(vShaderCmd, startIndex, noOfPoints);
            }
            if (this.showVShaderConst)
            {
                viewPortDataSeriesVShaderConst = (double[])Chart.arraySlice(vShaderConst, startIndex, noOfPoints);
            }
            if (this.showPShaderCmd)
            {
                viewPortDataSeriesPShaderCmd = (double[])Chart.arraySlice(pShaderCmd, startIndex, noOfPoints);
            }
            if (this.showPShaderConst)
            {
                viewPortDataSeriesPShaderConst = (double[])Chart.arraySlice(pShaderConst, startIndex, noOfPoints);
            }



            // configure overall chart apperance
            XYChart c = new XYChart(820, 490);

            c.setPlotArea(55, 50, c.getWidth() - 80, c.getHeight() - 85, c.linearGradientColor(0, 50, 0, c.getHeight() - 35, 0xf0f6ff, 0xa0c0ff), -1, Chart.Transparent, 0xffffff, 0xfffff);

            c.setClipping();

            c.addTitle(" All charactor for game", "Times New Roman Bold Italic", 10);

            // Set legend icon style to use line style icon, sized for 8pt font
            c.getLegend().setLineStyleKey();
            c.getLegend().setFontSize(8);


            //LegendBox b = c.addLegend(55, 25, false, "Arial Bold", 8);
            //b.setBackground(Chart.Transparent);
            //b.setLineStyleKey();

            // set the axis stem to transparent
            c.xAxis().setColors(Chart.Transparent);
            c.yAxis().setColors(Chart.Transparent);

            // add the y axixs title
            c.yAxis().setTitle("chractor", "Arial Bold Italic", 10);

            // add data to chart

            LineLayer layer = c.addLineLayer2();

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


            layer.setXData(this.index);

            /*
             * layer.addDataSet(viewPortDataSeriesCpu, 0xff3333, "CPU");
             * layer.addDataSet(viewPortDataSeriesGpu, 0x008800, "GPU");
             * layer.addDataSet(viewPortDataSeriesFps, 0x3333cc, "FPS");
             */
            if (this.showCpu)
            {
                layer.addDataSet(cpu, 0xff3333, "CPU");
            }
            if (this.showGpu)
            {
                layer.addDataSet(gpu, 0x008800, "GPU");
            }
            if (this.showFps)
            {
                layer.addDataSet(fps, 0x3333cc, "FPS");
            }


            if (this.showCmd)
            {
                layer.addDataSet(cmd, 0x3388cc, "CMD");
            }

            if (this.showObj)
            {
                layer.addDataSet(obj, 0x8833cc, "OBJ");
            }
            if (this.showTriangle)
            {
                layer.addDataSet(triangle, 0x333388, "TRI");
            }
            if (this.showDrawTime)
            {
                layer.addDataSet(draw, 0xff0000, "DRAW");
            }
            if (this.showDataSize)
            {
                layer.addDataSet(data, 0xff00cc, "DATA");
            }
            if (this.showIbLock)
            {
                layer.addDataSet(ibLock, 0x8888cc, "IBLOCK");
            }
            if (this.showIbSize)
            {
                layer.addDataSet(ibSize, 0x8833cc, "IBSIZE");
            }

            if (this.showVbLock)
            {
                layer.addDataSet(vbLock, 0x3333cc, "VBLOCK");
            }
            if (this.showVbSize)
            {
                layer.addDataSet(vbSize, 0x3333cc, "VBSIZE");
            }
            if (this.showParamSize)
            {
                layer.addDataSet(parameterSize, 0x3333cc, "PARAM");
            }
            if (this.showRemoteParamSize)
            {
                layer.addDataSet(remoteParamSize, 0x3333cc, "REMOTE");
            }
            if (this.showSurLock)
            {
                layer.addDataSet(surLock, 0x3333cc, "SURLOCK");
            }

            if (this.showSurSize)
            {
                layer.addDataSet(surSize, 0x3333cc, "SURSIZE");
            }
            if (this.showTexLock)
            {
                layer.addDataSet(texLock, 0x3333cc, "TEXLOCK");
            }
            if (this.showTexSize)
            {
                layer.addDataSet(texSize, 0x3333cc, "TEXSIZE");
            }
            if (this.showSetTexTime)
            {
                layer.addDataSet(setTex, 0x3333cc, "SETTEX");
            }
            if (this.showStateBlock)
            {
                layer.addDataSet(stateBlock, 0x3333cc, "STATEBLOCK");
            }

            if (this.showVShaderCmd)
            {
                layer.addDataSet(vShaderCmd, 0x3333cc, "VSC");
            }
            if (this.showVShaderConst)
            {
                layer.addDataSet(vShaderConst, 0x3333cc, "VSCONST");
            }
            if (this.showPShaderCmd)
            {
                layer.addDataSet(pShaderCmd, 0x3333cc, "PSC");
            }
            if (this.showPShaderConst)
            {
                layer.addDataSet(pShaderConst, 0x3333cc, "PSCONST");
            }


            // configure the axis scale and labeling
            //viewer.syncDateAxisWithViewPort("x", c.xAxis());
            viewer.syncLinearAxisWithViewPort("x", c.xAxis());
            // If all ticks are yearly aligned, then we use "yyyy" as the label format.
            //c.xAxis().setFormatCondition("align", 32);
            //c.xAxis().setLabelFormat("{value|p4}");

            viewer.Chart = c;
        }
Exemplo n.º 11
0
        private void drawChart(WinChartViewer viewer)
        {
            // get the start index that are visible on the chart
            double viewPortStartIndex = viewer.getValueAtViewPort("x", viewer.ViewPortLeft);
            double viewPortEndIndex   = viewer.getValueAtViewPort("x", viewer.ViewPortLeft + viewer.ViewPortWidth);

            // Get the array indexes that corresponds to the visible start and end
            int startIndex = 0;
            int endIndex   = 0;

            if (showInFrame)
            {
                startIndex = (int)Math.Floor(Chart.bSearch(indexForFrame, viewPortStartIndex));
                endIndex   = (int)Math.Ceiling(Chart.bSearch(indexForFrame, viewPortEndIndex));
                Console.WriteLine("port start: " + viewPortStartIndex + " port end: " + viewPortEndIndex + " start: " + startIndex + " end: " + endIndex + " index length: " + indexForFrame.Length);
            }
            else
            {
                startIndex = (int)Math.Floor(Chart.bSearch(indexForSecond, viewPortStartIndex));
                endIndex   = (int)Math.Ceiling(Chart.bSearch(indexForSecond, viewPortEndIndex));
                Console.WriteLine("port start: " + viewPortStartIndex + " port end: " + viewPortEndIndex + " start: " + startIndex + " end: " + endIndex + " index length: " + indexForSecond.Length);
            }

            int noOfPoints = endIndex - startIndex + 1;

            // declaration the data set
            double[] viewPortDataSeriesCpuInFrame;
            double[] viewPortDataSeriesGpuInFrame;
            double[] viewPortDataSeriesFpsInFrame;
            double[] viewPortDataSeriesFpsInSecond;
            double[] viewPortDataSeriesCpuInSecond;
            double[] viewPortDataSeriesGpuInSecond;

            double[] viewPortIndex;

            if (showInFrame)
            {
                viewPortIndex = (double[])Chart.arraySlice(indexForFrame, startIndex, noOfPoints);
                if (this.showCpu)
                {
                    viewPortDataSeriesCpuInFrame = (double[])Chart.arraySlice(cpuInFrame, startIndex, noOfPoints);
                }
                if (this.showGpu)
                {
                    viewPortDataSeriesGpuInFrame = (double[])Chart.arraySlice(gpuInFrame, startIndex, noOfPoints);
                }
                if (this.showFps)
                {
                    viewPortDataSeriesFpsInFrame = (double[])Chart.arraySlice(fpsInFrame, startIndex, noOfPoints);
                }
            }
            else
            {
                viewPortIndex = (double[])Chart.arraySlice(indexForSecond, startIndex, noOfPoints);
                if (this.showCpu)
                {
                    viewPortDataSeriesCpuInSecond = (double[])Chart.arraySlice(cpuInSecond, startIndex, noOfPoints);
                }
                if (this.showGpu)
                {
                    viewPortDataSeriesGpuInSecond = (double[])Chart.arraySlice(gpuInSecond, startIndex, noOfPoints);
                }
                if (this.showFps)
                {
                    viewPortDataSeriesFpsInSecond = (double[])Chart.arraySlice(fpsInSecond, startIndex, noOfPoints);
                }
            }

            // configure overall chart apperance
            XYChart c = new XYChart(807, 371);

            c.setPlotArea(55, 50, c.getWidth() - 80, c.getHeight() - 85, c.linearGradientColor(0, 50, 0, c.getHeight() - 35, 0xf0f6ff, 0xa0c0ff), -1, Chart.Transparent, 0xffffff, 0xfffff);

            c.setClipping();

            c.addTitle("Charactor for game", "Times New Roman Bold Italic", 10);

            // Set legend icon style to use line style icon, sized for 8pt font
            c.getLegend().setLineStyleKey();
            c.getLegend().setFontSize(8);

            //LegendBox b = c.addLegend(55, 25, false, "Arial Bold", 8);
            //b.setBackground(Chart.Transparent);
            //b.setLineStyleKey();

            // set the axis stem to transparent
            c.xAxis().setColors(Chart.Transparent);
            c.yAxis().setColors(Chart.Transparent);

            // add the y axixs title
            c.yAxis().setTitle("chractor", "Arial Bold Italic", 10);

            // add data to chart

            LineLayer layer = c.addLineLayer2();

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

            if (this.showInFrame)
            {
                layer.setXData(this.indexForFrame);
            }
            else
            {
                layer.setXData(this.indexForSecond);
            }

            /*
             * layer.addDataSet(viewPortDataSeriesCpu, 0xff3333, "CPU");
             * layer.addDataSet(viewPortDataSeriesGpu, 0x008800, "GPU");
             * layer.addDataSet(viewPortDataSeriesFps, 0x3333cc, "FPS");
             */
            if (this.showInFrame)
            {
                if (this.showCpu)
                {
                    layer.addDataSet(cpuInFrame, 0xff3333, "CPU In Frame");
                }
                if (this.showGpu)
                {
                    layer.addDataSet(gpuInFrame, 0x008800, "GPU In Frame");
                }
                if (this.showFps)
                {
                    layer.addDataSet(fpsInFrame, 0xcccccc, "FPS In Frame");
                }
            }
            else
            {
                if (this.showCpu)
                {
                    layer.addDataSet(cpuInSecond, 0x33cc33, "CPU In Second");
                }
                if (this.showGpu)
                {
                    layer.addDataSet(gpuInSecond, 0xff8833, "GPU In Second");
                }
                if (this.showFps)
                {
                    layer.addDataSet(fpsInSecond, 0xcccccc, "FPS In Second");
                }
            }


            // configure the axis scale and labeling
            //viewer.syncDateAxisWithViewPort("x", c.xAxis());
            viewer.syncLinearAxisWithViewPort("x", c.xAxis());
            // If all ticks are yearly aligned, then we use "yyyy" as the label format.
            //c.xAxis().setFormatCondition("align", 32);
            //c.xAxis().setLabelFormat("{value|p4}");

            viewer.Chart = c;
        }
Exemplo n.º 12
0
        private void drawFullChart(RazorViewPortControl vp, RazorChartViewer viewer)
        {
            // We need to draw a small thumbnail chart for the full data range. The simplest method is to
            // simply get the full data to draw the chart. If the full data are very large (eg. millions
            // of points), for such a small thumbnail chart, it is often acceptable to just retreive a
            // small sample of the data.
            //
            // In this example, there are only around 5500 points for the 3 data series. This amount is
            // not large to ChartDirector, so we simply pass all the data to ChartDirector.
            RanTable r = getRandomTable();

            // Get all the data from the random table
            DateTime[] timeStamps  = Chart.NTime(r.getCol(0));
            double[]   dataSeriesA = r.getCol(1);
            double[]   dataSeriesB = r.getCol(2);
            double[]   dataSeriesC = r.getCol(3);

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

            // Set the plotarea with the same horizontal position as that in the main chart for
            // alignment. The vertical position is set to equal to the chart height.
            c.setPlotArea(55, 0, c.getWidth() - 80, c.getHeight() - 1, 0xc0d8ff, -1, 0x888888,
                          Chart.Transparent, 0xffffff);

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

            // Put the x-axis labels inside the plot area by setting a negative label gap. Use
            // setLabelAlignment to put the label at the right side of the tick.
            c.xAxis().setLabelGap(-1);
            c.xAxis().setLabelAlignment(1);

            // Set the y axis stem and labels to transparent (that is, hide the labels)
            c.yAxis().setColors(Chart.Transparent, Chart.Transparent);

            // Add a line layer for the lines with fast line mode enabled
            LineLayer layer = c.addLineLayer2();

            layer.setFastLineMode();

            // Now we add the 3 data series to a line layer, using the color red (0xff3333), green
            // (0x008800) and blue (0x3333cc)
            layer.setXData(timeStamps);
            layer.addDataSet(dataSeriesA, 0xff3333);
            layer.addDataSet(dataSeriesB, 0x008800);
            layer.addDataSet(dataSeriesC, 0x3333cc);

            // The x axis scales should reflect the full range of the view port
            c.xAxis().setDateScale(viewer.getValueAtViewPort("x", 0), viewer.getValueAtViewPort("x", 1));

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

            // For the auto-scaled y-axis, as we hide the labels, we can disable axis rounding. This can
            // make the axis scale fit the data tighter.
            c.yAxis().setRounding(false, false);

            // Output the chart
            vp.Image = c.makeWebImage(Chart.PNG);
        }
Exemplo n.º 13
0
        //
        // Draw the chart
        //
        private void drawChart(RazorChartViewer viewer)
        {
            // Determine the visible x-axis range
            DateTime viewPortStartDate = Chart.NTime(viewer.getValueAtViewPort("x", viewer.ViewPortLeft))
            ;
            DateTime viewPortEndDate = Chart.NTime(viewer.getValueAtViewPort("x", viewer.ViewPortLeft +
                                                                             viewer.ViewPortWidth));

            // We need to get the data within the visible x-axis range. In real code, this can be by
            // using a database query or some other means as specific to the application. In this demo,
            // we just generate a random data table, and then select the data within the table.
            RanTable r = getRandomTable();

            // Select the data for the visible date range viewPortStartDate to viewPortEndDate. It is
            // possible there is no data point at exactly viewPortStartDate or viewPortEndDate. In this
            // case, we also need the data points that are just outside the visible date range to
            // "overdraw" the line a little bit (the "overdrawn" part will be clipped to the plot area)
            // In this demo, we do this by adding a one day margin to the date range when selecting the
            // data.
            r.selectDate(0, viewPortStartDate.AddDays(-1), viewPortEndDate.AddDays(1));

            // The selected data from the random data table
            DateTime[] timeStamps  = Chart.NTime(r.getCol(0));
            double[]   dataSeriesA = r.getCol(1);
            double[]   dataSeriesB = r.getCol(2);
            double[]   dataSeriesC = r.getCol(3);

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

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

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

            c.setRoundedFrame();

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

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

            // Add a top title to the chart using 15pt Times New Roman Bold Italic font, with a light
            // blue (ccccff) background, black (000000) border, and a glass like raised effect.
            c.addTitle("Product Line International Market Price", "Times New Roman Bold Italic", 15
                       ).setBackground(0xccccff, 0x000000, Chart.glassEffect());

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

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

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

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

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

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

            layer.setLineWidth(2);

            // In this demo, we do not have too many data points. In real code, the chart may contain a
            // lot of data points when fully zoomed out - much more than the number of horizontal pixels
            // in this plot area. So it is a good idea to use fast line mode.
            layer.setFastLineMode();

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

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

            // Set the x-axis as a date/time axis with the scale according to the view port x range.
            viewer.syncDateAxisWithViewPort("x", c.xAxis());

            // In this demo, we rely on ChartDirector to auto-label the axis. We ask ChartDirector to
            // ensure the x-axis labels are at least 75 pixels apart to avoid too many labels.
            c.xAxis().setTickDensity(75);

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

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "",
                                                "title='[{dataSetName}] {x|mmm dd, yyyy}: USD {value|2}'");
        }