Chart.js - line chart with two yAxis - Javascript Chart.js

Javascript examples for Chart.js:Line Chart

Description

Chart.js - line chart with two yAxis

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>chart.js 2.1</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.0/Chart.bundle.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){// w  w  w . j  a  v  a2s .  c  o m
var ctx = document.getElementById("chart").getContext("2d");
var myChart = new Chart(ctx, {
  type: "line",
  data: {
    "labels": [
      "01.12.2015",
      "02.12.2015",
      "03.12.2015",
      "04.12.2015",
      "30.12.2015"
    ],
    "datasets": [{
      "label": "DEA Burrweiler Druck Abgabe",
      "fill": "false",
      yAxisID: "y-axis-0",
      "data": [8.7,6.6,8.7,4.7,5.7
      ]
    }, {
      "label": "DEA Burrweiler Druck Zulauf",
      "fill": "false",
      yAxisID: "y-axis-0",
      "data": [
        1.5,
        4.5,
        3.5,
        4.5,
        2.5
      ]
    }, {
      "label": "DMS Flemlingen Durchfluss",
      "fill": "false",
      yAxisID: "y-axis-1",
      "data": [
        1.9588,
        2.4226,
        2.1392,
        2.223,
        1.9048
      ]
    }]
  },
  options: {
    scales: {
      yAxes: [{
        position: "left",
        "id": "y-axis-0"
      }, {
        position: "right",
        "id": "y-axis-1"
      }]
    }
  }
});
    }

      </script> 
   </head> 
   <body> 
      <canvas id="chart"></canvas>  
   </body>
</html>

Related Tutorials