apexcharts 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +89 -33
  3. data/lib/apex_charts/charts.rb +1 -0
  4. data/lib/apex_charts/charts/box_plot_chart.rb +8 -0
  5. data/lib/apex_charts/config/schema.rb +20 -0
  6. data/lib/apex_charts/configuration.rb +2 -0
  7. data/lib/apex_charts/helper.rb +9 -11
  8. data/lib/apex_charts/options/default/annotations_options.rb +14 -0
  9. data/lib/apex_charts/options/default/chart_options.rb +33 -0
  10. data/lib/apex_charts/options/default/data_labels_options.rb +18 -0
  11. data/lib/apex_charts/options/default/fill_options.rb +14 -0
  12. data/lib/apex_charts/options/default/grid_options.rb +17 -0
  13. data/lib/apex_charts/options/default/helper_options.rb +22 -0
  14. data/lib/apex_charts/options/default/legend_options.rb +33 -0
  15. data/lib/apex_charts/options/default/markers_options.rb +26 -0
  16. data/lib/apex_charts/options/default/no_data_options.rb +14 -0
  17. data/lib/apex_charts/options/default/plot_options.rb +19 -0
  18. data/lib/apex_charts/options/default/root_options.rb +38 -0
  19. data/lib/apex_charts/options/default/states_options.rb +11 -0
  20. data/lib/apex_charts/options/default/stroke_options.rb +14 -0
  21. data/lib/apex_charts/options/default/theme_options.rb +11 -0
  22. data/lib/apex_charts/options/default/title_subtitle_options.rb +15 -0
  23. data/lib/apex_charts/options/default/tooltip_options.rb +25 -0
  24. data/lib/apex_charts/options/default/x_axis_options.rb +27 -0
  25. data/lib/apex_charts/options/default/y_axis_options.rb +28 -0
  26. data/lib/apex_charts/options/dry_schema/annotations_options.rb +22 -0
  27. data/lib/apex_charts/options/dry_schema/annotations_options/annotation_label.rb +24 -0
  28. data/lib/apex_charts/options/dry_schema/annotations_options/image_annotations.rb +15 -0
  29. data/lib/apex_charts/options/dry_schema/annotations_options/point_annotations.rb +33 -0
  30. data/lib/apex_charts/options/dry_schema/annotations_options/text_annotations.rb +26 -0
  31. data/lib/apex_charts/options/dry_schema/annotations_options/x_axis_annotations.rb +20 -0
  32. data/lib/apex_charts/options/dry_schema/annotations_options/y_axis_annotations.rb +21 -0
  33. data/lib/apex_charts/options/dry_schema/chart_options.rb +35 -0
  34. data/lib/apex_charts/options/dry_schema/data_labels_options.rb +37 -0
  35. data/lib/apex_charts/options/dry_schema/fill_options.rb +34 -0
  36. data/lib/apex_charts/options/dry_schema/general_schema/drop_shadow.rb +14 -0
  37. data/lib/apex_charts/options/dry_schema/general_schema/function.rb +12 -0
  38. data/lib/apex_charts/options/dry_schema/grid_options.rb +19 -0
  39. data/lib/apex_charts/options/dry_schema/helper_options.rb +22 -0
  40. data/lib/apex_charts/options/dry_schema/legend_options.rb +61 -0
  41. data/lib/apex_charts/options/dry_schema/markers_options.rb +34 -0
  42. data/lib/apex_charts/options/dry_schema/markers_options/discrete_point.rb +13 -0
  43. data/lib/apex_charts/options/dry_schema/no_data_options.rb +16 -0
  44. data/lib/apex_charts/options/dry_schema/plot_options.rb +231 -0
  45. data/lib/apex_charts/options/dry_schema/root_options.rb +42 -0
  46. data/lib/apex_charts/options/dry_schema/schema.rb +32 -0
  47. data/lib/apex_charts/options/dry_schema/states_options.rb +22 -0
  48. data/lib/apex_charts/options/dry_schema/states_options/filter.rb +10 -0
  49. data/lib/apex_charts/options/dry_schema/stroke_options.rb +21 -0
  50. data/lib/apex_charts/options/dry_schema/theme_options.rb +18 -0
  51. data/lib/apex_charts/options/dry_schema/title_subtitle_options.rb +22 -0
  52. data/lib/apex_charts/options/dry_schema/tooltip_options.rb +27 -0
  53. data/lib/apex_charts/options/dry_schema/x_axis_options.rb +30 -0
  54. data/lib/apex_charts/options/dry_schema/y_axis_options.rb +30 -0
  55. data/lib/apex_charts/options_builder.rb +51 -38
  56. data/lib/apex_charts/theme.rb +0 -16
  57. data/lib/apex_charts/version.rb +2 -2
  58. data/vendor/assets/javascripts/apexcharts.js +5 -5
  59. metadata +58 -27
  60. data/lib/apex_charts/options/annotations_options.rb +0 -15
  61. data/lib/apex_charts/options/chart_options.rb +0 -32
  62. data/lib/apex_charts/options/data_labels_options.rb +0 -18
  63. data/lib/apex_charts/options/div_attributes.rb +0 -11
  64. data/lib/apex_charts/options/fill_options.rb +0 -14
  65. data/lib/apex_charts/options/grid_options.rb +0 -17
  66. data/lib/apex_charts/options/legend_options.rb +0 -32
  67. data/lib/apex_charts/options/markers_options.rb +0 -24
  68. data/lib/apex_charts/options/no_data_options.rb +0 -14
  69. data/lib/apex_charts/options/plot_options.rb +0 -16
  70. data/lib/apex_charts/options/root_options.rb +0 -47
  71. data/lib/apex_charts/options/states_options.rb +0 -11
  72. data/lib/apex_charts/options/stroke_options.rb +0 -14
  73. data/lib/apex_charts/options/theme_options.rb +0 -11
  74. data/lib/apex_charts/options/title_subtitle_options.rb +0 -15
  75. data/lib/apex_charts/options/tooltip_options.rb +0 -25
  76. data/lib/apex_charts/options/x_axis_options.rb +0 -26
  77. data/lib/apex_charts/options/y_axis_options.rb +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7da6c272c62c024c2e24180a80a69760efa4ba6703dd1fae81dc7119a2115ac1
4
- data.tar.gz: 50bbebd360a73a13ebf328de39acef58d6c59270c136e58563eaa6f1a0764db8
3
+ metadata.gz: 709e9e394138ca8ede2eec0fa33a175b3e08ccaa764907c53fc6c72db067e3d5
4
+ data.tar.gz: ea1a5e008282d9edc581da80d06a61c743fbf130f91cdbfea659bb450489d5a9
5
5
  SHA512:
6
- metadata.gz: de01a99814d9234441f6b4964239e9882f7676dd3749df05ffc995669a9bb74d4c29a57c4c839b37f9d2c675d0f8e72b8ad26f8d0f95d130a401777258c50f65
7
- data.tar.gz: b57b96bc2bdcedadc007a093c7253a8ddb63d74dddbb58eb678e006e881a34d53ce26d1b623c7b25529845726832fd491c644b13ff3cf7a79794e8f5336f0834
6
+ metadata.gz: 561565108337e05159effd5c8c353765b6f4ac1b4741d2b8f520d3a3c8698f697ec0abb359debcaca14ae1ff32fa2ae8c8efe7ab2171377356a3293a2e81a0f2
7
+ data.tar.gz: 79413ca860115ccf2e9e729b40af747865bf93252ac7ae90c29260a33be0702f05c9780b32ac65fd34e43005c84aabf5c1265d9551ddfc6835212f7338cfc5ab
data/README.md CHANGED
@@ -22,9 +22,6 @@
22
22
  <a href="https://codebeat.co/projects/github-com-styd-apexcharts-rb-master">
23
23
  <img alt="codebeat badge" src="https://codebeat.co/badges/7be581d6-e74a-406b-ae76-65605a2bff78" />
24
24
  </a>
25
- <a href='https://coveralls.io/github/styd/apexcharts.rb?branch=master'>
26
- <img src='https://coveralls.io/repos/github/styd/apexcharts.rb/badge.svg?branch=master' alt='Coverage Status' />
27
- </a>
28
25
  <a href='http://clayallsopp.github.io/readme-score/?url=styd/apexcharts.rb'>
29
26
  <img src='http://readme-score-api.herokuapp.com/score.svg?url=styd/apexcharts.rb' alt='README Score' />
30
27
  </a>
@@ -52,25 +49,18 @@ Organization/Company | Use Cas
52
49
  > [this issue](https://github.com/styd/apexcharts.rb/issues/34).
53
50
 
54
51
 
55
- ## Supported By
56
-
57
- <a href="https://www.jetbrains.com/?from=ApexCharts.RB">
58
- <img src="images/supporters/jetbrains.svg" title="Grants 1 License for All Products Pack" width="120" height="120" />
59
- </a>
60
-
61
-
62
52
  ## README Versions
63
53
 
64
54
  This README might not be for the version you use.
65
55
  Choose the right README:
66
56
 
67
- > [v0.1.10] | [v0.1.9] | [v0.1.8] | [v0.1.7] | [v0.1.6] | [v0.1.5] | [v0.1.4] | [v0.1.3] | [v0.1.2] | [v0.1.1]
57
+ > [v0.1.11] | [v0.1.10] | [v0.1.9] | [v0.1.8] | [v0.1.7] | [v0.1.6] |
58
+ > [v0.1.5] | [v0.1.4] | [v0.1.3] | [v0.1.2] | [v0.1.1]
68
59
 
69
60
  ## Table of Contents
70
61
 
71
62
  - [About](#about)
72
63
  - [Trusted By](#trusted-by)
73
- - [Supported By](#supported-by)
74
64
  - [README Versions](#readme-versions)
75
65
  - [Table of Contents](#table-of-contents)
76
66
  - [Usage](#usage)
@@ -83,6 +73,7 @@ Choose the right README:
83
73
  - [Range Bar Chart](#range-bar-chart)
84
74
  - [Scatter Chart](#scatter-chart)
85
75
  - [Candlestick Chart](#candlestick-chart)
76
+ - [Box Plot Chart](#box-plot-chart)
86
77
  - [Mixed Charts](#mixed-charts)
87
78
  - [Syncing Charts](#syncing-charts)
88
79
  - [Brush Chart](#brush-chart)
@@ -97,6 +88,7 @@ Choose the right README:
97
88
  - [Data Formats](#data-formats)
98
89
  - [Cartesian Charts](#cartesian-charts-1)
99
90
  - [Candlestick Chart](#candlestick-chart-1)
91
+ - [Box Plot Chart](#box-plot-chart-1)
100
92
  - [Heatmap Chart](#heatmap-chart-1)
101
93
  - [Radar Chart](#radar-chart-1)
102
94
  - [Bubble Chart](#bubble-chart-1)
@@ -105,9 +97,8 @@ Choose the right README:
105
97
  - [Global Options](#global-options)
106
98
  - [Formatter Function](#formatter-function)
107
99
  - [Defer Chart Rendering](#defer-chart-rendering)
100
+ - [Schema](#schema)
108
101
  - [Reusable Custom Palette](#reusable-custom-palette)
109
- - [Global Palette](#global-palette)
110
- - [Local Palette](#local-palette)
111
102
  - [Use Alongside Other Charting Libraries](#use-alongside-other-charting-libraries)
112
103
  - [Alongside Chartkick](#alongside-chartkick)
113
104
  - [Chartkick (Chart.js) and ApexCharts](#chartkick-chartjs-and-apexcharts)
@@ -118,7 +109,6 @@ Choose the right README:
118
109
  - [Rails](#rails)
119
110
  - [Sinatra](#sinatra)
120
111
  - [Plain HTML+ERB (Without Framework)](#plain-htmlerb-without-framework)
121
- - [Roadmap](#roadmap)
122
112
  - [Contributing](#contributing)
123
113
  - [License](#license)
124
114
  - [Like the charts?](#like-the-charts)
@@ -288,6 +278,46 @@ You can make candlestick chart with this:
288
278
  ![Example Candlestick Chart](images/candlestick_chart.gif)
289
279
 
290
280
 
281
+ #### Box Plot Chart
282
+
283
+ Given:
284
+ ```erb
285
+ <%
286
+ require 'date'
287
+
288
+ def box_plot_data
289
+ 20.times.map {|i| [Date.today - 20 + i, box_plot_datum] }.to_h
290
+ end
291
+
292
+ def box_plot_datum
293
+ level = 1000
294
+ max = level + rand(50..300)
295
+ min = level - rand(50..300)
296
+ q1 = min + rand(10..50)
297
+ q3 = max - rand(10..50)
298
+ median = (min + q1 + q3 + max)/4
299
+ [min, q1, median, q3, max]
300
+ end
301
+
302
+ box_plot_options = {
303
+ plot_options: {
304
+ boxPlot: {
305
+ colors: {
306
+ upper: '#aaffaa',
307
+ lower: '#ffaaFF'
308
+ }
309
+ }
310
+ }
311
+ }
312
+ %>
313
+ ```
314
+ You can make box plot chart with this:
315
+ ```erb
316
+ <%= box_plot_chart(box_plot_data, box_plot_options) %>
317
+ ```
318
+ ![Example Box Plot Chart](images/box_plot_chart.gif)
319
+
320
+
291
321
  #### Mixed Charts
292
322
 
293
323
  You can mix charts by using `mixed_charts` or `combo_charts` methods.
@@ -493,6 +523,29 @@ or this:
493
523
  ]
494
524
  ```
495
525
 
526
+ #### Box Plot Chart
527
+
528
+ Box plot chart is similar to candlestick chart, only the y value is
529
+ an array of 5 members (Minimum-First Quartile-Median-Third Quartile-Maximum):
530
+
531
+ ```ruby
532
+ {
533
+ <x value> => [<Min>, <Q1>, <Median>, <Q3>, <Max>],
534
+ <x value> => [<Min>, <Q1>, <Median>, <Q3>, <Max>],
535
+ ...
536
+ }
537
+ ```
538
+
539
+ or this:
540
+
541
+ ```ruby
542
+ [
543
+ [<x value>, [<Min>, <Q1>, <Median>, <Q3>, <Max>]],
544
+ [<x value>, [<Min>, <Q1>, <Median>, <Q3>, <Max>]],
545
+ ...
546
+ ]
547
+ ```
548
+
496
549
  ### Heatmap Chart
497
550
 
498
551
  The data format for heatmap chart **per-series** is similar to cartesian
@@ -651,13 +704,26 @@ It's possible to defer chart rendering by passing the argument `defer: true` as
651
704
  ```
652
705
 
653
706
 
654
- ## Reusable Custom Palette
707
+ ## Schema
708
+
709
+ To use [dry-schema] as an alternative options schema, you can specify the following config
710
+ before calling your charts:
655
711
 
656
- You can create custom palette that works globally or locally.
712
+ ```ruby
713
+ ApexCharts.config.schema = :dry_schema
714
+ ```
657
715
 
658
- ### Global Palette
716
+ or
659
717
 
660
- To create global palettes to be used anywhere on your any parts of your app, you can use
718
+ ```ruby
719
+ ApexCharts.configure do |config|
720
+ config.schema = :dry_schema
721
+ end
722
+ ```
723
+
724
+ ## Reusable Custom Palette
725
+
726
+ To create palettes to be used anywhere on your any parts of your app, you can use
661
727
  `ApexCharts::Theme.create`.
662
728
 
663
729
  For example, in rails app, you would write it in initializers:
@@ -689,8 +755,7 @@ You can prefix the helper methods name with your chosen words to avoid name clas
689
755
  other charting libraries (e.g. chartkick, google_charts, etc.) you already use. Just set
690
756
  the `APEXCHARTS_PREFIX` environment variable to a string before you start your app server,
691
757
  say, 'awesome\_' and then on your views/templates use the chart helpers as `awesome_line_chart`,
692
- `awesome_area_chart`, and so on. `create_palette` and `destroy_palette` are left as is (not
693
- prefixed) as other libraries don't seem to have anything similar to them.
758
+ `awesome_area_chart`, and so on.
694
759
 
695
760
  Besides setting the environtment variable, if you just want a quick prefix, you can instead
696
761
  do this on your _Gemfile_:
@@ -855,17 +920,6 @@ $ erb sample.html.erb > sample.html
855
920
  ```
856
921
 
857
922
 
858
- ## Roadmap
859
-
860
- - Support other ruby frameworks (hanami, roda, cuba, middleman, etc.)
861
- - v0.1.x
862
- - Add more features (e.g. gradient line, background image, etc.)
863
- - v0.2.x
864
- - Replace dependency `smart_kv` with `dry-schema`
865
- - Display warnings on browser console on development instead of error page when
866
- schema doesn't meet
867
-
868
-
869
923
  ## Contributing
870
924
 
871
925
  Everyone is encouraged to help improve this project by:
@@ -873,7 +927,6 @@ Everyone is encouraged to help improve this project by:
873
927
  - Fixing bugs and submiting pull requests
874
928
  - Fixing documentation
875
929
  - Suggesting new features
876
- - Implementing todos on Roadmap above
877
930
 
878
931
 
879
932
  ## License
@@ -889,8 +942,11 @@ The gem is available as open source under the terms of the
889
942
 
890
943
 
891
944
  [ApexCharts.JS]: https://github.com/apexcharts/apexcharts.js
945
+ [dry-schema]: https://github.com/dry-rb/dry-schema
892
946
 
893
947
 
948
+ [Unreleased]: https://github.com/styd/apexcharts.rb/compare/v0.1.11...HEAD
949
+ [v0.1.11]: https://github.com/styd/apexcharts.rb/blob/v0.1.11/README.md
894
950
  [v0.1.10]: https://github.com/styd/apexcharts.rb/blob/v0.1.10/README.md
895
951
  [v0.1.9]: https://github.com/styd/apexcharts.rb/blob/v0.1.9/README.md
896
952
  [v0.1.8]: https://github.com/styd/apexcharts.rb/blob/v0.1.8/README.md
@@ -8,6 +8,7 @@ module ApexCharts::Charts
8
8
  autoload :"#{type.capitalize}Chart", "apex_charts/charts/#{type}_chart.rb"
9
9
  end
10
10
 
11
+ autoload :BoxPlotChart, 'apex_charts/charts/box_plot_chart.rb'
11
12
  autoload :RangeBarChart, 'apex_charts/charts/range_bar_chart.rb'
12
13
  autoload :RadialBarChart, 'apex_charts/charts/radial_bar_chart.rb'
13
14
 
@@ -0,0 +1,8 @@
1
+
2
+ module ApexCharts::Charts
3
+ class BoxPlotChart < CartesianChart
4
+ def chart_type
5
+ 'boxPlot'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApexCharts
4
+ module Config
5
+ module Schema
6
+ def schema
7
+ @schema ||= 'Default'
8
+ end
9
+
10
+ def schema=(name)
11
+ @schema = case name
12
+ when :dry_schema, 'dry_schema', 'dry-schema'
13
+ 'DrySchema'
14
+ else
15
+ 'Default'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'config/default_options'
4
+ require_relative 'config/schema'
4
5
 
5
6
  module ApexCharts
6
7
  class << self
@@ -21,5 +22,6 @@ module ApexCharts
21
22
 
22
23
  class Configuration
23
24
  include ApexCharts::Config::DefaultOptions
25
+ include ApexCharts::Config::Schema
24
26
  end
25
27
  end
@@ -78,6 +78,15 @@ module ApexCharts
78
78
  end
79
79
  alias_method :ohlc_chart, :candlestick_chart
80
80
 
81
+ def box_plot_chart(series, options={}, &block)
82
+ outer_self = eval('self', block.binding, __FILE__, __LINE__) if block_given?
83
+ draw_chart(
84
+ ApexCharts::Charts::BoxPlotChart.new(
85
+ outer_self, *prepare_series_and_options(series, options), &block
86
+ )
87
+ )
88
+ end
89
+
81
90
  def heatmap_chart(series, options={})
82
91
  draw_chart(
83
92
  ApexCharts::Charts::HeatmapChart.new(
@@ -148,17 +157,6 @@ module ApexCharts
148
157
  alias_method :circle_chart, :radial_bar_chart
149
158
  end
150
159
 
151
- def create_palette(palette_name, colors)
152
- warn "`create_palette' and `destroy_palette` are deprecated " +
153
- "and will be removed in the next release."
154
-
155
- Theme::Local.create palette_name, colors
156
- end
157
-
158
- def destroy_palette(palette_name)
159
- Theme::Local.destroy palette_name
160
- end
161
-
162
160
  private
163
161
 
164
162
  def draw_chart(chart)
@@ -0,0 +1,14 @@
1
+ module ApexCharts::Options
2
+ module Default
3
+ class AnnotationsOptions < ::SmartKv
4
+ optional *%i[
5
+ images
6
+ points
7
+ position
8
+ texts
9
+ xaxis
10
+ yaxis
11
+ ]
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,33 @@
1
+ module ApexCharts::Options
2
+ module Default
3
+ class ChartOptions < ::SmartKv
4
+ optional *%i[
5
+ animations
6
+ background
7
+ brush
8
+ defaultLocale
9
+ dropShadow
10
+ events
11
+ fontFamily
12
+ foreColor
13
+ group
14
+ height
15
+ id
16
+ locales
17
+ offsetX
18
+ offsetY
19
+ parentHeightOffset
20
+ redrawOnParentResize
21
+ redrawOnWindowResize
22
+ selection
23
+ sparkline
24
+ stackType
25
+ stacked
26
+ toolbar
27
+ type
28
+ width
29
+ zoom
30
+ ]
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,18 @@
1
+ module ApexCharts::Options
2
+ module Default
3
+ class DataLabelsOptions < ::SmartKv
4
+ optional *%i[
5
+ background
6
+ distributed
7
+ dropShadow
8
+ enabled
9
+ enabledOnSeries
10
+ formatter
11
+ offsetX
12
+ offsetY
13
+ style
14
+ textAnchor
15
+ ]
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ module ApexCharts::Options
2
+ module Default
3
+ class FillOptions < ::SmartKv
4
+ optional *%i[
5
+ colors
6
+ gradient
7
+ image
8
+ opacity
9
+ pattern
10
+ type
11
+ ]
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ module ApexCharts::Options
2
+ module Default
3
+ class GridOptions < ::SmartKv
4
+ optional *%i[
5
+ borderColor
6
+ column
7
+ padding
8
+ position
9
+ row
10
+ show
11
+ strokeDashArray
12
+ xaxis
13
+ yaxis
14
+ ]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ require 'smart_kv'
2
+
3
+ module ApexCharts::Options
4
+ module Default
5
+ class HelperOptions < ::SmartKv
6
+ optional *%i[
7
+ brushTarget
8
+ class
9
+ chartId
10
+ defer
11
+ group
12
+ id
13
+ style
14
+ var
15
+ xtitle
16
+ xtype
17
+ ytitle
18
+ ytype
19
+ ]
20
+ end
21
+ end
22
+ end