Run
Auto Run
const chartColors = [ 'rgb(255, 99, 132)', 'rgb(255, 159, 64)', 'rgb(255, 205, 86)', 'rgb(75, 192, 192)', 'rgb(54, 162, 235)', 'rgb(153, 102, 255)', 'rgb(201, 203, 207)' ] define('my-app', class extends WeElement { install(){ this.chartData = { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [{ label: '# of Votes', data: [12, 19, 3, 5, 5, 3], yAxisID: 'y-axis-1', backgroundColor: Chart.helpers.color(chartColors[0]).alpha(0.2).rgbString(), borderColor: chartColors[0], borderWidth: 1 },{ label: '# of Votes', data: [7, 17, 13, 5, 12, 13], yAxisID: 'y-axis-2', backgroundColor: Chart.helpers.color(chartColors[1]).alpha(0.2).rgbString(), borderColor: chartColors[1], borderWidth: 1 } ] } this.chartOptions = { responsive: true, title: { display: true, text: 'Omi-chart Bar Chart - Multi Axis' }, tooltips: { mode: 'index', intersect: true }, scales: { yAxes: [{ type: 'linear', // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance display: true, position: 'left', id: 'y-axis-1', }, { type: 'linear', // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance display: true, position: 'right', id: 'y-axis-2', gridLines: { drawOnChartArea: false } }], } } } onClick = ()=>{ this.chartData.datasets.forEach((dataset, index) => { dataset.data.forEach((item, subIndex) => { dataset.data[subIndex] = Math.random() * 100 - index * Math.random() * 200 }) }) this.update() } render(props, data) { return (
Change data
) } }) render(
, 'body')