dynamically generating y values ​​with json data

Hi everyone,

I wanted to say a different number of y values ​​should be created according to the id of the person entering the page.That is, when I say how many y values ​​should be while running, it should create a y value accordingly.

How can I get this without if else operator?

series: <ChartSeries>[
          // Initialize line series
          SplineSeries<_CurrentValues, String>(
              dataSource: currentValues,
              name: currentValuesLegendTitle,
              xValueMapper: (_CurrentValues data, _) => data.x,
              yValueMapper: (_CurrentValues data, _) => data.y,
              color: Colors.black38),
          SplineSeries<_CurrentValues1, String>(
              dataSource: currentValues1,
              name: currentValuesLegendTitle1,
              xValueMapper: (_CurrentValues1 data, _) => data.x,
              yValueMapper: (_CurrentValues1 data, _) => data.y1,
              color: Colors.blue),
          SplineSeries<_CurrentValues2, String>(
              dataSource: currentValues2,
              name: currentValuesLegendTitle2,
              xValueMapper: (_CurrentValues2 data, _) => data.x,
              yValueMapper: (_CurrentValues2 data, _) => data.y2,
              color: const Color.fromRGBO(238, 182, 78, 1)),
        ]


I want create this Splineseries dynamically by jsondata how can i do this ? 




1 Reply

YG Yuvaraj Gajaraj Syncfusion Team February 15, 2022 04:42 PM UTC

Hi Mehmet, 
 
Greetings from Syncfusion. We are not clear on your exact requirement for creating y-values and also based on the id do you need to create series? Kindly share the sample json structure that you might have in your end, this will be helpful in creating sample for your scenario. Also, we have KB for binding json data to chart and demo, you find from below, 
 
 
Thanks, 
yuvaraj. 


Loader.
Up arrow icon