apexcharts 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +149 -56
- data/lib/apex_charts/charts/base_chart.rb +1 -1
- data/lib/apex_charts/charts/box_plot_chart.rb +9 -0
- data/lib/apex_charts/charts.rb +1 -0
- data/lib/apex_charts/helper.rb +9 -8
- data/lib/apex_charts/options_builder.rb +146 -123
- data/lib/apex_charts/renderer.rb +69 -25
- data/lib/apex_charts/series/bubble_series.rb +2 -3
- data/lib/apex_charts/series/cartesian_series.rb +8 -2
- data/lib/apex_charts/theme.rb +0 -16
- data/lib/apex_charts/version.rb +2 -1
- data/vendor/assets/javascripts/apexcharts.js +5 -5
- metadata +4 -51
- data/lib/apex_charts/options/annotations_options.rb +0 -12
- data/lib/apex_charts/options/axis_options.rb +0 -19
- data/lib/apex_charts/options/chart_options.rb +0 -28
- data/lib/apex_charts/options/data_labels_options.rb +0 -16
- data/lib/apex_charts/options/div_attributes.rb +0 -11
- data/lib/apex_charts/options/fill_options.rb +0 -14
- data/lib/apex_charts/options/grid_options.rb +0 -17
- data/lib/apex_charts/options/legend_options.rb +0 -29
- data/lib/apex_charts/options/markers_options.rb +0 -20
- data/lib/apex_charts/options/no_data_options.rb +0 -14
- data/lib/apex_charts/options/plot_options.rb +0 -14
- data/lib/apex_charts/options/root_options.rb +0 -46
- data/lib/apex_charts/options/states_options.rb +0 -11
- data/lib/apex_charts/options/stroke_options.rb +0 -14
- data/lib/apex_charts/options/theme_options.rb +0 -10
- data/lib/apex_charts/options/title_subtitle_options.rb +0 -15
- data/lib/apex_charts/options/tooltip_options.rb +0 -24
- data/lib/apex_charts/options/x_axis_options.rb +0 -14
- data/lib/apex_charts/options/y_axis_options.rb +0 -18
- data/lib/apexcharts/prefix_with_apex.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e97e5e996cb05991f345e7cf9c6591aab1405925b2b92643f518687017923170
|
4
|
+
data.tar.gz: 5a64c5b2a09074483ab53abcbcaed281efe8241ae83978d04e48e0486c1bf5b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 438e96dcecf8766666b1b1d48bfa7f0a134ee3ee70d14a6309850ef9e47ea28633bf68101b3c11a90f92cabdece41da05e3e599b3523a2de3295470133c980e1
|
7
|
+
data.tar.gz: 1677bef319ca1190860641f188e0914f29400709f96d9afc42a3f4cb833671865227c61ae9d22cfec7c2ae14af88cfa78f47a0328e91f4c60809d1bbdcf7db46
|
data/README.md
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
<a href="https://rubygems.org/gems/apexcharts">
|
7
7
|
<img src="https://img.shields.io/gem/v/apexcharts.svg?label=apexcharts" alt="Gem Version" />
|
8
8
|
</a>
|
9
|
-
<a href="https://
|
10
|
-
<img src="https://
|
9
|
+
<a href="https://github.com/styd/apexcharts.rb/actions">
|
10
|
+
<img src="https://github.com/styd/apexcharts.rb/workflows/build-test/badge.svg?branch=master" alt="Build Test Status" />
|
11
11
|
</a>
|
12
12
|
<a href="https://rubygems.org/gems/apexcharts">
|
13
13
|
<img alt="Downloads" src="https://img.shields.io/gem/dt/apexcharts">
|
@@ -19,12 +19,16 @@
|
|
19
19
|
<a href="https://codeclimate.com/github/styd/apexcharts.rb/maintainability">
|
20
20
|
<img src="https://api.codeclimate.com/v1/badges/07a4f59e67abfeae21cb/maintainability" />
|
21
21
|
</a>
|
22
|
-
<a href=
|
23
|
-
<img src=
|
22
|
+
<a href="https://codebeat.co/projects/github-com-styd-apexcharts-rb-master">
|
23
|
+
<img alt="codebeat badge" src="https://codebeat.co/badges/7be581d6-e74a-406b-ae76-65605a2bff78" />
|
24
24
|
</a>
|
25
25
|
<a href='http://clayallsopp.github.io/readme-score/?url=styd/apexcharts.rb'>
|
26
26
|
<img src='http://readme-score-api.herokuapp.com/score.svg?url=styd/apexcharts.rb' alt='README Score' />
|
27
27
|
</a>
|
28
|
+
<br />
|
29
|
+
<a href='https://ko-fi.com/setyadi' target='_blank'>
|
30
|
+
<img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi4.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' />
|
31
|
+
</a>
|
28
32
|
</p>
|
29
33
|
|
30
34
|
|
@@ -46,14 +50,7 @@ Organization/Company | Use Cas
|
|
46
50
|
<img src="/images/users/ventrata.png" width="180" height="40" /> | Ticket sales for clients (visitor attractions and tour operators)
|
47
51
|
|
48
52
|
> If your organization/company uses ApexCharts.RB in production, please comment on
|
49
|
-
> [this
|
50
|
-
|
51
|
-
|
52
|
-
## Supported By
|
53
|
-
|
54
|
-
<a href="https://www.jetbrains.com/?from=ApexCharts.RB">
|
55
|
-
<img src="images/supporters/jetbrains.svg" title="Grants 1 License for All Products Pack" width="120" height="120" />
|
56
|
-
</a>
|
53
|
+
> [this discussion](https://github.com/styd/apexcharts.rb/discussions/34).
|
57
54
|
|
58
55
|
|
59
56
|
## README Versions
|
@@ -61,13 +58,13 @@ Organization/Company | Use Cas
|
|
61
58
|
This README might not be for the version you use.
|
62
59
|
Choose the right README:
|
63
60
|
|
64
|
-
> [v0.
|
61
|
+
> [v0.2.0] | [v0.1.11] | [v0.1.10] | [v0.1.9] | [v0.1.8] | [v0.1.7] |
|
62
|
+
> [v0.1.6] | [v0.1.5] | [v0.1.4] | [v0.1.3] | [v0.1.2] | [v0.1.1]
|
65
63
|
|
66
64
|
## Table of Contents
|
67
65
|
|
68
66
|
- [About](#about)
|
69
67
|
- [Trusted By](#trusted-by)
|
70
|
-
- [Supported By](#supported-by)
|
71
68
|
- [README Versions](#readme-versions)
|
72
69
|
- [Table of Contents](#table-of-contents)
|
73
70
|
- [Usage](#usage)
|
@@ -80,10 +77,12 @@ Choose the right README:
|
|
80
77
|
- [Range Bar Chart](#range-bar-chart)
|
81
78
|
- [Scatter Chart](#scatter-chart)
|
82
79
|
- [Candlestick Chart](#candlestick-chart)
|
80
|
+
- [Box Plot Chart](#box-plot-chart)
|
83
81
|
- [Mixed Charts](#mixed-charts)
|
84
82
|
- [Syncing Charts](#syncing-charts)
|
85
83
|
- [Brush Chart](#brush-chart)
|
86
84
|
- [Annotations](#annotations)
|
85
|
+
- [Multiple Y-Axes](#multiple-y-axes)
|
87
86
|
- [Heatmap Chart](#heatmap-chart)
|
88
87
|
- [Radar Chart](#radar-chart)
|
89
88
|
- [Bubble Chart](#bubble-chart)
|
@@ -94,6 +93,7 @@ Choose the right README:
|
|
94
93
|
- [Data Formats](#data-formats)
|
95
94
|
- [Cartesian Charts](#cartesian-charts-1)
|
96
95
|
- [Candlestick Chart](#candlestick-chart-1)
|
96
|
+
- [Box Plot Chart](#box-plot-chart-1)
|
97
97
|
- [Heatmap Chart](#heatmap-chart-1)
|
98
98
|
- [Radar Chart](#radar-chart-1)
|
99
99
|
- [Bubble Chart](#bubble-chart-1)
|
@@ -101,9 +101,9 @@ Choose the right README:
|
|
101
101
|
- [Options](#options)
|
102
102
|
- [Global Options](#global-options)
|
103
103
|
- [Formatter Function](#formatter-function)
|
104
|
+
- [Defer Chart Rendering](#defer-chart-rendering)
|
105
|
+
- [Render with a script whose type is module](#render-with-a-script-whose-type-is-module)
|
104
106
|
- [Reusable Custom Palette](#reusable-custom-palette)
|
105
|
-
- [Global Palette](#global-palette)
|
106
|
-
- [Local Palette](#local-palette)
|
107
107
|
- [Use Alongside Other Charting Libraries](#use-alongside-other-charting-libraries)
|
108
108
|
- [Alongside Chartkick](#alongside-chartkick)
|
109
109
|
- [Chartkick (Chart.js) and ApexCharts](#chartkick-chartjs-and-apexcharts)
|
@@ -114,10 +114,9 @@ Choose the right README:
|
|
114
114
|
- [Rails](#rails)
|
115
115
|
- [Sinatra](#sinatra)
|
116
116
|
- [Plain HTML+ERB (Without Framework)](#plain-htmlerb-without-framework)
|
117
|
-
- [Roadmap](#roadmap)
|
118
117
|
- [Contributing](#contributing)
|
119
118
|
- [License](#license)
|
120
|
-
- [
|
119
|
+
- [Articles](#articles)
|
121
120
|
|
122
121
|
|
123
122
|
## Usage
|
@@ -284,6 +283,46 @@ You can make candlestick chart with this:
|
|
284
283
|

|
285
284
|
|
286
285
|
|
286
|
+
#### Box Plot Chart
|
287
|
+
|
288
|
+
Given:
|
289
|
+
```erb
|
290
|
+
<%
|
291
|
+
require 'date'
|
292
|
+
|
293
|
+
def box_plot_data
|
294
|
+
20.times.map {|i| [Date.today - 20 + i, box_plot_datum] }.to_h
|
295
|
+
end
|
296
|
+
|
297
|
+
def box_plot_datum
|
298
|
+
level = 1000
|
299
|
+
max = level + rand(50..300)
|
300
|
+
min = level - rand(50..300)
|
301
|
+
q1 = min + rand(10..50)
|
302
|
+
q3 = max - rand(10..50)
|
303
|
+
median = (min + q1 + q3 + max)/4
|
304
|
+
[min, q1, median, q3, max]
|
305
|
+
end
|
306
|
+
|
307
|
+
box_plot_options = {
|
308
|
+
plot_options: {
|
309
|
+
boxPlot: {
|
310
|
+
colors: {
|
311
|
+
upper: '#aaffaa',
|
312
|
+
lower: '#ffaaFF'
|
313
|
+
}
|
314
|
+
}
|
315
|
+
}
|
316
|
+
}
|
317
|
+
%>
|
318
|
+
```
|
319
|
+
You can make box plot chart with this:
|
320
|
+
```erb
|
321
|
+
<%= box_plot_chart(box_plot_data, box_plot_options) %>
|
322
|
+
```
|
323
|
+

|
324
|
+
|
325
|
+
|
287
326
|
#### Mixed Charts
|
288
327
|
|
289
328
|
You can mix charts by using `mixed_charts` or `combo_charts` methods.
|
@@ -353,6 +392,52 @@ All cartesian charts can have annotations, for example:
|
|
353
392
|

|
354
393
|
|
355
394
|
|
395
|
+
#### Multiple Y-Axes
|
396
|
+
|
397
|
+
There's no fancy shortcut for multiple Y axes yet, but it is allowed. Here is an example
|
398
|
+
for that.
|
399
|
+
|
400
|
+
```erb
|
401
|
+
<% series = [
|
402
|
+
{
|
403
|
+
name: 'Income',
|
404
|
+
type: 'column',
|
405
|
+
data: [1.4, 2, 2.5, 1.5, 2.5, 2.8, 3.8, 4.6]
|
406
|
+
},
|
407
|
+
{
|
408
|
+
name: 'Cashflow',
|
409
|
+
type: 'column',
|
410
|
+
data: [1.1, 3, 3.1, 4, 4.1, 4.9, 6.5, 8.5]
|
411
|
+
},
|
412
|
+
{
|
413
|
+
name: 'Revenue',
|
414
|
+
data: [20, 29, 37, 36, 44, 45, 50, 58]
|
415
|
+
}
|
416
|
+
]
|
417
|
+
|
418
|
+
xaxis = {
|
419
|
+
title: {text: 'Year'},
|
420
|
+
categories: [2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016]
|
421
|
+
}
|
422
|
+
|
423
|
+
yaxis = [
|
424
|
+
{title: {text: "Income"}},
|
425
|
+
{
|
426
|
+
title: {text: "Operating Cashflow"},
|
427
|
+
opposite: true,
|
428
|
+
seriesName: 'Cashflow'
|
429
|
+
},
|
430
|
+
{
|
431
|
+
title: {text: "Revenue"},
|
432
|
+
opposite: true,
|
433
|
+
seriesName: 'Revenue'
|
434
|
+
}
|
435
|
+
]
|
436
|
+
%>
|
437
|
+
<%= line_chart(series, xaxis: xaxis, yaxis: yaxis) %>
|
438
|
+
```
|
439
|
+

|
440
|
+
|
356
441
|
### Heatmap Chart
|
357
442
|
|
358
443
|
```erb
|
@@ -489,6 +574,29 @@ or this:
|
|
489
574
|
]
|
490
575
|
```
|
491
576
|
|
577
|
+
#### Box Plot Chart
|
578
|
+
|
579
|
+
Box plot chart is similar to candlestick chart, only the y value is
|
580
|
+
an array of 5 members (Minimum-First Quartile-Median-Third Quartile-Maximum):
|
581
|
+
|
582
|
+
```ruby
|
583
|
+
{
|
584
|
+
<x value> => [<Min>, <Q1>, <Median>, <Q3>, <Max>],
|
585
|
+
<x value> => [<Min>, <Q1>, <Median>, <Q3>, <Max>],
|
586
|
+
...
|
587
|
+
}
|
588
|
+
```
|
589
|
+
|
590
|
+
or this:
|
591
|
+
|
592
|
+
```ruby
|
593
|
+
[
|
594
|
+
[<x value>, [<Min>, <Q1>, <Median>, <Q3>, <Max>]],
|
595
|
+
[<x value>, [<Min>, <Q1>, <Median>, <Q3>, <Max>]],
|
596
|
+
...
|
597
|
+
]
|
598
|
+
```
|
599
|
+
|
492
600
|
### Heatmap Chart
|
493
601
|
|
494
602
|
The data format for heatmap chart **per-series** is similar to cartesian
|
@@ -638,13 +746,28 @@ Or, without the _functionable-json_ gem, use function as object as follows:
|
|
638
746
|
```
|
639
747
|
|
640
748
|
|
641
|
-
|
749
|
+
### Defer Chart Rendering
|
642
750
|
|
643
|
-
|
751
|
+
It's possible to defer chart rendering by passing the argument `defer: true` as option.
|
644
752
|
|
645
|
-
|
753
|
+
```erb
|
754
|
+
<%= line_chart series, defer: true %>
|
755
|
+
```
|
756
|
+
|
757
|
+
### Render with a script whose type is module
|
646
758
|
|
647
|
-
|
759
|
+
The charts are rendered by inserting a <script> block in the HTML.
|
760
|
+
In order to generate this <script> with `type="module"` use the
|
761
|
+
option `module: true`.
|
762
|
+
|
763
|
+
```erb
|
764
|
+
<%= line_chart series, module: true %>
|
765
|
+
```
|
766
|
+
|
767
|
+
|
768
|
+
## Reusable Custom Palette
|
769
|
+
|
770
|
+
To create palettes to be used anywhere on your any parts of your app, you can use
|
648
771
|
`ApexCharts::Theme.create`.
|
649
772
|
|
650
773
|
For example, in rails app, you would write it in initializers:
|
@@ -669,26 +792,6 @@ If later for some reason I don't know you want to destroy the palette you can us
|
|
669
792
|
ApexCharts::Theme.destroy "rainbow"
|
670
793
|
```
|
671
794
|
|
672
|
-
### Local Palette
|
673
|
-
|
674
|
-
To create local palettes to be used only for current thread (usually for the duration
|
675
|
-
of a request), you can use the `create_palette` helper. The theme will only be available
|
676
|
-
on that page and inside its partials after the palette created.
|
677
|
-
|
678
|
-
For example:
|
679
|
-
|
680
|
-
```ruby
|
681
|
-
create_palette "ephemeral", ["#ab356d", "#12cdf3", "#665572", "#ababac"]
|
682
|
-
```
|
683
|
-
|
684
|
-
To destroy the palette:
|
685
|
-
|
686
|
-
```ruby
|
687
|
-
destroy_palette "ephemeral"
|
688
|
-
```
|
689
|
-
|
690
|
-
on the same page or in its partials. Otherwise, nothing will happen.
|
691
|
-
|
692
795
|
|
693
796
|
## Use Alongside Other Charting Libraries
|
694
797
|
|
@@ -696,8 +799,7 @@ You can prefix the helper methods name with your chosen words to avoid name clas
|
|
696
799
|
other charting libraries (e.g. chartkick, google_charts, etc.) you already use. Just set
|
697
800
|
the `APEXCHARTS_PREFIX` environment variable to a string before you start your app server,
|
698
801
|
say, 'awesome\_' and then on your views/templates use the chart helpers as `awesome_line_chart`,
|
699
|
-
`awesome_area_chart`, and so on.
|
700
|
-
prefixed) as other libraries don't seem to have anything similar to them.
|
802
|
+
`awesome_area_chart`, and so on.
|
701
803
|
|
702
804
|
Besides setting the environtment variable, if you just want a quick prefix, you can instead
|
703
805
|
do this on your _Gemfile_:
|
@@ -862,17 +964,6 @@ $ erb sample.html.erb > sample.html
|
|
862
964
|
```
|
863
965
|
|
864
966
|
|
865
|
-
## Roadmap
|
866
|
-
|
867
|
-
- Support other ruby frameworks (hanami, roda, cuba, middleman, etc.)
|
868
|
-
- v0.1.x
|
869
|
-
- Add more features (e.g. gradient line, background image, etc.)
|
870
|
-
- v0.2.x
|
871
|
-
- Replace dependency `smart_kv` with `dry-schema`
|
872
|
-
- Display warnings on browser console on development instead of error page when
|
873
|
-
schema doesn't meet
|
874
|
-
|
875
|
-
|
876
967
|
## Contributing
|
877
968
|
|
878
969
|
Everyone is encouraged to help improve this project by:
|
@@ -880,7 +971,6 @@ Everyone is encouraged to help improve this project by:
|
|
880
971
|
- Fixing bugs and submiting pull requests
|
881
972
|
- Fixing documentation
|
882
973
|
- Suggesting new features
|
883
|
-
- Implementing todos on Roadmap above
|
884
974
|
|
885
975
|
|
886
976
|
## License
|
@@ -898,6 +988,9 @@ The gem is available as open source under the terms of the
|
|
898
988
|
[ApexCharts.JS]: https://github.com/apexcharts/apexcharts.js
|
899
989
|
|
900
990
|
|
991
|
+
[v0.2.0]: https://github.com/styd/apexcharts.rb/blob/v0.2.0/README.md
|
992
|
+
[v0.1.11]: https://github.com/styd/apexcharts.rb/blob/v0.1.11/README.md
|
993
|
+
[v0.1.10]: https://github.com/styd/apexcharts.rb/blob/v0.1.10/README.md
|
901
994
|
[v0.1.9]: https://github.com/styd/apexcharts.rb/blob/v0.1.9/README.md
|
902
995
|
[v0.1.8]: https://github.com/styd/apexcharts.rb/blob/v0.1.8/README.md
|
903
996
|
[v0.1.7]: https://github.com/styd/apexcharts.rb/blob/v0.1.7/README.md
|
data/lib/apex_charts/charts.rb
CHANGED
@@ -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
|
|
data/lib/apex_charts/helper.rb
CHANGED
@@ -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,14 +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
|
-
Theme::Local.create palette_name, colors
|
153
|
-
end
|
154
|
-
|
155
|
-
def destroy_palette(palette_name)
|
156
|
-
Theme::Local.destroy palette_name
|
157
|
-
end
|
158
|
-
|
159
160
|
private
|
160
161
|
|
161
162
|
def draw_chart(chart)
|