コード例 #1
0
 public void AddSeries(DataSeries dataSeries, DataSeriesDisplaySettings displaySettings)
 {
     if (DataSeriesList == null)
     {
         DataSeriesList      = new List <DataSeries>();
         DisplaySettingsList = new List <DataSeriesDisplaySettings>();
     }
     DataSeriesList.Add(dataSeries);
     DisplaySettingsList.Add(displaySettings);
     if (ownerControl != null)
     {
         ownerControl.Invalidate();
     }
 }
コード例 #2
0
        private void DrawSeries(Graphics g, DataSeries dataSeries, DataSeriesDisplaySettings displaySettings)
        {
            float absoluteSymbolSize = Math.Min(this.Height, ownerControl.MainPanelWidth) * displaySettings.RelativeSymbolSize;

            if ((displaySettings.DrawLine) && (dataSeries.HorizontalData.Count > 1))
            {
                g.SmoothingMode     = SmoothingMode.HighQuality;
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                using (Pen linePen = new Pen(displaySettings.LineColor))
                {
                    for (int ii = 1; ii < dataSeries.HorizontalData.Count; ii++)
                    {
                        double xPrevious     = dataSeries.HorizontalData[ii - 1];
                        double yPrevious     = dataSeries.VerticalData[ii - 1];
                        float  xPlotPrevious = ownerControl.GetPixelXatX((float)xPrevious);
                        float  yPlotPrevious = GetPixelYatY((float)yPrevious);
                        double x             = dataSeries.HorizontalData[ii];
                        double y             = dataSeries.VerticalData[ii];
                        float  xPlot         = ownerControl.GetPixelXatX((float)x);
                        float  yPlot         = GetPixelYatY((float)y);
                        if ((yPlot >= Top) && (yPlot <= Top + Height)) // MW ToDo: Need to deal with this, somehow.
                        {
                            g.DrawLine(linePen, xPlotPrevious, yPlotPrevious, xPlot, yPlot);
                        }
                    }
                }
            }
            using (SolidBrush pointBrush = new SolidBrush(displaySettings.SymbolColor))
            {
                for (int ii = 0; ii < dataSeries.HorizontalData.Count; ii++)
                {
                    double x     = dataSeries.HorizontalData[ii];
                    double y     = dataSeries.VerticalData[ii];
                    float  xPlot = ownerControl.GetPixelXatX((float)x);
                    float  yPlot = GetPixelYatY((float)y);
                    if (displaySettings.Symbol == SymbolStyle.Disc)
                    {
                        g.FillEllipse(pointBrush, xPlot - absoluteSymbolSize / 2, yPlot - absoluteSymbolSize / 2, absoluteSymbolSize, absoluteSymbolSize);
                    }
                    else if (displaySettings.Symbol == SymbolStyle.Square)
                    {
                        g.FillRectangle(pointBrush, xPlot - absoluteSymbolSize / 2, yPlot - absoluteSymbolSize / 2, absoluteSymbolSize, absoluteSymbolSize);
                    }
                }
            }
        }