charts README

项目的 README,来自 github.com/frappe/charts。合并为一个 markdown 文件:README.md。

Frappe Charts logo

Frappe Charts

Simple, modern SVG charts for the web, with zero dependencies

Test and Release npm version gzipped size

Live demos

Frappe Charts: mixed axis, line with a today marker, horizontal bar and donut charts

Frappe Charts

Frappe Charts is a small charting library with a simple API. It started as the sales graph in ERPNext and is now used for charts across the Frappe Framework.

Key Features

Usage

npm install frappe-charts
import { Chart } from 'frappe-charts';
import 'frappe-charts/dist/frappe-charts.min.css';

Or load it in the browser:

<link rel="stylesheet" href="https://unpkg.com/frappe-charts/dist/frappe-charts.min.css">
<script src="https://unpkg.com/frappe-charts/dist/frappe-charts.umd.js"></script>
<!-- the browser build exposes window['frappe-charts'].Chart -->
const chart = new Chart('#chart', {
  title: 'Sales by channel',
  type: 'axis-mixed', // or 'bar', 'line', 'donut', 'pie', 'percentage', 'heatmap'
  height: 250,
  colors: ['#318ad8', '#30a66d'],
  data: {
    labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
    datasets: [
      { name: 'Online', chartType: 'bar', values: [42, 48, 39, 55, 61, 58] },
      { name: 'Target', chartType: 'line', values: [60, 62, 64, 68, 72, 76] }
    ],
    yMarkers: [{ label: 'Goal', value: 70 }]
  }
});

chart.addDataPoint('Jul', [66, 80]);
chart.export();

For a horizontal bar chart, use type: 'bar' with barOptions: { horizontal: 1 }.

Development Setup



Frappe Technologies

charts (frappe/charts)

正在搜索数据库…

15.1K ·GitHub
这是干什么的?Frappe Charts 是一个轻量级的 JavaScript 图表库,以 SVG 的形式渲染简洁、自适应的图表,而且没有任何依赖。
这是托管服务,还是需要嵌入我自己页面的库?它是一个库:你可以把它导入到项目里,或在 HTML 中加一个 script 标签,图表就会直接在浏览器里以 SVG 的形式渲染出来。
怎么把它加到项目里?导入安装好的包,或直接在 HTML 中引入 script 标签。如果想参与开发这个库本身,就克隆仓库,运行 npm install,然后运行 npm run dev。
它会引入其他库吗?不会——零依赖是它的主打特点,所以不需要提前安装别的东西。
它能画哪些类型的图表?支持柱状图、折线图、面积图等坐标轴图表,还有混合坐标轴图、饼图、百分比图和热力图。你还可以在图表上添加 x 轴和 y 轴标记线、高亮区域以及悬浮提示。
作者为什么不直接用 c3.js,而要新写一个图表库?ERPNext 需要一个简单的销售历史图表,但 c3.js 和产品的经典设计风格不搭,其他 JS 库又显得太复杂或太死板。于是作者写了一个小而专的库,专注于把数值对转换成简单的图形和位置。
图表已经显示在页面上之后,还能更新数据吗?可以——你可以就地添加、删除或更新单个数据点,也可以整体刷新数据集。颜色、动画和自定义标题也都是可以配置的。
不安装任何东西能先试用吗?可以——README 里有在线演示的链接,其中包括 CodeSandbox 上的可编辑版本,你可以先在浏览器里直接体验。
有哪些类似的项目?uPlot, d3, apexcharts.js, Chart.js, plotly.js, visx, highcharts, G6
作者
frappe
大小
6.9 MB
星标
15.1K
时长
9年
提交 · 90 天