Uplot Barchart Plugin
HTML
<script src="https://unpkg.com/vue"></script>
<link rel="stylesheet" href="https://leeoniya.github.io/uPlot/src/uPlot.css">
<script src="https://leeoniya.github.io/uPlot/dist/uPlot.iife.js"></script>
<div id="app">
<div ref="chart"></div>
</div>
JavaScript
new Vue(
{
beforeDestroy()
{
if(this.chart)
this.chart.destroy();
},
el: "#app",
mounted()
{
let data =
[
[1, 2, 3, 4],
[35, 71, 32, 18],
[55, 53, 50, 49]
];
let opts =
{
title: "My Chart",
width: 640,
height: 480,
scales:
{
x: { time: false }
},
series:
[
{},
{
label: 'Series 1',
stroke: 'red',
width: 1,
fill: 'rgba(255, 0, 0, 0.3)',
},
{
label: 'Series 2',
stroke: 'blue'
}
],
};
this.chart = new uPlot(opts, data, this.$refs.chart);
}
}
);