Chart.js issue

by Marvin Heilemann

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js"></script>
<canvas id="myChart"></canvas>

JavaScript

var data1 = [0.001, 0.002, 0.005, 0.005, 0.006, 0.006, 0.012, 0.012, 0.013, 0.013, 0.013, 0.015];
var data2 = [0, 0.002, 0.002, 0.003, 0.003, 0.003, 0.003, 0.003, 0.005, 0.005, 0.009, 0.009];

var maxticks = 12;
var max1 = _.max(data1)
var max2 = _.max(data2)
var maxSize = max1 > max2 ? max1 : max2;
var stepSize = maxSize / maxticks;

// use custom step size (fixed in this data case)
stepSize = 0.002;

console.log(data1);
console.log(data2);
console.log(maxSize);
console.log(stepSize);

var ctx = document.getElementById('myChart').getContext('2d');

var chart = new Chart(ctx, {
  data: {
    labels: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
    datasets: [{
      label: 'KU1',
      yAxisID: 'axis-accumulation',
      data: data1,
      type: 'line',
      backgroundColor: 'transparent',
      borderColor: 'rgba(232, 62, 140, 0.5)',
      pointBackgroundColor: 'rgba(232, 62, 140, 0.5)',
      pointBorderWidth: 0,
      pointRadius: 2,
      borderWidth: 1,
      datalabels: {
        display: false,
      },
    }, {
      label: 'KU2',
      yAxisID: 'axis-accumulation',
      data: data2,
      type: 'line',
      backgroundColor: 'transparent',
      borderColor: 'rgba(120, 21, 185, 0.5)',
      pointBackgroundColor: 'rgba(120, 21, 185, 0.5)',
      pointBorderWidth: 0,
      pointRadius: 2,
      borderWidth: 1,
      datalabels: {
        display: false,
      },
    }],
  },

  // Configuration options go here
  options: {
    responsive: true,
    title: {
      display: true,
      text: "KS"
    },
    verticalGuide: {
      color: '#2d2d2d',
    },
    hover: {
      mode: 'index',
      intersect: false,
    },
    tooltips: {
      mode: 'index',
      intersect: false,
      position: 'nearest',
      bodySpacing: 6,
      callbacks: {
        label: tooltipItem => {
          let val = tooltipItem.label
          if (val == 0) {
            val = val + '≤'
          }

          return val + ' Mio €'
        },
      },
    },
  ...