Chart / olddataset /web /Vchart /line /chart_0014_line.html
Pekku's picture
Upload folder using huggingface_hub
79dc9c8 verified
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>VChart Area Demo</title>
<!-- 1) 引入 VChart(CDN) -->
<!-- 如果这个不通,再把它换成:https://unpkg.com/@visactor/vchart/build/index.min.js -->
<script src="https://cdn.jsdelivr.net/npm/@visactor/vchart/build/index.min.js"></script>
<style>
/* 2) 给容器一个高度,不然你可能看不到图 */
#chart {
width: 100%;
height: 520px;
}
</style>
</head>
<body>
<!-- 3) 图表容器:id 要和下面 JS 里的 dom 对上 -->
<div id="chart"></div>
<script>
const spec = {
type: "area",
data: {
values: [
{ type: "Nail polish", country: "Africa", value: 4229 },
{ type: "Nail polish", country: "EU", value: 4376 },
{ type: "Nail polish", country: "China", value: 3054 },
{ type: "Nail polish", country: "USA", value: 12814 },
{ type: "Eyebrow pencil", country: "Africa", value: 3932 },
{ type: "Eyebrow pencil", country: "EU", value: 3987 },
{ type: "Eyebrow pencil", country: "China", value: 5067 },
{ type: "Eyebrow pencil", country: "USA", value: 13012 },
{ type: "Rouge", country: "Africa", value: 5221 },
{ type: "Rouge", country: "EU", value: 3574 },
{ type: "Rouge", country: "China", value: 7004 },
{ type: "Rouge", country: "USA", value: 11624 },
{ type: "Lipstick", country: "Africa", value: 9256 },
{ type: "Lipstick", country: "EU", value: 4376 },
{ type: "Lipstick", country: "China", value: 9054 },
{ type: "Lipstick", country: "USA", value: 8814 },
{ type: "Eyeshadows", country: "Africa", value: 3308 },
{ type: "Eyeshadows", country: "EU", value: 4572 },
{ type: "Eyeshadows", country: "China", value: 12043 },
{ type: "Eyeshadows", country: "USA", value: 12998 },
{ type: "Eyeliner", country: "Africa", value: 5432 },
{ type: "Eyeliner", country: "EU", value: 3417 },
{ type: "Eyeliner", country: "China", value: 15067 },
{ type: "Eyeliner", country: "USA", value: 12321 },
{ type: "Foundation", country: "Africa", value: 13701 },
{ type: "Foundation", country: "EU", value: 5231 },
{ type: "Foundation", country: "China", value: 10119 },
{ type: "Foundation", country: "USA", value: 10342 },
{ type: "Lip gloss", country: "Africa", value: 4008 },
{ type: "Lip gloss", country: "EU", value: 4572 },
{ type: "Lip gloss", country: "China", value: 12043 },
{ type: "Lip gloss", country: "USA", value: 22998 },
{ type: "Mascara", country: "Africa", value: 18712 },
{ type: "Mascara", country: "EU", value: 6134 },
{ type: "Mascara", country: "China", value: 10419 },
{ type: "Mascara", country: "USA", value: 11261 }
]
},
title: {
visible: true,
text: "Unstacked area chart of cosmetic products sales"
},
stack: false,
xField: "type",
yField: "value",
seriesField: "country",
legends: [{ visible: true, position: "middle", orient: "bottom" }]
};
// 4) 关键点:CDN 引入时一般用 VChart.default
const vchart = new VChart.default(spec, { dom: "chart" });
vchart.renderSync();
// 5) 这行是为了方便你在控制台调试;不需要就删掉
window.vchart = vchart;
</script>
</body>
</html>