Search code examples
amcharts

AM Charts Defined Colour Scale on Heat Map


I want to create a Heat Map and I am using the following example from AmCharts4:

Heat Map Example

How do I define the maximum and minimum values for the colour scale, rather than just let it use the values from the data set?

Here is the line of code I think I need to modify but not sure how:

series.heatRules.push({target:columnTemplate, property:"fill", min:am4core.color("#ffffff"), max:am4core.color("#692155")});

Solution

  • Heat map rules can take a minValue and maxValue if you don't want them to derive the range from your dataset:

    series.heatRules.push({
      target:columnTemplate, 
      property:"fill", 
      min:am4core.color("#ffffff"), 
      max:am4core.color("#692155"),
      minValue: 2000,
      maxValue: 5000
    });
    

    Updated codepen