Spline Area chart with different color above a threshold - CanvasJS JavaScript Charts

Spline Area chart with different 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: 91},
        { x: 20, y: 75},
        { x: 30, y: 90 },
        { x: 40, y: 75 },
        { x: 50, y: 105 },
        { x: 60, y: 88 },
        { x: 70, y: 48 },
        { x: 80, y: 54 },
        { x: 90, y: 44 }
        ];
var threshold =80;


var chart = new CanvasJS.Chart("chartContainer",
    {
      title:{
       text: "Spline Area chart with different color above a threshold"   
      },
      
      axisY:{
      	gridThickness:0,
        viewportMinimum: -0.3,
      },
      
      data: [
      {        
        type: "splineArea",
        lineThickness:0,
        markerSize:0,
        toolTipContent: null,
        highlightEnabled: false,
        //color:"#FF0000",
        fillOpacity: 1,
        dataPoints: dataPoints
      },
      {        
        type: "splineArea",
        lineThickness:0,
        toolTipContent: null,
        highlightEnabled: false,
        color: "white",
        fillOpacity: 1,
        markerSize: 0,
        dataPoints: [{ x: 10, y: threshold},
        						{ x: 90, y: threshold}]
      },
      {        
        type: "splineArea",
        //lineThickness:0,
        fillOpacity: 0.3,
        //color:"#00FF00",
        dataPoints: dataPoints
      }
      ]
    });

    chart.render();