frappe-charts 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,155 +1,95 @@
1
- <div align="center">
2
- <img src="https://github.com/frappe/design/blob/master/logos/logo-2019/frappe-charts-logo.png" height="128">
3
- <a href="https://frappe.github.io/charts">
4
- <h2>Frappe Charts</h2>
5
- </a>
6
- <p align="center">
7
- <p>GitHub-inspired modern, intuitive and responsive charts with zero dependencies</p>
8
- <a href="https://frappe.github.io/charts">
9
- <b>Explore Demos » </b>
10
- </a>
11
- <a href="https://codepen.io/pratu16x7/pen/wjKBoq">
12
- <b> Edit at CodePen »</b>
13
- </a>
14
- </p>
1
+ <div align="center" markdown="1">
2
+
3
+ <img width="80" alt="Frappe Charts logo" src="https://github.com/user-attachments/assets/37b7ffaf-8354-48f2-8b9c-fa04fae0135b">
4
+
5
+ <h1>Frappe Charts</h1>
6
+
7
+ **Simple, modern SVG charts for the web, with zero dependencies**
8
+
9
+ [![Test and Release](https://github.com/frappe/charts/actions/workflows/publish.yml/badge.svg)](https://github.com/frappe/charts/actions/workflows/publish.yml)
10
+ [![npm version](https://img.shields.io/npm/v/frappe-charts.svg)](https://www.npmjs.com/package/frappe-charts)
11
+
12
+ [Live demos](https://frappe.io/charts)
13
+
14
+ <img alt="Frappe Charts: mixed axis, line with a today marker, horizontal bar and donut charts" src=".github/charts.png">
15
+
15
16
  </div>
16
17
 
17
- <p align="center">
18
- <a href="https://travis-ci.org/frappe/charts">
19
- <img src="https://img.shields.io/travis/frappe/charts.svg?style=flat-square">
20
- </a>
21
- <a href="http://github.com/frappe/charts/tree/master/dist/js/frappe-charts.min.iife.js">
22
- <img src="http://img.badgesize.io/frappe/charts/master/dist/frappe-charts.min.iife.js.svg?compression=gzip">
23
- </a>
24
- </p>
25
-
26
- <p align="center">
27
- <a href="https://frappe.github.io/charts">
28
- <img src=".github/example.gif">
29
- </a>
30
- </p>
31
-
32
- ### Contents
33
- * [Installation](#installation)
34
- * [Usage](#usage)
35
- * [Contribute](https://frappe.io/charts/docs/contributing)
36
- * [Updates](#updates)
37
- * [License](#license)
38
-
39
- #### Installation
40
- * Install via [`npm`](https://www.npmjs.com/get-npm):
41
-
42
- ```sh
43
- $ npm install frappe-charts
44
- ```
45
-
46
- and include in your project:
47
- ```js
48
- import { Chart } from "frappe-charts"
49
- ```
50
-
51
- ...or include following for es-modules(eg:vuejs):
52
- ```js
53
- import { Chart } from 'frappe-charts/dist/frappe-charts.esm.js'
54
- // import css
55
- import 'frappe-charts/dist/frappe-charts.min.css'
56
- ```
57
-
58
- * ...or include within your HTML
59
-
60
- ```html
61
- <script src="https://cdn.jsdelivr.net/npm/frappe-charts@1.1.0/dist/frappe-charts.min.iife.js"></script>
62
- <!-- or -->
63
- <script src="https://unpkg.com/frappe-charts@1.1.0/dist/frappe-charts.min.iife.js"></script>
64
- ```
65
-
66
- #### Usage
67
- ```js
68
- const data = {
69
- labels: ["12am-3am", "3am-6pm", "6am-9am", "9am-12am",
70
- "12pm-3pm", "3pm-6pm", "6pm-9pm", "9am-12am"
71
- ],
72
- datasets: [
73
- {
74
- name: "Some Data", type: "bar",
75
- values: [25, 40, 30, 35, 8, 52, 17, -4]
76
- },
77
- {
78
- name: "Another Set", type: "line",
79
- values: [25, 50, -10, 15, 18, 32, 27, 14]
80
- }
81
- ]
82
- }
83
-
84
- const chart = new frappe.Chart("#chart", { // or a DOM element,
85
- // new Chart() in case of ES6 module with above usage
86
- title: "My Awesome Chart",
87
- data: data,
88
- type: 'axis-mixed', // or 'bar', 'line', 'scatter', 'pie', 'percentage'
89
- height: 250,
90
- colors: ['#7cd6fd', '#743ee2']
91
- })
92
- ```
18
+ ## Frappe Charts
93
19
 
94
- ...or for es-modules (replace `new frappe.Chart()` with `new Chart()`):
95
- ```diff
96
- - const chart = new frappe.Chart("#chart", {
97
- + const chart = new Chart("#chart", { // or a DOM element,
98
- // new Chart() in case of ES6 module with above usage
99
- title: "My Awesome Chart",
100
- data: data,
101
- type: 'axis-mixed', // or 'bar', 'line', 'scatter', 'pie', 'percentage'
102
- height: 250,
103
- colors: ['#7cd6fd', '#743ee2']
104
- })
105
- ```
20
+ Frappe Charts is a small charting library with a simple API. It started as the sales graph in [ERPNext](https://github.com/frappe/erpnext) and is now used for charts across the [Frappe Framework](https://github.com/frappe/frappe).
106
21
 
22
+ ### Key Features
107
23
 
108
- If you want to contribute:
24
+ - **Chart types**: bar, horizontal bar, line, mixed axis, donut, pie, percentage and heatmap.
25
+ - **Axis charts**: stacked bars, rounded bars, smooth or dashed lines, gaps in lines, region fill, X and Y markers and Y regions.
26
+ - **Tooltips**: one tooltip per column with every series in it, with your own number format.
27
+ - **Donut**: a total or your own value in the center, and `onClick` for slices and legend items.
28
+ - **Live data**: add, remove or replace data points, and the chart animates to the new shape.
29
+ - **Theming**: colors and lines come from CSS variables such as `--charts-label-color`, so dark mode is a few lines of CSS.
30
+ - **Export**: save any chart as an SVG file.
109
31
 
110
- 1. Clone this repo.
111
- 2. `cd` into project directory
112
- 3. `npm install`
113
- 4. `npm run dev`
32
+ ## Usage
114
33
 
115
- #### Updates
34
+ ```bash
35
+ npm install frappe-charts
36
+ ```
116
37
 
117
- ##### v1.0.0
118
- - Major rewrite out. Some new features include:
119
- - Mixed type axis datasets
120
- - Stacked bar charts
121
- - Value over data points
122
- - Y Markers and regions
123
- - Dot size, Bar space size, and other options
124
- - Legend for axis charts
125
- - We would be looking to incorporate existing PRs and issues in the meantime.
38
+ ```js
39
+ import { Chart } from 'frappe-charts';
40
+ import 'frappe-charts/dist/frappe-charts.min.css';
41
+ ```
126
42
 
127
- ##### Please read [#93](https://github.com/frappe/charts/issues/93) for v0.1.0 updates on rework and development.
43
+ Or load it in the browser:
128
44
 
129
- ##### v0.0.7
130
- - [Custom color values](https://github.com/frappe/charts/pull/71) for charts as hex codes. The API now takes an array of colors for all charts instead of a color for each dataset.
131
- - [@iamkdev's](https://github.com/iamkdev) blog on [usage with Angular](https://medium.com/@iamkdev/frappé-charts-with-angular-c9c5dd075d9f).
45
+ ```html
46
+ <link rel="stylesheet" href="https://unpkg.com/frappe-charts/dist/frappe-charts.min.css">
47
+ <script src="https://unpkg.com/frappe-charts/dist/frappe-charts.umd.js"></script>
48
+ <!-- the browser build exposes window['frappe-charts'].Chart -->
49
+ ```
132
50
 
133
- ##### v0.0.5
134
- - More [flexible Y values](https://github.com/frappe/charts/commit/3de049c451194dcd8e61ff91ceeb998ce131c709): independent from exponent, minimum Y axis point for line graphs.
135
- - Customisable [Heatmap colors](https://github.com/frappe/charts/pull/53); check out the Halloween demo on the [website](https://frappe.github.io/charts) :D
136
- - Tooltip values can be [formatted](https://github.com/frappe/charts/commit/e3d9ed0eae14b65044dca0542cdd4d12af3f2b44).
51
+ ```js
52
+ const chart = new Chart('#chart', {
53
+ title: 'Sales by channel',
54
+ type: 'axis-mixed', // or 'bar', 'line', 'donut', 'pie', 'percentage', 'heatmap'
55
+ height: 250,
56
+ colors: ['#318ad8', '#30a66d'],
57
+ data: {
58
+ labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
59
+ datasets: [
60
+ { name: 'Online', chartType: 'bar', values: [42, 48, 39, 55, 61, 58] },
61
+ { name: 'Target', chartType: 'line', values: [60, 62, 64, 68, 72, 76] }
62
+ ],
63
+ yMarkers: [{ label: 'Goal', value: 70 }]
64
+ }
65
+ });
137
66
 
138
- ##### v0.0.4
139
- - Build update: [Shipped](https://github.com/frappe/charts/pull/35) an ES6 module, along with the browser friendly IIFE.
67
+ chart.addDataPoint('Jul', [66, 80]);
68
+ chart.export();
69
+ ```
140
70
 
141
- ##### v0.0.2
142
- - We have an animated [Pie Chart](https://github.com/frappe/charts/issues/29)! Thanks [@sheweichun](https://github.com/sheweichun).
143
- - [@tobiaslins](https://github.com/tobiaslins) contributed tweaks for his quest to make these easy to use with React. Check out his [repo](https://github.com/tobiaslins/frappe-charts-react-example) and updates at [#24](https://github.com/frappe/charts/issues/24) to learn more :)
144
- - A new logo.
71
+ For a horizontal bar chart, use `type: 'bar'` with `barOptions: { horizontal: 1 }`.
145
72
 
146
- ##### v0.0.1
147
- - The very first version out, with animatable bars and lines, a percentage chart and a heatmap. GitHub-style.
73
+ ## Development Setup
148
74
 
149
- #### License
150
- This repository has been released under the [MIT License](LICENSE)
75
+ * `yarn install`
76
+ * `yarn watch` - Build on every change
77
+ * `yarn build` - Build `dist`
78
+ * `yarn test` - Run the Playwright tests (run `yarn playwright install chromium` once first)
79
+ * Commit messages follow [Conventional Commits](https://www.conventionalcommits.org). A merge to `master` runs the tests and publishes a new version to npm.
151
80
 
152
- ------------------
153
- Project maintained by [Frappe](https://frappe.io).
154
- Used in [ERPNext](https://erpnext.com). Read the [blog post](https://medium.com/@pratu16x7/so-we-decided-to-create-our-own-charts-a95cb5032c97).
81
+ ## Links
155
82
 
83
+ - [Release notes](https://github.com/frappe/charts/releases), and [older updates](CHANGELOG.md)
84
+ - [So we decided to create our own charts](https://medium.com/@pratu16x7/so-we-decided-to-create-our-own-charts-a95cb5032c97)
85
+
86
+ <br>
87
+ <br>
88
+ <div align="center" style="padding-top: 0.75rem;">
89
+ <a href="https://frappe.io" target="_blank">
90
+ <picture>
91
+ <source media="(prefers-color-scheme: dark)" srcset="https://frappe.io/files/Frappe-white.png">
92
+ <img src="https://frappe.io/files/Frappe-black.png" alt="Frappe Technologies" height="28"/>
93
+ </picture>
94
+ </a>
95
+ </div>