Different colors for negative and positive values

Hi!
Is it possible in LineChart when the values ​​are negative the line is red, and when the values ​​are positive the line is green?



Thanks!


3 Replies 1 reply marked as answer

AR Arun Raji Syncfusion Team October 27, 2020 10:43 AM UTC

Hi Luis,  
  
Greetings from Syncfusion. 
  
We have analyzed your query, and we can achieve your scenario by using the pointColorMapper function in LineSeries and placed a simple logic into it, which return the appropriate positive and negative color for each input data point. However when a point is connected from negative to positive, that will be in red colored and from positive to negative, that will be in green colored. We have created a simple sample, code snippet, and output image below, which meet your requirement. So, find that sample and revert back If you have any concerns regarding this scenario. 
  
  
Code snippet –  
pointColorMapper: (ChartSampleData sales, _) { 
  if (sales.y < 0) { 
    return Color.fromRGBO(255001); 
  } else { 
    return Color.fromRGBO(025501); 
  } 
} 
 
  
Output image –  
 
  
Thanks,  
Arun 


Marked as answer

LU Luís October 27, 2020 10:56 AM UTC

That's exactly what I wanted.
Thank you very much Arun Raji!


SK Sriram Kiran Senthilkumar Syncfusion Team October 28, 2020 11:47 AM UTC

Hi Luis, 
  
Most welcome. Please get in touch with us if you have further queries. We are always happy in assisting you. 
  
Regards, 
Sriram Kiran 


Loader.
Up arrow icon