Esempio n. 1
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;
        }
        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;
        }
        //
        // Draw the chart and display it in the given viewer
        //
        private void drawChart(WinChartViewer viewer)
        {
            // Create an XYChart object 500 x 480 pixels in size, with the same background color
            // as the container
            XYChart c = new XYChart(500, 480, Chart.CColor(BackColor));

            // Set the plotarea at (50, 40) and of size 400 x 400 pixels. Use light grey (c0c0c0)
            // horizontal and vertical grid lines. Set 4 quadrant coloring, where the colors of
            // the quadrants alternate between lighter and deeper grey (dddddd/eeeeee).
            c.setPlotArea(50, 40, 400, 400, -1, -1, -1, 0xc0c0c0, 0xc0c0c0
                          ).set4QBgColor(0xdddddd, 0xeeeeee, 0xdddddd, 0xeeeeee, 0x000000);

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

            // Set 4 quadrant mode, with both x and y axes symetrical around the origin
            c.setAxisAtOrigin(Chart.XYAxisAtOrigin, Chart.XAxisSymmetric + Chart.YAxisSymmetric);

            // Add a legend box at (450, 40) (top right corner of the chart) with vertical layout
            // and 8 pts Arial Bold font. Set the background color to semi-transparent grey.
            LegendBox b = c.addLegend(450, 40, true, "Arial Bold", 8);

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

            // Add a titles to axes
            c.xAxis().setTitle("Alpha Index");
            c.yAxis().setTitle("Beta Index");

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

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

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

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

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

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

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

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

            // Set the chart image to the WinChartViewer
            viewer.Chart = c;
        }