Skip to content

Commit c8701c2

Browse files
committed
v0.2
### [0.2] - 2020-11-06 #### Added - Attribute `height` for the canvas object - Attribute `color={color1,color2,..n}` comma separator - Supported colors [blue,red,orange,yellow,green,purple,grey,black] - Attribute `first={n}` show only `{n}` first rows - Attribute `last={n}` show only `{n}` last rows #### Changed - Attribute `data` now accept A-Z to correspond TablePress columns - Attribute `dimension` to `label` attribute - `_maybe_string_to_number` RegExp
1 parent 0ae2f6e commit c8701c2

6 files changed

Lines changed: 276 additions & 156 deletions

File tree

README.md

Lines changed: 135 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,158 @@
11
# TablePress Extension: Chart.js
2-
Create a chart.js using the data in a TablePress table
32

3+
Create a [Chart.js](https://www.chartjs.org/) using [TablePress](https://tablepress.org/) as data source
44

5-
## About
65

7-
This plugin code and idea is a modification of [TablePress Extension: Chartist](https://github.com/soderlind/tablepress_chartist).
6+
## About
87

9-
Using [Chart.js](https://www.chartjs.org/), this [TablePress](https://tablepress.org/) Extension creates a responsive chart based on the data in a TablePress table.
8+
This plugin code base and idea is a modification of [TablePress Extension: Chartist](https://github.com/soderlind/tablepress_chartist).
109

1110

1211
## Usage
1312

14-
Add the Shortcode [tp-chartjs id=123 dimension=1 data=2,3/] to a post or page to create a chart from the TablePress table 123.
13+
Add the Shortcode `[tp-chartjs id=1 label=A data=B,C/]` to a post or page to create a chart from the TablePress ID '1' where labes are column `A`, and dataset points are columns `B` and `C`.
14+
15+
![TablePress Usage](assets/tp_usage.png)
16+
17+
Result:
18+
19+
![Chartjs Usage](assets/chart_usage.png)
20+
21+
22+
## Attributes
23+
24+
- [`id={n}`](#att_id) TablePress ID reference
25+
- [`label={c,...}`](#att_label) Column Axis label (default: A)
26+
- [`data={n,...}`](#att_data) Column(s) datasets used to populate chart (default: B)
27+
- [`chart=[line|hbar]`](#att_chart) Chart type (default: line)
28+
- [`color`](#att_color) (default: blue,red,orange,yellow,green,purple,grey,black)
29+
- [`height={n}`](#att_height) Declare height of `canvas` HTML object
30+
- [`first={n}`](#att_first) Declare that only use the first `{n}` rows of data
31+
- [`last={n}`](#att_last) Declare that only use the last `{n}` rows of data
32+
33+
34+
### `id`<a id="att_id"></a>
35+
36+
TablePress ID reference
37+
38+
* **Example:** `[tp-chartjs id=1/]`
39+
* **Value:** Integer `id`
40+
41+
42+
### `label`<a id="att_label"></a>
43+
44+
Column Axis label
45+
46+
* **Example:** `[tp-chartjs id=1 label=A data=B,C/]`
47+
* **Value:** One character from [A-Z]
48+
* **Default:** `A`
49+
50+
51+
### `data`<a id="att_data"></a>
52+
53+
Column(s) datasets used to populate chart
54+
55+
* **Example:** `[tp-chartjs id=1 label=A data=B,C,D,E/]`
56+
* **Values:** One or more comma separated columns character [A-Z]
57+
* **Default:** `B`
58+
59+
60+
### `chart`<a id="att_chart"></a>
61+
62+
Chart type used
63+
64+
* **Example:** `[tp-chartjs id=1 label=A data=B,C chart=line/]`
65+
* **Values:** Select one of this
66+
* `line`: Line
67+
* `hbar`: Vertical Bar
68+
* **Default:** `line`
1569

1670

71+
### `color`<a id="att_color"></a>
72+
73+
The colors you can use in populated lines or bars.
74+
75+
* **Example:** `[tp-chartjs id=1 label=A data=B,C color=blue,red/]`
76+
* **Values:** One or more comma separated colors
77+
* `blue`
78+
* `red`
79+
* `orange`
80+
* `yellow`
81+
* `green`
82+
* `purple`
83+
* `grey`
84+
* `black`
85+
* **Default:** `blue,red,orange,yellow,green,purple,grey,black`
86+
87+
On example column `B` draws `blue` and column `C` draws `red`
88+
89+
90+
### `height`<a id="att_height"></a>
91+
92+
Declare height of `canvas` HTML object
93+
94+
* **Example:** `[tp-chartjs id=1 label=A data=B,C height=300/]`
95+
* **Values:** Integer value transformed into pixels
96+
* **Default:** Automatic
97+
98+
### `first`<a id="att_first"></a>
99+
100+
Declare that only use the first `{n}` rows of data
101+
102+
* **Example:** `[tp-chartjs id=1 label=A data=B,C first=10/]`
103+
* **Value:** Integer value offset
104+
* **Default:** All data
105+
106+
107+
### `last`<a id="att_last"></a>
108+
109+
Declare that only use the last `{n}` rows of data
110+
111+
* **Example:** `[tp-chartjs id=1 label=A data=B,C last=10/]`
112+
* **Values:** Integer value offset
113+
* **Default:** All data
114+
17115

18116
## Install
19117

118+
Prerequisite: The [TablePress](https://tablepress.org/) plugin
119+
120+
121+
## Donate to Developer
122+
123+
If you like my work, please donate to help me.
20124

21-
## Donations
125+
[![Donate to Developer](assets/button-donate.png)](https://www.paypal.com/donate?hosted_button_id=ZXY9DM6PTWB8C)
22126

23-
[Buy me a Coffee](https://www.paypal.com/paypalme/developarts)
127+
128+
## To Do
129+
130+
- [ ] Chart Title
131+
- [ ] Vertical Bar chart support
132+
- [ ] Pie chart support
133+
- [ ] Time Series chart support
134+
- [ ] Stacked chart support
24135

25136

26137
## Changelog
27138

28-
* 0.1 Initial release
139+
### [0.2] - 2020-11-06
140+
141+
#### Added
142+
- Attribute `height` for the canvas object
143+
- Attribute `color={color1,color2,..n}` comma separator
144+
- Supported colors [blue,red,orange,yellow,green,purple,grey,black]
145+
- Attribute `first={n}` show only `{n}` first rows
146+
- Attribute `last={n}` show only `{n}` last rows
147+
148+
#### Changed
149+
- Attribute `data` now accept A-Z to correspond TablePress columns
150+
- Attribute `dimension` to `label` attribute
151+
- `_maybe_string_to_number` RegExp
152+
153+
154+
### [0.1] - 2020-11-01
155+
- Initial release
29156

30157

31158
## Credits

assets/button-donate.png

10.6 KB
Loading

assets/chart_usage.png

75.2 KB
Loading

assets/tp_id.png

13.3 KB
Loading

assets/tp_usage.png

79.4 KB
Loading

0 commit comments

Comments
 (0)