Search code examples
amchartsamcharts4

amCharts 4 - How To Set Line Color Via Property Fields When No Data Added To Chart


Following this demo, the following can be used to change the color of a LineSeries:

lineSeries.propertyFields.stroke = "lineColor";
lineSeries.propertyFields.fill = "lineColor";

This works if you add some data when making the chart. But there are issues when no data is originally added.

See this pen. Errors occur. Commenting out the lineSeries.propertyFields.stroke and lineSeries.propertyFields.fill lines allow data to be added to the chart via the "Add Data" button.

Is there a way to define the line color property field so that it works in this situation?


Solution

  • This seems like an issue on amCharts side, I will take a look at it. Meanwhile I would recommend setting property fields just before adding data for the first time.