Frappe Charts简单直观的零依赖图表库
Frappé Charts 是一个现代、直观且反应灵敏的图表库,无任何依赖。
如何构建图表
安装
npm install frappe-charts
导入至项目
import Chart from "frappe-charts/dist/frappe-charts.min.esm"
...或将其直接放入 HTML 中
<script src="https://unpkg.com/frappe-charts@0.0.5/dist/frappe-charts.min.iife.js"></script>
制作一个新的图表
<!--HTML--> <div id="chart"></div>
// Javascript let data = { labels: ["12am-3am", "3am-6am", "6am-9am", "9am-12pm", "12pm-3pm", "3pm-6pm", "6pm-9pm", "9pm-12am"], datasets: [ { title: "Some Data", color: "light-blue", values: [25, 40, 30, 35, 8, 52, 17, -4] }, { title: "Another Set", color: "violet", values: [25, 50, -10, 15, 18, 32, 27, 14] }, { title: "Yet Another", color: "blue", values: [15, 20, -3, -15, 58, 12, -17, 37] } ] }; let chart = new Chart({ parent: "#chart", // or a DOM element title: "My Awesome Chart", data: data, type: 'bar', // or 'line', 'scatter', 'pie', 'percentage' height: 250, format_tooltip_x: d => (d + '').toUpperCase(), format_tooltip_y: d => d + ' pts' });
评论