Knowledge Base

Automatically color segments of the line graph based on positive or negative change in value

This demo uses graph’s useNegativeColorIfDown property. If it’s set to true the chart will check values when drawing the line (or column). If the previous value is bigger than the current one, the segment of the line graph (or column) will be drawn using negativeLineColor or negativeFillColors settings.

var chart = AmCharts.makeChart( "chartdiv", {
  "type": "serial",
  // config skipped
  // ...
  "graphs": [ {
    "lineThickness": 3,
    "useNegativeColorIfDown": true,
    "negativeLineColor": "#c00",
    "valueField": "value"
  } ]
} );