How to apply colors on postive and negative value

I have data which include both positive and negative values. How can I config colorMappers, for example: red for negative values and green for positive values?


Thanks and best regards


1 Reply

YG Yuvaraj Gajaraj Syncfusion Team April 19, 2022 02:16 PM UTC

Hi Duong,


Greetings from Syncfusion. We suggest you use the colorMapper property in the treemap that will help you to map the respective color based on the positive and negative values. We have also had the demo sample and code snippet that can be found in the link below.


Sample: https://flutter.syncfusion.com/#/treemap/range-color-mapping


Code link: https://github.com/syncfusion/flutter-examples/blob/master/lib/samples/treemap/range_color_mapping.dart#L520


Code snippet:

SfTreemap(

  colorMappers: const <TreemapColorMapper>[

    TreemapColorMapper.range(

        from: -100, to: -1, color: Color.fromRGBO(255, 0, 0, 1.0)),

    TreemapColorMapper.range(

       from: 0, to: 100, color: Color.fromRGBO(0, 255, 0, 1.0)),

  ],

//Other required properties

)


Regards,

Yuvaraj.


Loader.
Up arrow icon