Quantcast
Channel: OxyPlot (moved to GitHub)
Viewing all articles
Browse latest Browse all 2061

New Post: Programatically (or via XAML) Define color for each bar in ColumnSeries

$
0
0
I'm really enjoying the OxyPlot library. Thank you!

I have a Plot with seven ColumnSeries. I need to set each bar color (in each of the series) based on a property in the model.

From the code, I tried defining a list of colors in DefaultColors the chart is drawn where all the bars in the 1st series are drawn with DefaultColor[0] and all the bars in the 2nd series are drawn with DefaultColors[1], etc.
        eg: plotModel.Series.Add(new ColumnSeries { Title = "V1", ItemsSource = CellList, ValueField = "CellVoltage" });
               OxyColor defaultColor = OxyColor.Parse("#FF000080"); // Default -- blue
               plotModel.DefaultColors.Add(defaultColor);
               ...
From XAML, I tried to set FillColor binding to a method that should return a bar color, but it appears to return the same color for all bars in the series.
 eg: <oxy:ColumnSeries Title="V1" ItemsSource="{Binding Path=CellList}" ValueField="Voltage"  FillColor="{Binding Path=CellBarColor}" />


Thank you for your help
jg

Viewing all articles
Browse latest Browse all 2061

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>