Gradient on LineSeries or rather AreaSeries

Hello Guys,

first of all I would like to thank Syncfusion for the great products.

Atm i have a problem with the gradient function for Area Series.

I would like to achieve a look like this:

IMG_1197.jpegIMG_1199.jpeg

Im pretty sure there is an easy way to do that. 

Thanks in advance.

Greetings


5 Replies 1 reply marked as answer

YG Yuvaraj Gajaraj Syncfusion Team February 17, 2022 04:16 PM UTC

Hi Leon, 
 
Greetings from Syncfusion. Using the gradient feature for the area series your requirement can be achieved. We have prepared the sample for your scenario and applied gradient colors using the gradient property in the series. You can customize the range of the gradient by setting the stops in the gradient. We have attached the code snippet and sample below for your reference. 
 
Code snippet: 
final List<Color> positiveColor = <Color>[]; 
    positiveColor.add(Colors.green[50]!); 
    positiveColor.add(const Color.fromARGB(255, 145, 231, 148)); 
    positiveColor.add(const Color.fromARGB(255, 3, 250, 11)); 
final List<double> stops = <double>[]; 
    stops.add(0.0); 
    stops.add(0.5); 
    stops.add(1.0); 
final LinearGradient positiveGradientColors = LinearGradient( 
        colors: positiveColor, 
        stops: stops, 
        begin: Alignment.bottomCenter, 
        end: Alignment.topCenter); 
return Scaffold( 
        body: SfCartesianChart( 
          series: <ChartSeries<SampleData, num>>[ 
            AreaSeries( 
              borderColor: const Color.fromARGB(255, 0, 248, 128), 
              borderWidth: 3, 
              gradient: positiveGradientColors, 
              dataSource: chartData, 
              xValueMapper: (SampleData data, _) => data.x, 
              yValueMapper: (SampleData data, _) => data.y), 
          ], 
)))) 
 
Screenshot: 
 
 
  
Regards, 
Yuvaraj. 


Marked as answer

LE Leon February 19, 2022 04:58 PM UTC

Thanks for ur fast responding. I will test it in a few days and give a short feedback.



YG Yuvaraj Gajaraj Syncfusion Team February 21, 2022 01:40 PM UTC

Hi Leon, 
  
We will wait to hear from you. 
 
Regards, 
Yuvaraj. 



LE Leon February 24, 2022 03:32 PM UTC

Hello,

thanks for ur answer. Im still not able to get this gradient of my picture below. But i think thats not ur problem. The gradient function is working fine.

Greetings



YG Yuvaraj Gajaraj Syncfusion Team February 25, 2022 10:30 PM UTC

Hi Leon, 
 
Most welcome. Please check the above attached sample, the gradient will work for the area series. 
 
Regards, 
Yuvaraj. 


Loader.
Up arrow icon