File size: 1,699 Bytes
7b52e07 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | <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 data = [
{
name: 'boxPlot',
values: [
{
x: 'Sub-Saharan Africa',
y1: 8.72,
y2: 9.73,
y3: 10.17,
y4: 10.51,
y5: 11.64
},
{
x: 'South Asia',
y1: 9.4,
y2: 10.06,
y3: 10.75,
y4: 11.56,
y5: 12.5
},
{
x: 'Middle East & North Africa',
y1: 9.54,
y2: 10.6,
y3: 11.05,
y4: 11.5,
y5: 11.92
},
{
x: 'Latin America & Caribbean',
y1: 8.74,
y2: 9.46,
y3: 10.35,
y4: 10.94,
y5: 12.21
},
{
x: 'East Asia & Pacific',
y1: 7.8,
y2: 8.95,
y3: 10.18,
y4: 11.57,
y5: 13.25
},
{
x: 'Europe & Central Asia',
y1: 9.52,
y2: 10.39,
y3: 10.93,
y4: 11.69,
y5: 12.63
}
]
}
];
const spec = {
type: 'boxPlot',
data: data,
xField: 'x',
minField: 'y1',
q1Field: 'y2',
medianField: 'y3',
q3Field: 'y4',
maxField: 'y5',
direction: 'vertical',
boxPlot: {
style: {
// boxWidth: 50, // 不指定则自适应宽度
// shaftWidth: 60,
shaftShape: 'line',
lineWidth: 2
}
}
};
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>
|