I want to implement something like, if a certain analysis value/custom logic is true for one of the values in the loop, –> set this bar color to ‘orange’ as an example, how can i do this?
// Create a dataset of type x=DateTime, y=Double
var dataSeries = new OhlcDataSeries<DateTime, double>();
// Prices are in the format Time, Open, High, Low, Close (all IList)
var prices = smallerList;
// Append data to series. SciChart automatically redraws
for (var i = 0; i < prices.Count(); i++)
{
// Convert TIME to a 4-digit string (e.g., 5 becomes "0005", 15 becomes "0015")
string timeString = prices[i].Value.TIME.ToString("D4");
// Parse the TIME field
int hour = int.Parse(timeString.Substring(0, 2));
int minute = int.Parse(timeString.Substring(2, 2));
// Create the DateTime object
DateTime dateTime = new DateTime(prices[i].Value.YEAR, prices[i].Value.MONTH, prices[i].Value.DAY, hour, minute, 0);
Dispatcher.Invoke(() =>
{
//here we append values in 'dataSeries', how do i do something like, 'bool condition =
// returnCustomLogic('dataValues') --> outputs true, if true --> set this bar color to orange
// Update the UI element on the UI thread
dataSeries.Append(
dateTime,
(double)prices[i].Value.OPEN,
(double)prices[i].Value.HIGH,
(double)prices[i].Value.LOW,
(double)prices[i].Value.CLOSE);
});
}
Dispatcher.Invoke(() =>
{
StockChart.RenderableSeries[0].DataSeries = dataSeries;
// Zoom Extents - necessary as we have AutoRange=False
StockChart.ZoomExtents();
});
- Adan Ramirez asked 7 months ago
- last edited 7 months ago
- You must login to post comments
Hi Adan,
Programmatically setting the color of a data-point can be done with our PaletteProvider API. This allows you to create classes or functions to change the color of data-points for line, scatter, column series and more based on custom code
From the documentation:
RenderableSeries APIs – Paletted Series
SciChart features the ability to change color on a point-by-point
basis, using the PaletteProvider feature.Many series types support PaletteProvider, including:
- FastLineRenderableSeries
- XyScatterRenderableSeries
- FastCandlestickRenderableSeries
- FastMountainRenderableSeries
- FastColumnRenderableSeries
- FastOhlcRenderableSeries
- FastBubbleRenderableSeries
To enable the paletting feature, you need
to create a class which inherits IStrokePaletteProvider or
IFillPaletteProvider, or IPointMarkerPaletteProvider, and assign or
bind to the BaseRenderableSeries.PaletteProvider property.
Let me know if this helps!
Best regards,
Andrew
- Andrew Burnett-Thompson answered 7 months ago
- You must login to post comments
Please login first to submit.