Full option Line Chart

The working example of full option line chart.

by Bharadhwaj CN

HTML

<script src="https://d3js.org/d3.v4.min.js"></script>
<link rel="stylesheet" href="https://bharadhwajcn.github.io/cinch-charts/static/css/min/cinch-charts.min.css">
<script src="https://bharadhwajcn.github.io/cinch-charts/static/js/min/line.min.js"></script>
<div class="chart-container" id="first-chart"> </div>

CSS

.chart-container {
  height: 90%;
  width: 100%;
}

JavaScript

var element = document.querySelector('#first-chart');

var data = [
  ['Jan', 10],
  ['Feb', 70],
  ['Mar', 30],
  ['Apr', 10],
  ['May', null],
  ['Jun', 45],
  ['Jul', 76],
  ['Aug', 40],
  ['Sep', 40],
  ['Oct', 60],
  ['Nov', 40],
  ['Dec', 80]
];

var chart = new LineChart(element, data, {
  line: {
    color: '#B8D551',
    width: 4,
    icon: {
      show: true,
      url: 'https://bharadhwajcn.github.io/cinch-charts/static/images/green_circle.png',
      toBase64: false,
      class: 'point-icon',
      width: 10
    }
  },
  threshold: {
    value: 50,
    icon: {
      url: 'https://bharadhwajcn.github.io/cinch-charts/static/images/orange_circle.png',
      toBase64: false,
    }
  },
  grids: {
    vertical: {
      show: true,
      color: '#999',
      opacity: .5, 
    },
    horizontal: {
      show: true,
      color: '#999',
      opacity: .5,
      skipFirst: false,
      skipLast: false,
      values: [10, 30, 50, 70, 80]       
    }
  },
  transition: {
    animate: true,
    duration: 2000
  },
  margin: {
    left: 0,
    right: 0,
    top: 0,
    bottom: 0
  },
  goalLine: {
    value: 50,
    class: 'goalline',
    icon: {
      url: 'https://bharadhwajcn.github.io/cinch-charts/static/images/goal_arrow.png',
      class: 'goal-icon',
      height: 15,
      width: 13,
      left: 0
    }
  },
  axis: {
    xAxis: {
      showAxisLine: false,
      firstLabel: true, 
      orientation: 'bottom',
      ticks: {
        values: ['Jan', 'Mar', 'May', 'Aug', 'Oct', 'Dec'],
        padding: 10,
				formatter: function(value) {
          return value + " '17";
        }
      }
    },
    yAxis: {
      showAxisLine: false,
      firstLabel: false, 
      orientation: 'left',
      ticks: {
        values: [{
          value: 10,
          label: '10 m unit'
        }, {
          value: 30,
          label: '30 m unit'
        }, {
          value: 50,
          label: '50 m unit'
        }, {
          value: 70,
          label: '70 m unit'
 ...