Lineseries.Color bug, help

Jul 24, 2014 at 2:20 AM
Edited Jul 24, 2014 at 2:24 AM
Hi all, thanks for the library!
I wanna keep the color patter of creating the new line while getting the color of the line plotted. But this: OxyPlot.WindowsForms.ConverterExtensions.ToColor(tmpLine.Color); code will always return same color value back.
Thanks a lot!
foreach (Plot plotItem in _plots)
            {
                var tmpLine = new LineSeries();
                tmpLine.Points.AddRange(plotItem._resampledPoints);
                tmpLine.StrokeThickness = plotItem._thickness;
                tmpLine.LineStyle = plotItem._style;
                if(_showLineTitle)
                    tmpLine.Title = plotItem._name;
                if (!(plotItem._color.Equals(System.Drawing.Color.White)))
                    tmpLine.Color = plotItem._color.ToOxyColor();
                plotItem._color = OxyPlot.WindowsForms.ConverterExtensions.ToColor(tmpLine.Color);
                model.Series.Add(tmpLine);
            }
Jul 24, 2014 at 2:11 PM
You're using extensions wrong, might want to look into them more =P. Try just doing
tmpLine.Color.ToColor();
Jul 24, 2014 at 3:59 PM
Edited Jul 24, 2014 at 4:00 PM
Every time the tmpLine.Color will always give me {#00000001} while the actual color is not. I've tried changing my code to This:
foreach (Plot plotItem in _plots)
            {
                var tmpLine = new LineSeries();
                tmpLine.Points.AddRange(plotItem._resampledPoints);
                tmpLine.StrokeThickness = plotItem._thickness;
                tmpLine.LineStyle = plotItem._style;
                if (_showLineTitle)
                    tmpLine.Title = plotItem._name;
                if (!(plotItem._color.Equals(System.Drawing.Color.White)))
                    tmpLine.Color = plotItem._color.ToOxyColor();
                plotItem._color = tmpLine.Color.ToColor();

                model.Series.Add(tmpLine);
            }
Thanks so much!
Jul 25, 2014 at 3:37 PM
That's because LineSeries.Color is actually initialized to OxyColors.Automatic if you don't define it yourself. This allows whatever you've set to PlotModel.DefaultColors to handle giving line series colours when they're visible. You can do something similar to PlotModel.DefaultColors = OxyPalettes.HueDistinct(20).Colors to change what it gives out for automatic colours. You'll have to set the colour of the line series yourself if you want something from LineSeries.Color.
Jul 25, 2014 at 11:17 PM
This information is so helpful! Thanks so much!
You're always so helpful :)