From 32b87abdedbf3f7066cc8093c93bdfdb52b5ff8c Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 12 Jun 2019 16:22:07 -0500 Subject: [PATCH] replace simple highcharts charts with chartkick --- .../analysis/sections/_readability.html.erb | 121 ++++-------------- 1 file changed, 25 insertions(+), 96 deletions(-) diff --git a/app/views/documents/analysis/sections/_readability.html.erb b/app/views/documents/analysis/sections/_readability.html.erb index 58f88c4e..f2819a68 100644 --- a/app/views/documents/analysis/sections/_readability.html.erb +++ b/app/views/documents/analysis/sections/_readability.html.erb @@ -199,7 +199,7 @@
N-syllable words
-
+ <%= column_chart analysis.n_syllable_words.map { |k, v| [k, v] } %>
@@ -208,7 +208,13 @@
Word variety
-
+

Number of words used...

+ <%= + pie_chart({ + 'exactly once' => analysis.words_used_once_count, + 'multiple times' => analysis.words_used_repeatedly_count + }) + %>
- explanation + + Why is this important? + close +
@@ -225,7 +234,15 @@
Word complexity
-
+

+ Number of unique... +

+ <%= + pie_chart({ + 'simple words' => analysis.simple_words_count, + 'complex words' => analysis.complex_words_count + }) + %>
- explanation + + Why is this important? + close +
@@ -257,96 +277,5 @@ $(document).ready(function () { e.stopPropagation(); return false; }); - - var n_syllables_per_words_chart = Highcharts.chart('graph-n-syllable-words', { - chart: { - type: 'column', - }, - title: { - text: '' - }, - xAxis: { - title: { - text: 'Syllables' - }, - tickInterval: 1, - plotBands: [{ - color: 'lightgreen', - from: 0, - to: 2.5, - label: { - text: 'Simple words' - } - }, { - color: 'lightyellow', - from: 2.5, - to: 20, - label: { - text: 'Complex words' - } - }] - }, - yAxis: { - title: { - text: 'Words' - } - }, - series: [{ - name: 'Words', - data: <%= analysis.n_syllable_words.map { |k, v| [k, v] } %> - }], - tooltip: { - formatter: function() { - return 'This document contains ' + this.y + ' ' + this.x + '-syllable word' + (this.y == 1 ? '' : 's') + '.'; - } - }, - legend: { - enabled: false - } - }); - - var word_variety_chart = Highcharts.chart('graph-word-variety', { - chart: { - type: 'pie' - }, - title: { - text: 'Number of words used...' - }, - series: [{ - name: 'Words', - colorByPoint: true, - data: [{ - name: 'exactly once', - y: <%= analysis.words_used_once_count %>, - sliced: true, - selected: true - }, { - name: 'multiple times', - y: <%= analysis.words_used_repeatedly_count %> - }] - }] - }); - - var word_complexity_chart = Highcharts.chart('graph-word-complexity', { - chart: { - type: 'pie' - }, - title: { - text: 'Number of...' - }, - series: [{ - name: 'Words', - colorByPoint: true, - data: [{ - name: 'simple words', - y: <%= analysis.simple_words_count %>, - sliced: true, - selected: true - }, { - name: 'complex words', - y: <%= analysis.complex_words_count %> - }] - }] - }); });