Multiple charts gradient overlapping the border

Hello, Im making a multiple chart with 2 AreaSeries series, and I have gradients and borders on both of them. The issue is that the colors are mixing and the borders are not on top of the gradient even though Im using 

 borderDrawMode: BorderDrawMode.top


Sample code:

                        AreaSeries<ChartData, String>(
                            borderColor: Colors.green,
                            borderDrawMode: BorderDrawMode.top,
                            borderWidth: 4,
                            gradient: LinearGradient(
                                begin: Alignment.topCenter,
                                end: Alignment.bottomCenter,
                                colors: [Colors.green.withOpacity(0.7), Colors.green.withOpacity(0.2)]),
                            color: Colors.green,
                            dataSource: chartData1,
                            xValueMapper: (ChartData data, _) => data.x,
                            yValueMapper: (ChartData data, _) => data.y),

Image_8271_1712137913774

3 Replies 1 reply marked as answer

LP Lokesh Palani Syncfusion Team April 4, 2024 05:40 PM UTC

Hi Michael,


We would like to inform you that when the borderDrawMode is set to BorderDrawMode.top in the AreaSeries, the border will render only for the top side. You can avoid color overlapping by using the LineSeries above the AreaSeries. We have shared a code snippet, screenshot, and sample for your reference. Please let us know if you have any further needs.


UG Link,

https://help.syncfusion.com/flutter/cartesian-charts/chart-types/area-chart#border-customization


Code Snippet:

series: <CartesianSeries<_SalesData, String>>[

          AreaSeries<_SalesData, String>(

            dataSource: data,

            borderColor: Colors.green,

            borderDrawMode: BorderDrawMode.top,

            borderWidth: 4,

            gradient: LinearGradient(

              begin: Alignment.topCenter,

              end: Alignment.bottomCenter,

              colors: [

                Colors.green.withOpacity(0.7),

                Colors.green.withOpacity(0.2)

              ],

            ),

            xValueMapper: (_SalesData sales, _) => sales.year,

            yValueMapper: (_SalesData sales, _) => sales.sales0,

          ),

          AreaSeries<_SalesData, String>(

            dataSource: data,

            borderColor: Colors.orange,

            borderDrawMode: BorderDrawMode.top,

            borderWidth: 4,

            gradient: LinearGradient(

              begin: Alignment.topCenter,

              end: Alignment.bottomCenter,

              colors: [

                Colors.orange.withOpacity(0.7),

                Colors.orange.withOpacity(0.2)

              ],

            ),

            xValueMapper: (_SalesData sales, _) => sales.year,

            yValueMapper: (_SalesData sales, _) => sales.sales1,

          ),

          LineSeries<_SalesData, String>(

            dataSource: data,

            color: Colors.green,

            width: 4,

            xValueMapper: (_SalesData sales, _) => sales.year,

            yValueMapper: (_SalesData sales, _) => sales.sales0,

          ),

          LineSeries<_SalesData, String>(

            dataSource: data,

            color: Colors.orange,

            width: 4,

            xValueMapper: (_SalesData sales, _) => sales.year,

            yValueMapper: (_SalesData sales, _) => sales.sales1,

          ),

        ],

 



Screenshot:



Regards,

Lokesh P.



Marked as answer

MB Michael Bardon April 4, 2024 05:45 PM UTC

Exactly what I was looking for, thanks!



LP Lokesh Palani Syncfusion Team April 5, 2024 09:36 AM UTC

Hi Michael,


Most Welcome. Kindly get back to us if you have further queries. We are always happy to assist you.


Regards,

Lokesh P.


Loader.
Up arrow icon