I see it very inconvenient to reload the entire chart to update the shader (gradient) or the color (ChartSegment properties: color, stroke, etc.)
Is there any possibility to be able to update the shaders or segment properties on the fly?
Real case:
This is 24h price change chart. It has to change its color from green to red and vice versa if the current price is more or less than the price from 24h ago.
Right now the only way (at least I didn't manage to find another) to change gradient and borderColor(strokeColor) is to rerender the component. It is not a big issue if I have only one element like this but I have many on the screen (5 - 20 at the time).
Therefore I was trying to find a way to optimize it - like changing the stylish properties only so I don't need to recalculate the whole chart series on every color change.
Hi,
To change the gradient or border color of the chart, it is necessary to rebuild the widget, which is a behavior in Flutter. If you are concerned about the performance when updating the color of a single series, as it will cause rerendering of other charts, we suggest that you wrap the chart widget in another stateful widget. Doing so will prevent the rebuilding of this widget from affecting the others.
On the other hand, we suggest that you look into the RepaintBoundary widget; it may help you in such a case.
Thanks,
Vijay
That's sad that syncfusion doesn't have proper support for color and shader updates on the fly - only through the complete widget rebuild.
Than
Hi Sergey,
We are looking for a feasible solution to achieve your requirement. We will update the status in one business day on 7 February 2023. We appreciate your patience until then.
Regards,
Yuvaraj.
Hi Sergey,
We have tried to find a solution, but unfortunately there is no feasible workaround for your requirement. Drawing the whole series in a single canvas makes it impossible to use a different canvas for each segment. As a result of the chart's behavior, all segments will need to be re-rendered when updating data points since a single canvas is used for the chart series.
Regards,
Lavanya A.
You seem to have misunderstood my question, as your response is not relevant to what I was asking.
Hi Sergey,
As informed earlier, to change the gradient or border color of the chart, it is necessary to rebuild the widget, which is a behavior in Flutter. So, there is no option to change the series color without calling setState.
Please let us know if you need any further assistance on this.
Regards,
Lavanya A.