JSFiddle - React, Tailwind, and code Playground

by xin zhang

HTML

<script src="https://unpkg.com/vue"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.js" charset="utf-8"></script>
<div id="demo">
    <canvas id="canvas" width="300" height="300" v-demo></canvas>
  </div>

JavaScript

window.chartColors = {
    blue: 'rgb(188, 214, 236)',
  };

  Vue.directive('demo', {
    bind: function(el, binding) {
      console.log(1);
      //cpuCanvas.draw(el, binding.value);
      var ctx = el.getContext("2d");
      var config = {
        type: 'line',
        data: {
          labels: ["January", "February"],
          datasets: [{
            label: "My First dataset",
            borderColor: window.chartColors.blue,
            data: [
              1, 2
            ],
            fill: false,
          }]
        },
        options: {
          responsive: false,
          scales: {
            xAxes: [{
              display: true,
              scaleLabel: {
                display: true,
                labelString: 'Month'
              }
            }],
            yAxes: [{
              display: true,
              scaleLabel: {
                display: true,
                labelString: 'Value'
              }
            }]
          }
        }
      };
      var chart = new Chart(ctx, config)
    }
  })

  new Vue({
    el: "#demo",
    data: []
  })