chart-xkcd 0.1.0__tar.gz
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.
- chart_xkcd-0.1.0/.claude/settings.local.json +11 -0
- chart_xkcd-0.1.0/.gitignore +20 -0
- chart_xkcd-0.1.0/CODE_OF_CONDUCT.md +70 -0
- chart_xkcd-0.1.0/CONTRIBUTING.md +30 -0
- chart_xkcd-0.1.0/LICENSE.md +21 -0
- chart_xkcd-0.1.0/PKG-INFO +7 -0
- chart_xkcd-0.1.0/README.md +3 -0
- chart_xkcd-0.1.0/assets/xkcd-script.ttf +0 -0
- chart_xkcd-0.1.0/docs/01-intro.md +22 -0
- chart_xkcd-0.1.0/docs/02-getting-started.md +35 -0
- chart_xkcd-0.1.0/docs/03-install.md +36 -0
- chart_xkcd-0.1.0/docs/04-line.md +52 -0
- chart_xkcd-0.1.0/docs/05-XY.md +73 -0
- chart_xkcd-0.1.0/docs/06-bar.md +40 -0
- chart_xkcd-0.1.0/docs/07-stacked-bar.md +51 -0
- chart_xkcd-0.1.0/docs/08-pie.md +45 -0
- chart_xkcd-0.1.0/docs/09-radar.md +52 -0
- chart_xkcd-0.1.0/examples/bar.py +14 -0
- chart_xkcd-0.1.0/examples/line.py +23 -0
- chart_xkcd-0.1.0/examples/pie.py +16 -0
- chart_xkcd-0.1.0/examples/radar.py +21 -0
- chart_xkcd-0.1.0/examples/stacked_bar.py +19 -0
- chart_xkcd-0.1.0/examples/xy.py +38 -0
- chart_xkcd-0.1.0/js/.claude/settings.local.json +14 -0
- chart_xkcd-0.1.0/js/eslint.config.mjs +26 -0
- chart_xkcd-0.1.0/js/examples/example.html +17 -0
- chart_xkcd-0.1.0/js/examples/index.js +242 -0
- chart_xkcd-0.1.0/js/package-lock.json +2100 -0
- chart_xkcd-0.1.0/js/package.json +43 -0
- chart_xkcd-0.1.0/js/src/Bar.js +172 -0
- chart_xkcd-0.1.0/js/src/Line.js +241 -0
- chart_xkcd-0.1.0/js/src/Pie.js +147 -0
- chart_xkcd-0.1.0/js/src/Radar.js +251 -0
- chart_xkcd-0.1.0/js/src/StackedBar.js +208 -0
- chart_xkcd-0.1.0/js/src/XY.js +251 -0
- chart_xkcd-0.1.0/js/src/components/Tooltip.js +170 -0
- chart_xkcd-0.1.0/js/src/config.js +10 -0
- chart_xkcd-0.1.0/js/src/index.js +11 -0
- chart_xkcd-0.1.0/js/src/utils/addAxis.js +50 -0
- chart_xkcd-0.1.0/js/src/utils/addFilter.js +45 -0
- chart_xkcd-0.1.0/js/src/utils/addFont.js +9 -0
- chart_xkcd-0.1.0/js/src/utils/addLabels.js +42 -0
- chart_xkcd-0.1.0/js/src/utils/addLegend.js +71 -0
- chart_xkcd-0.1.0/js/src/utils/colors.js +3 -0
- chart_xkcd-0.1.0/pyproject.toml +53 -0
- chart_xkcd-0.1.0/src/chart_xkcd/__init__.py +10 -0
- chart_xkcd-0.1.0/src/chart_xkcd/bar.py +44 -0
- chart_xkcd-0.1.0/src/chart_xkcd/charts.py +54 -0
- chart_xkcd-0.1.0/src/chart_xkcd/config.py +10 -0
- chart_xkcd-0.1.0/src/chart_xkcd/line.py +47 -0
- chart_xkcd-0.1.0/src/chart_xkcd/main.py +27 -0
- chart_xkcd-0.1.0/src/chart_xkcd/pie.py +39 -0
- chart_xkcd-0.1.0/src/chart_xkcd/radar.py +46 -0
- chart_xkcd-0.1.0/src/chart_xkcd/renderer.py +64 -0
- chart_xkcd-0.1.0/src/chart_xkcd/scatter.py +64 -0
- chart_xkcd-0.1.0/src/chart_xkcd/stacked_bar.py +49 -0
- chart_xkcd-0.1.0/src/chart_xkcd/static/chart.xkcd.min.js +5921 -0
- chart_xkcd-0.1.0/uv.lock +576 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# JS
|
|
2
|
+
.cache
|
|
3
|
+
node_modules
|
|
4
|
+
js/dist/
|
|
5
|
+
|
|
6
|
+
# Python
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
dist/
|
|
10
|
+
.venv/
|
|
11
|
+
|
|
12
|
+
# Built JS bundled into Python package
|
|
13
|
+
src/chart_xkcd/static/chart.xkcd.min.js
|
|
14
|
+
|
|
15
|
+
# Python-generated HTML files
|
|
16
|
+
examples/*.html
|
|
17
|
+
|
|
18
|
+
# Miscellaneous
|
|
19
|
+
*~
|
|
20
|
+
.DS_Store
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
4
|
+
contributors and maintainers pledge to making participation in our project and
|
|
5
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
6
|
+
size, disability, ethnicity, gender identity and expression, level of
|
|
7
|
+
experience, education, socioeconomic status, nationality, personal appearance,
|
|
8
|
+
race, religion, or sexual identity and orientation.
|
|
9
|
+
|
|
10
|
+
## Our Standards
|
|
11
|
+
|
|
12
|
+
Examples of behavior that contributes to creating a positive environment
|
|
13
|
+
include:
|
|
14
|
+
|
|
15
|
+
* using welcoming and inclusive language,
|
|
16
|
+
* being respectful of differing viewpoints and experiences,
|
|
17
|
+
* gracefully accepting constructive criticism,
|
|
18
|
+
* focusing on what is best for the community, and
|
|
19
|
+
* showing empathy towards other community members.
|
|
20
|
+
|
|
21
|
+
Examples of unacceptable behavior by participants include:
|
|
22
|
+
|
|
23
|
+
* the use of sexualized language or imagery and unwelcome sexual
|
|
24
|
+
attention or advances,
|
|
25
|
+
* trolling, insulting/derogatory comments, and personal or political
|
|
26
|
+
attacks,
|
|
27
|
+
* public or private harassment,
|
|
28
|
+
* publishing others' private information, such as a physical or
|
|
29
|
+
electronic address, without explicit permission, and
|
|
30
|
+
* other conduct which could reasonably be considered inappropriate in
|
|
31
|
+
a professional setting
|
|
32
|
+
|
|
33
|
+
## Our Responsibilities
|
|
34
|
+
|
|
35
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
36
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
37
|
+
response to any instances of unacceptable behavior.
|
|
38
|
+
|
|
39
|
+
Project maintainers have the right and responsibility to remove, edit, or reject
|
|
40
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
41
|
+
not aligned to this Code of Conduct, or to ban temporarily or permanently any
|
|
42
|
+
contributor for other behaviors that they deem inappropriate, threatening,
|
|
43
|
+
offensive, or harmful.
|
|
44
|
+
|
|
45
|
+
## Scope
|
|
46
|
+
|
|
47
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
48
|
+
when an individual is representing the project or its community. Examples of
|
|
49
|
+
representing a project or community include using an official project email
|
|
50
|
+
address, posting via an official social media account, or acting as an appointed
|
|
51
|
+
representative at an online or offline event. Representation of a project may be
|
|
52
|
+
further defined and clarified by project maintainers.
|
|
53
|
+
|
|
54
|
+
## Enforcement
|
|
55
|
+
|
|
56
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
57
|
+
reported by emailing the project team. All complaints will be reviewed
|
|
58
|
+
and investigated and will result in a response that is deemed necessary and
|
|
59
|
+
appropriate to the circumstances. The project team is obligated to maintain
|
|
60
|
+
confidentiality with regard to the reporter of an incident. Further details of
|
|
61
|
+
specific enforcement policies may be posted separately.
|
|
62
|
+
|
|
63
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
64
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
65
|
+
members of the project's leadership.
|
|
66
|
+
|
|
67
|
+
## Attribution
|
|
68
|
+
|
|
69
|
+
This Code of Conduct is adapted from
|
|
70
|
+
the [Contributor Covenant](https://www.contributor-covenant.org/) version 1.4.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
> drafting
|
|
2
|
+
|
|
3
|
+
# Contributing
|
|
4
|
+
|
|
5
|
+
Before contributing to chart.xkcd you'll need to:
|
|
6
|
+
|
|
7
|
+
- install npm
|
|
8
|
+
- install uv
|
|
9
|
+
- create a Python virtual environment
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# install dependencies
|
|
15
|
+
npm i
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# start examples (example/npm)
|
|
20
|
+
npm start
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Then you can open `localhost:1234` to see the examples, and you can start to edit the code. Thanks to [parcel](), the website will be auto updated when you make changes.
|
|
24
|
+
|
|
25
|
+
## Layout
|
|
26
|
+
|
|
27
|
+
- [docs](./docs): Documentation used to generate timqian.com/chart.xkcd
|
|
28
|
+
- [examples](./examples): Examples showing how to use chart.xkcd. The npm example is also used for developing and debug features for now.
|
|
29
|
+
- [js](./js): JavaScript source
|
|
30
|
+
- [py](./py): Python source
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) egoist <0x142857@gmail.com> (https://github.com/egoist)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Introduction
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<!-- Chart.xkcd is an xkcd styled chart library. Not like most chart libs out there do precise plots. The rough, seemingly hand drawn nature of the graph provides a visual hint as to the imprecision of the results. It is useful in some cases.
|
|
6
|
+
|
|
7
|
+
When precise numbers
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
We already have lots of great chart libraries like [chart.js](), [echart](), [chartist-js](https://github.com/gionkunz/chartist-js) etc. One of the problems I've had with them is that everything they draw is so precise and perfect. Sometimes I want the plots looks less precise to d -->
|
|
11
|
+
|
|
12
|
+
Chart.xkcd is a chart library plots "sketchy", "cartoony" or "hand-drawn" styled charts.
|
|
13
|
+
|
|
14
|
+
[](https://patreon.com/timqian)
|
|
15
|
+
[](https://join.slack.com/t/t9tio/shared_invite/enQtNjgzMzkwMDM0NTE3LTE5ZTUzYjU4Y2I0YzRiZjNkYTkzMzE1ZmM0NDdmYzRlZmMxNGY1MzZlN2EwYjYyNWVlMWY0Nzk2MDBhNWZlY2I)
|
|
16
|
+
[](https://github.com/timqian/chart.xkcd)
|
|
17
|
+
[](https://www.npmjs.com/package/chart.xkcd)
|
|
18
|
+
[](https://www.jsdelivr.com/package/npm/chart.xkcd)
|
|
19
|
+
|
|
20
|
+
## Sponsors
|
|
21
|
+
|
|
22
|
+
[Madao](https://madao.me/) | [Become a sponsor](https://www.patreon.com/timqian)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Getting started
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
It's easy to get started with chart.xkcd. All that's required is the script included in your page along with a single `<svg>` node to render the chart.
|
|
6
|
+
|
|
7
|
+
In the following example we create a line chart.
|
|
8
|
+
|
|
9
|
+
<p class="codepen" data-height="424" data-theme-id="light" data-default-tab="result" data-user="timqian" data-slug-hash="GRKqLaL" style="height: 424px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="chart.xkcd example">
|
|
10
|
+
<span>See the Pen <a href="https://codepen.io/timqian/pen/GRKqLaL/">
|
|
11
|
+
chart.xkcd example</a> by timqian (<a href="https://codepen.io/timqian">@timqian</a>)
|
|
12
|
+
on <a href="https://codepen.io">CodePen</a>.</span>
|
|
13
|
+
</p>
|
|
14
|
+
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
|
|
15
|
+
|
|
16
|
+
**JS part of the example**
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
const svg = document.querySelector('.line-chart')
|
|
20
|
+
new chartXkcd.Line(svg, {
|
|
21
|
+
title: '',
|
|
22
|
+
xLabel: '',
|
|
23
|
+
yLabel: '',
|
|
24
|
+
data: {...},
|
|
25
|
+
options: {},
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Parameters description
|
|
30
|
+
|
|
31
|
+
- `title`: optional title of the chart
|
|
32
|
+
- `xLabel`: optional x label of the chart
|
|
33
|
+
- `yLabel`: optional y label of the chart
|
|
34
|
+
- `data`: the data you want to visulize
|
|
35
|
+
- `options`: optional configurations to customize how the chart looks
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Installation
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
You can install chart.xkcd via script tag in HTML or via npm
|
|
6
|
+
|
|
7
|
+
## Via Script Tag
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
<script src="https://cdn.jsdelivr.net/npm/chart.xkcd@1.1/dist/chart.xkcd.min.js" integrity="sha256-NkH6G4XRcQ5Bsfs7O6yh9mw1SJLEOJWCtWqko6VjF34=" crossorigin="anonymous"></script>
|
|
11
|
+
<script>
|
|
12
|
+
const myChart = new chartXkcd.Line(svg, {...});
|
|
13
|
+
</script>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Via npm
|
|
17
|
+
|
|
18
|
+
**Install**
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm i chart.xkcd
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Usage**
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import chartXkcd from 'chart.xkcd';
|
|
28
|
+
const myChart = new chartXkcd.Line(svg, {...});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Other ways**
|
|
32
|
+
|
|
33
|
+
- React wrapper: [chart.xkcd-react](https://github.com/obiwankenoobi/chart.xkcd-react) <br/>
|
|
34
|
+
- Vue wrapper:
|
|
35
|
+
- [chart.xkcd-vue](https://github.com/shiyiya/chart.xkcd-vue)
|
|
36
|
+
- [chart.xkcd-vue-wrapper](https://github.com/wistcc/chart.xkcd-vue-wrapper)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Line chart
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Line chart displays series of data points in the form of lines. It can be used to show trend data, or comparison of different data sets.
|
|
6
|
+
|
|
7
|
+
<p class="codepen" data-height="424" data-theme-id="light" data-default-tab="result" data-user="timqian" data-slug-hash="GRKqLaL" style="height: 424px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="chart.xkcd example">
|
|
8
|
+
<span>See the Pen <a href="https://codepen.io/timqian/pen/GRKqLaL/">
|
|
9
|
+
chart.xkcd example</a> by timqian (<a href="https://codepen.io/timqian">@timqian</a>)
|
|
10
|
+
on <a href="https://codepen.io">CodePen</a>.</span>
|
|
11
|
+
</p>
|
|
12
|
+
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
|
|
13
|
+
|
|
14
|
+
## JS part
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
const lineChart = new chartXkcd.Line(svg, {
|
|
18
|
+
title: 'Monthly income of an indie developer', // optional
|
|
19
|
+
xLabel: 'Month', // optional
|
|
20
|
+
yLabel: '$ Dollars', // optional
|
|
21
|
+
data: {
|
|
22
|
+
labels: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
|
|
23
|
+
datasets: [{
|
|
24
|
+
label: 'Plan',
|
|
25
|
+
data: [30, 70, 200, 300, 500, 800, 1500, 2900, 5000, 8000],
|
|
26
|
+
}, {
|
|
27
|
+
label: 'Reality',
|
|
28
|
+
data: [0, 1, 30, 70, 80, 100, 50, 80, 40, 150],
|
|
29
|
+
}],
|
|
30
|
+
},
|
|
31
|
+
options: { // optional
|
|
32
|
+
yTickCount: 3,
|
|
33
|
+
legendPosition: chartXkcd.config.positionType.upLeft
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Customize chart by defining options
|
|
39
|
+
|
|
40
|
+
- `yTickCount`: customize tick numbers you want to see on the y axis (default `3`)
|
|
41
|
+
- `showLegend`: display legend near chart (default `true`)
|
|
42
|
+
- `legendPosition`: specify where you want to place the legend. (default `chartXkcd.config.positionType.upLeft`)
|
|
43
|
+
Possible values:
|
|
44
|
+
- up left: `chartXkcd.config.positionType.upLeft`
|
|
45
|
+
- up right: `chartXkcd.config.positionType.upRight`
|
|
46
|
+
- bottom left: `chartXkcd.config.positionType.downLeft`
|
|
47
|
+
- bottom right: `chartXkcd.config.positionType.downRight`
|
|
48
|
+
- `dataColors`: array of colors for different datasets
|
|
49
|
+
- `fontFamily`: customize font family used in the chart
|
|
50
|
+
- `unxkcdify`: disable xkcd effect (default `false`)
|
|
51
|
+
- `strokeColor`: stroke colors (default `black`)
|
|
52
|
+
- `backgroundColor`: color for BG (default `white`)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: XY chart
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
XY chart is used to plot points by specifying their XY coordinates.
|
|
6
|
+
|
|
7
|
+
You can also plot XY line chart by connecting the points.
|
|
8
|
+
|
|
9
|
+
<p class="codepen" data-height="445" data-theme-id="light" data-default-tab="result" data-user="timqian" data-slug-hash="ExYZvZY" style="height: 445px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="chart.xkcd XY">
|
|
10
|
+
<span>See the Pen <a href="https://codepen.io/timqian/pen/ExYZvZY/">
|
|
11
|
+
chart.xkcd XY</a> by timqian (<a href="https://codepen.io/timqian">@timqian</a>)
|
|
12
|
+
on <a href="https://codepen.io">CodePen</a>.</span>
|
|
13
|
+
</p>
|
|
14
|
+
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
|
|
15
|
+
|
|
16
|
+
## JS part
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
const svg = document.querySelector('.xy-chart');
|
|
20
|
+
|
|
21
|
+
new chartXkcd.XY(svg, {
|
|
22
|
+
title: 'Pokemon farms', //optional
|
|
23
|
+
xLabel: 'Coordinate', //optional
|
|
24
|
+
yLabel: 'Count', //optional
|
|
25
|
+
data: {
|
|
26
|
+
datasets: [{
|
|
27
|
+
label: 'Pikachu',
|
|
28
|
+
data: [{ x: 3, y: 10 }, { x: 4, y: 122 }, { x: 10, y: 100 }, { x: 1, y: 2 }, { x: 2, y: 4 }],
|
|
29
|
+
}, {
|
|
30
|
+
label: 'Squirtle',
|
|
31
|
+
data: [{ x: 3, y: 122 }, { x: 4, y: 212 }, { x: -3, y: 100 }, { x: 1, y: 1 }, { x: 1.5, y: 12 }],
|
|
32
|
+
}],
|
|
33
|
+
},
|
|
34
|
+
options: { //optional
|
|
35
|
+
xTickCount: 5,
|
|
36
|
+
yTickCount: 5,
|
|
37
|
+
legendPosition: chartXkcd.config.positionType.upRight,
|
|
38
|
+
showLine: false,
|
|
39
|
+
timeFormat: undefined,
|
|
40
|
+
dotSize: 1,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Customize XY chart by defining options
|
|
46
|
+
|
|
47
|
+
- `xTickCount`: customize tick numbers you want to see on the x axis (default `3`)
|
|
48
|
+
- `yTickCount`: customize tick numbers you want to see on the y axis (default `3`)
|
|
49
|
+
- `showLegend`: display legend near chart (default `true`)
|
|
50
|
+
- `legendPosition`: specify where you want to place the legend (default `chartXkcd.config.positionType.upLeft`)
|
|
51
|
+
Possible values:
|
|
52
|
+
- up left: `chartXkcd.config.positionType.upLeft`
|
|
53
|
+
- up right: `chartXkcd.config.positionType.upLeft`
|
|
54
|
+
- bottom left: `chartXkcd.config.positionType.downLeft`
|
|
55
|
+
- bottom right: `chartXkcd.config.positionType.downRight`
|
|
56
|
+
- `showLine`: connect the points with lines (default: `false`)
|
|
57
|
+
- `timeFormat`: specify the time format if the x values are time (default `undefined`)
|
|
58
|
+
chart.xkcd use [dayjs](https://github.com/iamkun/dayjs) to format time, you can find the all the available formats [here](https://github.com/iamkun/dayjs/blob/dev/docs/en/API-reference.md#list-of-all-available-formats)
|
|
59
|
+
- `dotSize`: you can change size of the dots if you want (default `1`)
|
|
60
|
+
- `dataColors`: array of colors for different datasets
|
|
61
|
+
- `fontFamily`: customize font family used in the chart
|
|
62
|
+
- `unxkcdify`: disable xkcd effect (default `false`)
|
|
63
|
+
- `strokeColor`: stroke colors (default `black`)
|
|
64
|
+
- `backgroundColor`: color for BG (default `white`)
|
|
65
|
+
|
|
66
|
+
**Another example of XY chart: XY line chart with `timeFormat`**
|
|
67
|
+
|
|
68
|
+
<p class="codepen" data-height="472" data-theme-id="light" data-default-tab="result" data-user="timqian" data-slug-hash="ZEzLJaN" style="height: 472px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="chart.xkcd XY line">
|
|
69
|
+
<span>See the Pen <a href="https://codepen.io/timqian/pen/ZEzLJaN/">
|
|
70
|
+
chart.xkcd XY line</a> by timqian (<a href="https://codepen.io/timqian">@timqian</a>)
|
|
71
|
+
on <a href="https://codepen.io">CodePen</a>.</span>
|
|
72
|
+
</p>
|
|
73
|
+
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Bar chart
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
A bar chart provides a way of showing data values represented as vertical bars
|
|
6
|
+
|
|
7
|
+
<p class="codepen" data-height="509" data-theme-id="light" data-default-tab="result" data-user="timqian" data-slug-hash="QWLERdG" style="height: 509px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="chart.xkcd bar">
|
|
8
|
+
<span>See the Pen <a href="https://codepen.io/timqian/pen/QWLERdG/">
|
|
9
|
+
chart.xkcd bar</a> by timqian (<a href="https://codepen.io/timqian">@timqian</a>)
|
|
10
|
+
on <a href="https://codepen.io">CodePen</a>.</span>
|
|
11
|
+
</p>
|
|
12
|
+
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
|
|
13
|
+
|
|
14
|
+
## JS part
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
const barChart = new chartXkcd.Bar(svg, {
|
|
18
|
+
title: 'github stars VS patron number', // optional
|
|
19
|
+
// xLabel: '', // optional
|
|
20
|
+
// yLabel: '', // optional
|
|
21
|
+
data: {
|
|
22
|
+
labels: ['github stars', 'patrons'],
|
|
23
|
+
datasets: [{
|
|
24
|
+
data: [100, 2],
|
|
25
|
+
}],
|
|
26
|
+
},
|
|
27
|
+
options: { // optional
|
|
28
|
+
yTickCount: 2,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Customize chart by defining options
|
|
34
|
+
|
|
35
|
+
- `yTickCount`: customize tick numbers you want to see on the y axis
|
|
36
|
+
- `dataColors`: array of colors for different datasets
|
|
37
|
+
- `fontFamily`: customize font family used in the chart
|
|
38
|
+
- `unxkcdify`: disable xkcd effect (default `false`)
|
|
39
|
+
- `strokeColor`: stroke colors (default `black`)
|
|
40
|
+
- `backgroundColor`: color for BG (default `white`)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Stacked bar chart
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
A stacked bar chart provides a way of showing data values represented as vertical bars
|
|
6
|
+
|
|
7
|
+
<p class="codepen" data-height="429" data-theme-id="default" data-default-tab="result" data-user="timqian" data-slug-hash="KKwPrEm" style="height: 429px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="chart.xkcd stacked bar">
|
|
8
|
+
<span>See the Pen <a href="https://codepen.io/timqian/pen/KKwPrEm">
|
|
9
|
+
chart.xkcd stacked bar</a> by timqian (<a href="https://codepen.io/timqian">@timqian</a>)
|
|
10
|
+
on <a href="https://codepen.io">CodePen</a>.</span>
|
|
11
|
+
</p>
|
|
12
|
+
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
|
|
13
|
+
|
|
14
|
+
## JS part
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
new chartXkcd.StackedBar(svg, {
|
|
18
|
+
title: 'Issues and PR Submissions',
|
|
19
|
+
xLabel: 'Month',
|
|
20
|
+
yLabel: 'Count',
|
|
21
|
+
data: {
|
|
22
|
+
labels: ['Jan', 'Feb', 'Mar', 'April', 'May'],
|
|
23
|
+
datasets: [{
|
|
24
|
+
label: 'Issues',
|
|
25
|
+
data: [12, 19, 11, 29, 17],
|
|
26
|
+
}, {
|
|
27
|
+
label: 'PRs',
|
|
28
|
+
data: [3, 5, 2, 4, 1],
|
|
29
|
+
}, {
|
|
30
|
+
label: 'Merges',
|
|
31
|
+
data: [2, 3, 0, 1, 1],
|
|
32
|
+
}],
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Customize chart by defining options
|
|
38
|
+
|
|
39
|
+
- `yTickCount`: customize tick numbers you want to see on the y axis
|
|
40
|
+
- `dataColors`: array of colors for different datasets
|
|
41
|
+
- `fontFamily`: customize font family used in the chart
|
|
42
|
+
- `unxkcdify`: disable xkcd effect (default `false`)
|
|
43
|
+
- `strokeColor`: stroke colors (default `black`)
|
|
44
|
+
- `backgroundColor`: color for BG (default `white`)
|
|
45
|
+
- `showLegend`: display legend near chart (default `true`)
|
|
46
|
+
- `legendPosition`: specify where you want to place the legend (default `chartXkcd.config.positionType.upLeft`)
|
|
47
|
+
Possible values:
|
|
48
|
+
- up left: `chartXkcd.config.positionType.upLeft`
|
|
49
|
+
- up right: `chartXkcd.config.positionType.upLeft`
|
|
50
|
+
- bottom left: `chartXkcd.config.positionType.downLeft`
|
|
51
|
+
- bottom right: `chartXkcd.config.positionType.downRight`
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Pie/Doughnut chart
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<p class="codepen" data-height="470" data-theme-id="light" data-default-tab="result" data-user="timqian" data-slug-hash="VwZjOPR" style="height: 470px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="chart.xkcd pie">
|
|
6
|
+
<span>See the Pen <a href="https://codepen.io/timqian/pen/VwZjOPR/">
|
|
7
|
+
chart.xkcd pie</a> by timqian (<a href="https://codepen.io/timqian">@timqian</a>)
|
|
8
|
+
on <a href="https://codepen.io">CodePen</a>.</span>
|
|
9
|
+
</p>
|
|
10
|
+
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
|
|
11
|
+
|
|
12
|
+
## JS part
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
const pieChart = new chartXkcd.Pie(svg, {
|
|
16
|
+
title: 'What Tim is made of', // optional
|
|
17
|
+
data: {
|
|
18
|
+
labels: ['a', 'b', 'e', 'f', 'g'],
|
|
19
|
+
datasets: [{
|
|
20
|
+
data: [500, 200, 80, 90, 100],
|
|
21
|
+
}],
|
|
22
|
+
},
|
|
23
|
+
options: { // optional
|
|
24
|
+
innerRadius: 0.5,
|
|
25
|
+
legendPosition: chartXkcd.config.positionType.upRight,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Customize chart by defining options
|
|
31
|
+
|
|
32
|
+
- `innerRadius`: specify empty pie chart radius (default: `0.5`)
|
|
33
|
+
- Want a pie chart? set `innerRadius` to `0`
|
|
34
|
+
- `showLegend`: display legend near chart (default `true`)
|
|
35
|
+
- `legendPosition`: specify where you want to place the legend. (default `chartXkcd.config.positionType.upLeft`)
|
|
36
|
+
Possible values:
|
|
37
|
+
- up left: `chartXkcd.config.positionType.upLeft`
|
|
38
|
+
- up right: `chartXkcd.config.positionType.upLeft`
|
|
39
|
+
- bottom left: `chartXkcd.config.positionType.downLeft`
|
|
40
|
+
- bottom right: `chartXkcd.config.positionType.downRight`
|
|
41
|
+
- `dataColors`: array of colors for different datasets
|
|
42
|
+
- `fontFamily`: customize font family used in the chart
|
|
43
|
+
- `unxkcdify`: disable xkcd effect (default `false`)
|
|
44
|
+
- `strokeColor`: stroke colors (default `black`)
|
|
45
|
+
- `backgroundColor`: color for BG (default `white`)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Radar chart
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<p class="codepen" data-height="434" data-theme-id="light" data-default-tab="result" data-user="timqian" data-slug-hash="VwZQBoj" style="height: 434px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="chart.xkcd radar">
|
|
6
|
+
<span>See the Pen <a href="https://codepen.io/timqian/pen/VwZQBoj/">
|
|
7
|
+
chart.xkcd radar</a> by timqian (<a href="https://codepen.io/timqian">@timqian</a>)
|
|
8
|
+
on <a href="https://codepen.io">CodePen</a>.</span>
|
|
9
|
+
</p>
|
|
10
|
+
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
|
|
11
|
+
|
|
12
|
+
## JS part
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
const radar = new chartXkcd.Radar(svg, {
|
|
16
|
+
title: 'Letters in random words', // optional
|
|
17
|
+
data: {
|
|
18
|
+
labels: ['c', 'h', 'a', 'r', 't'],
|
|
19
|
+
datasets: [{
|
|
20
|
+
label: 'ccharrrt', // optional
|
|
21
|
+
data: [2, 1, 1, 3, 1],
|
|
22
|
+
}, {
|
|
23
|
+
label: 'chhaart', // optional
|
|
24
|
+
data: [1, 2, 2, 1, 1],
|
|
25
|
+
}],
|
|
26
|
+
},
|
|
27
|
+
options: { // optional
|
|
28
|
+
showLegend: true,
|
|
29
|
+
dotSize: .8,
|
|
30
|
+
showLabels: true,
|
|
31
|
+
legendPosition: chartXkcd.config.positionType.upRight,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Customize chart by defining options
|
|
37
|
+
|
|
38
|
+
- `showLabels`: display labels near every line (default `false`)
|
|
39
|
+
- `ticksCount`: customize tick numbers you want to see on the main line (default `3`)
|
|
40
|
+
- `dotSize`: you can change size of the dots if you want (default `1`)
|
|
41
|
+
- `showLegend`: display legend near chart (default `false`)
|
|
42
|
+
- `legendPosition`: specify where you want to place the legend. (default `chartXkcd.config.positionType.upLeft`)
|
|
43
|
+
Possible values:
|
|
44
|
+
- up left: `chartXkcd.config.positionType.upLeft`
|
|
45
|
+
- up right: `chartXkcd.config.positionType.upRight`
|
|
46
|
+
- bottom left: `chartXkcd.config.positionType.downLeft`
|
|
47
|
+
- bottom right: `chartXkcd.config.positionType.downRight`
|
|
48
|
+
- `dataColors`: array of colors for different datasets
|
|
49
|
+
- `fontFamily`: customize font family used in the chart
|
|
50
|
+
- `unxkcdify`: disable xkcd effect (default `false`)
|
|
51
|
+
- `strokeColor`: stroke colors (default `black`)
|
|
52
|
+
- `backgroundColor`: color for BG (default `white`)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Example: Bar chart."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from chart_xkcd import Bar, render
|
|
5
|
+
|
|
6
|
+
chart = Bar(
|
|
7
|
+
title="Github Stars vs Patron Count",
|
|
8
|
+
x_label="Project",
|
|
9
|
+
y_label="Count",
|
|
10
|
+
labels=["chart.xkcd", "star-history", "tomato-pie"],
|
|
11
|
+
datasets=[{"data": [2100, 430, 90]}],
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
render(chart, sys.argv[1], chart_js_url="/src/chart_xkcd/static/chart.xkcd.min.js")
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Example: Line chart."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from chart_xkcd import Line, render
|
|
5
|
+
|
|
6
|
+
chart = Line(
|
|
7
|
+
title="Monthly Income of an Indie Developer",
|
|
8
|
+
x_label="Month",
|
|
9
|
+
y_label="$ Dollars",
|
|
10
|
+
labels=["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],
|
|
11
|
+
datasets=[
|
|
12
|
+
{
|
|
13
|
+
"label": "Plan",
|
|
14
|
+
"data": [30, 70, 200, 300, 500, 800, 1500, 2900, 5000, 8000],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"label": "Reality",
|
|
18
|
+
"data": [0, 1, 30, 70, 80, 100, 50, 80, 40, 150],
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
render(chart, sys.argv[1], chart_js_url="/src/chart_xkcd/static/chart.xkcd.min.js")
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Example: Pie chart."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from chart_xkcd import Pie, positionType, render
|
|
5
|
+
|
|
6
|
+
chart = Pie(
|
|
7
|
+
title="What Tim Is Made Of",
|
|
8
|
+
labels=["Code", "Coffee", "Sleep", "Snacks"],
|
|
9
|
+
datasets=[{"data": [500, 200, 80, 90]}],
|
|
10
|
+
options={
|
|
11
|
+
"innerRadius": 0.5,
|
|
12
|
+
"legendPosition": positionType.upRight,
|
|
13
|
+
},
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
render(chart, sys.argv[1], chart_js_url="/src/chart_xkcd/static/chart.xkcd.min.js")
|