Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Add the Shortcode `[table-chart id=123 /]` to a post or page to create a chart f
* Enable/disable smooth line: `linesmooth=true` (default: true)
* Enable/disable line points: `showpoint=true` (default: true)
* Set chart aspect ratio: `aspect_ratio=3:4` (default: 3:4) Alternatives: 1, 15:16, 8:9, 5:6, 4:5, 3:4, 2:3, 5:8, 1:1.618, 3:5, 9:16, 8:15, 1:2, 2:5, 3:8, 1:3, or 1:4
* Select chart type: `chart=bar` (default: line) Alternatives: line, bar, pie, or percent.
* Select chart type: `chart=bar` (default: line) Alternatives: line, bar, pie, donut or percent.

If the "Table Head Row" option is enabled for the table, the Extension will use the head row data for the chart labels.
The other rows will be shown as lines or bars. Pie or percent charts will only use the first data row. Percent charts will ignore the header row.
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Optional parameters:
* Enable/disable smooth line: `linesmooth=true` (default: true)
* Enable/disable line points: `showpoint=true` (default: true)
* Set chart aspect ratio: `aspect_ratio=3:4` (default: 3:4) Alternatives: 1, 15:16, 8:9, 5:6, 4:5, 3:4, 2:3, 5:8, 1:1.618, 3:5, 9:16, 8:15, 1:2, 2:5, 3:8, 1:3, or 1:4
* Select chart type: `chart=bar` (default: line) Alternatives: line, bar, pie, or percent.
* Select chart type: `chart=bar` (default: line) Alternatives: line, bar, pie, donut or percent.

If the "Table Head Row" option is enabled for the table, the Extension will use the head row data for the chart labels.
The other rows will be shown as lines or bars. Pie or percent charts will only use the first data row. Percent charts will ignore the header row.
Expand Down
5 changes: 5 additions & 0 deletions tablepress_chartist.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ public static function generate_chart( $output, $table, $render_options ) {
$chart = 'Pie';
$json_chart_options[] = 'labelInterpolationFnc: function( value ) { return value[0]; }';
break;
case 'donut':
$chart = 'Pie';
$json_chart_options[] = 'labelInterpolationFnc: function( value ) { return value[0]; }';
$json_chart_options[] = 'donut: true';
break;
case 'percent':
$chart = 'Pie';
$json_chart_options[] = "labelInterpolationFnc: function( value ) { return Math.round( value / data.series.reduce( sum ) * 100 ) + '%'; }";
Expand Down