From b3b9afa38bbf5fa0bad5ed1b7a23bef4bebdd712 Mon Sep 17 00:00:00 2001 From: Shahar Hesse Date: Thu, 15 Oct 2015 18:09:29 +0300 Subject: [PATCH] Addition of donut chart type --- README.md | 2 +- readme.txt | 2 +- tablepress_chartist.php | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 88cdcd5..770d599 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/readme.txt b/readme.txt index 52c1c13..e72bfd9 100644 --- a/readme.txt +++ b/readme.txt @@ -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. diff --git a/tablepress_chartist.php b/tablepress_chartist.php index 4b06eba..e911029 100644 --- a/tablepress_chartist.php +++ b/tablepress_chartist.php @@ -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 ) + '%'; }";