Skip to content

Instantly share code, notes, and snippets.

@typpo
Created March 17, 2020 23:04
Show Gist options
  • Save typpo/1c6009f70e47962bcd32c163268b7ea9 to your computer and use it in GitHub Desktop.
Save typpo/1c6009f70e47962bcd32c163268b7ea9 to your computer and use it in GitHub Desktop.

Revisions

  1. typpo created this gist Mar 17, 2020.
    25 changes: 25 additions & 0 deletions example.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    const { stringify } = require('javascript-stringify');

    const chartObj = {
    type: 'bar',
    data: {
    labels: ['January', 'February', 'March', 'April', 'May'],
    datasets: [{
    label: 'Dogs',
    data: [ 50, 60, 70, 180, 190 ]
    }]
    },
    options: {
    scales: {
    yAxes: [{
    ticks: {
    callback: function(value) {
    return '$' + value;
    }
    }
    }],
    },
    },
    };

    console.log(encodeURIComponent(stringify(chartObj)));