UNPKG

light-chart

Version:

Charts for mobile visualization.

53 lines (52 loc) 1.13 kB
<!DOCTYPE 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') .style({ fillOpacity: 0.65 }); chart.render(); }); </script> </body> </html>