ChartAct / web /Vchart /bar /chart_0018_bar.html
wumumu's picture
Add files using upload-large-folder tool
7b52e07 verified
Raw History Blame Contribute Delete
1.5 kB
<div id="chart" style="width:100%;height:520px;"></div>
<script src="_deps/cdn.jsdelivr.net/npm/@visactor/vchart/build/index.min.js"></script>
<script>
// 这里粘贴你的那段 JS 代码
const spec = {
type: 'bar',
color: ['#becef3', '#6a8edc', '#77caeb', '#52c93b', '#d3f5e8'],
data: [
{
id: 'barData',
values: [
{ type: 'A', year: '2000', value: 25 },
{ type: 'A', year: '2010', value: 28 },
{ type: 'A', year: '2018', value: 18 },
{ type: 'B', year: '2000', value: 23 },
{ type: 'B', year: '2010', value: 32 },
{ type: 'B', year: '2018', value: 22 },
{ type: 'C', year: '2000', value: 18 },
{ type: 'C', year: '2010', value: 18 },
{ type: 'C', year: '2018', value: 18 },
{ type: 'D', year: '2000', value: 15 },
{ type: 'D', year: '2010', value: 22 },
{ type: 'D', year: '2018', value: 19 },
{ type: 'E', year: '2000', value: 5 },
{ type: 'E', year: '2010', value: 12 },
{ type: 'E', year: '2018', value: 5 }
]
}
],
xField: ['year', 'type'],
yField: 'value',
seriesField: 'type',
axes: [
{
orient: 'bottom',
paddingInner: 0.3
}
],
bar: {
style: {
fillOpacity: 0.9
}
}
};
const vchart = new VChart.default(spec, { dom: "chart" });
vchart.renderSync();
// Just for the convenience of console debugging, DO NOT COPY!
window['vchart'] = vchart;
// 只要记得:dom 要写成 "chart"
</script>