UNPKG

light-chart

Version:

Charts for mobile visualization.

51 lines (49 loc) 1.17 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> const data = [ { year: '1951 年', sales: 38 }, { year: '1952 年', sales: 52 }, { year: '1956 年', sales: 61 }, { year: '1957 年', sales: 145 }, { year: '1958 年', sales: 48 }, { year: '1959 年', sales: 38 }, { year: '1960 年', sales: 38 }, { year: '1962 年', sales: 38 }, ]; const chart = new F2.Chart({ id: 'mountNode', width: window.innerWidth, height: window.innerWidth * 0.64, pixelRatio: window.devicePixelRatio }); chart.source(data, { sales: { min: 20, } }); chart.tooltip({ showItemMarker: false, onShow(ev) { const { items } = ev; items[0].name = null; // items[0].name = items[0].title; items[0].value = '¥ ' + items[0].value; } }); chart.interval().position('year*sales'); chart.render(); </script> </body> </html>