文档:
http://www.ruanyifeng.com/blog/2019/04/weekly-issue-52.html(软件-通过url生成图表的开源服务)
https://quickchart.io/
demo:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<img id="bar" src="" />
<script>
window.onload = function() {
var obj = {
type: 'bar',
data: {
labels: ['January', 'February', 'March', 'April', 'May'],
datasets: [{
label: 'Dogs',
data: [50, 60, 70, 180, 190]
}, {
label: 'Cats',
data: [100, 200, 300, 400, 500]
}, {
label: 'Cats',
data: [100, 200, 300, 400, 500]
}, {
label: 'Cats',
data: [100, 200, 300, 400, 500]
}]
}
};
document.getElementById("bar").src = `https://quickchart.io/chart?width=500&height=300&c=${JSON.stringify(obj)}`
}
</script>
</body>
</html>