Dynamic line name(each point)

my problem situation:
I have 5 lines and I get 
data from an api, and these data are the highest 5 CPU usage at that moment. Since these cpu names have changed, I cannot assign them to the name. I need to show these cpu process names in trackball dynamicly.

3 Replies 1 reply marked as answer

SK Sriram Kiran Senthilkumar Syncfusion Team August 28, 2020 03:01 PM UTC

Hi Selahattin, 

Greetings from Syncfusion. We have analyzed your scenario and we have created a simple sample in which we have rendered five-line series with dummy data which indicates the CPU usage of the five processes and also provided dummy names for those series. We have displayed their name in the trackball using the onTrackballPositionChanging event available in the chart. Please refer the code snippet below for reference. 
SfCartesianChart( 
       onTrackballPositionChanging: (TrackballArgs args) { 
        // We have rendered the series name along with the y value of the series in the  
        //trackball’s tooltip. 
 
         // If you have a unique name for every process that keeps on changing dynamically,  
         // then return it from your API and you can use that name here instead of  
         // 'args.chartPointInfo.series.name' value in the args.chartPointInfo.label variable. 
 
       args.chartPointInfo.label = 
       '${args.chartPointInfo.series.name}\nMemory: ${args.chartPointInfo.chartDataPoint.y.toInt()}%'; 
      }, 
       primaryXAxis: CategoryAxis(), 
       series: <ChartSeries<ProcessData, String>>[ 
              LineSeries<ProcessData, String>( 
                name: 'Process1', //Dummy name 
                dataSource: Process1Data, 
                xValueMapper: (ProcessData data, _) => data.time, 
                yValueMapper: (ProcessData data, _) => data.memory, 
              ), 
              LineSeries<ProcessData, String>( 
                name: 'Process2', 
                dataSource: Process2Data 
                xValueMapper: (ProcessData data, _) => data.time, 
                yValueMapper: (ProcessData data, _) => data.memory, 
              ), 
              LineSeries<ProcessData, String>( 
                name: 'Process3', 
                dataSource: Process3Data, 
                xValueMapper: (ProcessData data, _) => data.time, 
                yValueMapper: (ProcessData data, _) => data.memory, 
              ), 
              LineSeries<ProcessData, String>( 
                name: 'Process4', 
                dataSource: Process4Data, 
                xValueMapper: (ProcessData data, _) => data.time, 
                yValueMapper: (ProcessData data, _) => data.memory, 
              ), 
              LineSeries<ProcessData, String>( 
                name: 'Process5', 
                dataSource: Process5Data, 
                xValueMapper: (ProcessData data, _) => data.time, 
                yValueMapper: (ProcessData data, _) => data.memory, 
              ) 
       ] 
       // other configurations 

Screenshot: 
  

The sample for reference can be found below. 
  
As you have mentioned in your query that the process names changes dynamically according to the returned process data, if you can return that name from your API along with when returning its process data for the chart then you use that process name in the onTrackballPositionChanging event dynamically by checking and setting the corresponding name in the args.chartPointInfo.label variable according to it process data. Please check the attached sample and revert us if you still have concerns. 
If we have misunderstood your query, kindly revert us with below details so that it will be helpful in providing the solutions sooner. 
·        If possible, share us an example screenshot which depicts our scenario. 
·        Or, kindly share us the code snippet along with your data returned from your API which you have used to render chart widget. 

Regards, 
Sriram Kiran 


Marked as answer

SC selahattin Ceylan August 28, 2020 03:49 PM UTC

okey thanx I made it :D


SK Sriram Kiran Senthilkumar Syncfusion Team August 31, 2020 12:15 PM UTC

Hi Selahattin, 

Thanks for the revert. We are always happy in assisting you. Kindly revert us if you have further queries. 

Regards, 
Sriram Kiran 


Loader.
Up arrow icon