light-chart
Version:
Charts for mobile visualization.
54 lines (53 loc) • 1.16 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<title>多色散点图</title>
<link rel="stylesheet" href="./assets/common.css">
</head>
<body>
<div>
<canvas id="mountNode"></canvas>
</div>
<script src="./assets/jquery-3.2.1.min.js"></script>
<script src="../build/f2-all.js"></script>
<script>
$.getJSON('./data/scatter.json', data => {
const chart = new F2.Chart({
id: 'mountNode',
width: window.innerWidth,
height: window.innerWidth * 0.64,
pixelRatio: window.devicePixelRatio
});
chart.source(data, {
height: {
tickCount: 5
},
weight: {
tickCount: 5
}
});
chart.axis('height', {
label(text, index, total) {
const textCfg = {};
if (index === 0) {
textCfg.textAlign = 'left';
}
if (index === total - 1) {
textCfg.textAlign = 'right';
}
return textCfg;
}
});
chart.tooltip(false);
chart.point()
.position('height*weight')
.color('gender')
.style({
fillOpacity: 0.65
});
chart.render();
});
</script>
</body>
</html>