Area chart with color above a threshold - CanvasJS JavaScript Charts

Area chart with color above a threshold - CanvasJS JavaScript Charts

by canvasjs

HTML

<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<br/><!-- Just so that JSFiddle's Result label doesn't overlap the Chart -->
<div id="chartContainer" style="height: 360px; width: 100%;"></div>

JavaScript

var dataPoints = [        
        { x: 10, y: 71},
        { x: 20, y: 55},
        { x: 30, y: 70 },
        { x: 40, y: 55 },
        { x: 50, y: 85, indexLabel: "high", markerType: "triangle",markerColor: "green", markerSize: 12 },
        { x: 60, y: 68 },
        { x: 70, y: 28 },
        { x: 80, y: 34 },
        { x: 90, y: 24,  indexLabel: "low", markerType: "cross",markerColor: "green" , markerSize: 12 }
        ];
var threshold = 60;        

var chart = new CanvasJS.Chart("chartContainer",
    {
      title:{
       text: "Area chart with color above a threshold"   
      },
      
      axisY:{
      	gridThickness:0,
        stripLines:[{
        	value: threshold,
        	showOnTop: true,
        }],
        viewportMinimum: -0.2,
      },
      
      data: [
      {        
        type: "area", 
        dataPoints: dataPoints
      },
      {        
        type: "area",
        toolTipContent: null,
        highlightEnabled: false,
        color: "white",
        fillOpacity: 1,
        markerSize: 0,
        dataPoints: [{ x: 10, y: threshold},
        						{ x: 90, y: threshold}]
      },{        
        type: "line",
        dataPoints: dataPoints
      }
      ]
    });

    chart.render();