Hello together,
I have implemented a PaletteProvider which colors the whole Series depending on the Series always the same.
public class OwnPaletteProvider : PaletteProviderBase
{
private readonly Dictionary<IRenderableSeries, Color> seriesColorsDictionary = new Dictionary<IRenderableSeries, Color>();
private List<Color> availablesColors = new List<Color>()
{
Colors.Red,
Colors.Yellow,
Colors.Green,
Colors.Orange,
Colors.Blue
};
private int counter = 0;
public override Color? GetColor(IRenderableSeries series, double xValue, double yValue)
{
// Get the specific Color for the specific Series
if (seriesColorsDictionary.ContainsKey(series))
{
return seriesColorsDictionary[series];
}
// Series doesn't have a color
// Add new Color from the list for this series in a RoundRobin-way
var newColorForSeries = availablesColors[counter%availablesColors.Count];
counter++;
seriesColorsDictionary.Add(series, newColorForSeries);
return newColorForSeries;
}
}
The problem is that I have also in this Series PointMarkers which should have the same Color as the RenderableSeries. I thought, I could create a Style which binds to the Color of the RenderableSeries, but this is not working (see image in attachment).
<Style x:Key="pointMarker" TargetType="{x:Type s:BasePointMarker}">
<Setter Property="StrokeThickness" Value="5" />
<Setter Property="Fill" Value="{Binding Path=SeriesColor,
RelativeSource={RelativeSource AncestorType={x:Type s:FastLineRenderableSeries}}, Converter={StaticResource StringToBrushConverter}}"/>
<Setter Property="Background" Value="{Binding Path=SeriesColor,
RelativeSource={RelativeSource AncestorType={x:Type s:FastLineRenderableSeries}}, Converter={StaticResource StringToBrushConverter}}"/>
</Style>
I could imagine that the PaletteProvider doesn’t support this. I would need a dynamic coloring of the RenderableSeries and the PointMarkers because the amount of the Series are flexible.
My current solution for this problem is to set the color in the ViewModel, but this seems to me not very nice, because I what to have only Bindings in the ViewModel and the “Styling” and the “Coloring” of the Chart should be done in the Xaml Code with some converters are with the PaletteProvider.
Why questions are:
- How is it possible to color the FastLineRenderableSeriesor or the XyScatterRenderableSeries dynamically, also when new ones are added or deleted dynamically from the Xaml Code?
- Can the PaletteProvider have an influence of the Color MarkerPoints?
Best regards,
Martin
PS: Sry I couldn’t use NuGet because the Port 81 is blocked in our company, so you have to add the SciChart library by our own.
- Martin Balter asked 8 years ago
- last edited 8 years ago
- You must login to post comments
Update / 2016
As of SciChart v4 the following series types now support PaletteProvider / per-point colouring:
- Line Series
- Scatter Series
- Mountain Series
- Column Series
- Ohlc Series
- Candlestick Series
- Bubble Series
You can see more in our PaletteProvider API Documentation.
- Andrew Burnett-Thompson answered 6 years ago
- You must login to post comments
Hi Martin,
You are absolutely right the PaletteProvider colours only the lines at this time (not the point markers). Bindings to point marker properties do work in some cases, but not in all, because we are basically exposing a XAML API but translating everything from XAML over to our own bitmap rendering-engine, so some of the things like triggers and style bindings on PointMarkers you would expect to work in WPF, won’t work in SciChart.
Here is a list of what does work in SciChart point marker style bindings:
Here is our best workaround for having an infinite number of varied point-markers on a series in SciChart:
Different datapoint markers on the same dataseries.
I hope this helps,
Best regards,
Andrew
- Andrew Burnett-Thompson answered 8 years ago
- It's good to know that this was not the intention of the PaletteProvider. I already did something similar like the "Different datapoint markers on the same dataseries" and this works really fine for my case. Thanks for your quick answer!
- You must login to post comments
Please login first to submit.