Example #1
0
        /// <summary>
        /// 设置ColorEach
        /// </summary>
        /// <param name="series">SeriesBase</param>
        /// <param name="colorEach">是否设置成ColorEach</param>
        public static void SetColorEach(this SeriesBase series, bool colorEach)
        {
            SeriesViewColorEachSupportBase colorEachView = (SeriesViewColorEachSupportBase)series.View;

            if (colorEachView != null)
            {
                colorEachView.ColorEach = colorEach;
            }
        }
Example #2
0
        Bitmap GetMarkerImage(ChartControl chart, Series series)
        {
            Bitmap bitmap        = null;
            Series currentSeries = null;

            foreach (Series fakeSeries in chart.Series)
            {
                if (fakeSeries.Name == series.Name)
                {
                    currentSeries           = fakeSeries;
                    fakeSeries.ShowInLegend = true;
                }
                else
                {
                    fakeSeries.ShowInLegend = false;
                }
            }
            if (currentSeries != null)
            {
                XYDiagram2D diagram = chart.Diagram as XYDiagram2D;
                if (diagram != null)
                {
                    diagram.DefaultPane.Visible = false;
                }
                SeriesViewColorEachSupportBase colorEachView = currentSeries.View as SeriesViewColorEachSupportBase;
                if (colorEachView != null && colorEachView.ColorEach)
                {
                    chart.Size = new Size(chart.Legend.MarkerSize.Width, chart.Legend.MarkerSize.Height * currentSeries.Points.Count);
                }
                else
                {
                    chart.Size = chart.Legend.MarkerSize;
                }
                bitmap = new Bitmap(chart.Size.Width, chart.Size.Height);
                chart.DrawToBitmap(bitmap, new Rectangle(Point.Empty, bitmap.Size));
            }
            return(bitmap);
        }