apexcharts 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -20
- data/lib/apex_charts/charts.rb +16 -0
- data/lib/{apexcharts/charts/area.rb → apex_charts/charts/area_chart.rb} +1 -1
- data/lib/{apexcharts/charts/bar.rb → apex_charts/charts/bar_chart.rb} +1 -1
- data/lib/{apexcharts/charts/base.rb → apex_charts/charts/base_chart.rb} +6 -4
- data/lib/{apexcharts/charts/bubble.rb → apex_charts/charts/bubble_chart.rb} +2 -2
- data/lib/{apexcharts/charts/candlestick.rb → apex_charts/charts/candlestick_chart.rb} +1 -1
- data/lib/{apexcharts/charts/cartesian.rb → apex_charts/charts/cartesian_chart.rb} +8 -6
- data/lib/{apexcharts/charts/column.rb → apex_charts/charts/column_chart.rb} +3 -1
- data/lib/{apexcharts/charts/donut.rb → apex_charts/charts/donut_chart.rb} +1 -1
- data/lib/{apexcharts → apex_charts}/charts/features/annotations.rb +7 -5
- data/lib/{apexcharts → apex_charts}/charts/features/mixable.rb +1 -1
- data/lib/{apexcharts/charts/heatmap.rb → apex_charts/charts/heatmap_chart.rb} +2 -2
- data/lib/{apexcharts/charts/line.rb → apex_charts/charts/line_chart.rb} +1 -1
- data/lib/{apexcharts/charts/mixed.rb → apex_charts/charts/mixed_charts.rb} +6 -4
- data/lib/{apexcharts/charts/pie.rb → apex_charts/charts/pie_chart.rb} +1 -1
- data/lib/apex_charts/charts/polar_chart.rb +9 -0
- data/lib/{apexcharts/charts/radar.rb → apex_charts/charts/radar_chart.rb} +2 -2
- data/lib/{apexcharts/charts/radial_bar.rb → apex_charts/charts/radial_bar_chart.rb} +1 -1
- data/lib/{apexcharts/charts/range_bar.rb → apex_charts/charts/range_bar_chart.rb} +1 -1
- data/lib/{apexcharts/charts/scatter.rb → apex_charts/charts/scatter_chart.rb} +1 -1
- data/lib/{apexcharts/charts/syncing.rb → apex_charts/charts/syncing_charts.rb} +1 -1
- data/lib/{apexcharts → apex_charts}/colors.rb +2 -1
- data/lib/apex_charts/config/default_options.rb +16 -0
- data/lib/{apexcharts/config.rb → apex_charts/configuration.rb} +7 -7
- data/lib/{apexcharts → apex_charts}/helper.rb +16 -16
- data/lib/{apexcharts/options/annotations.rb → apex_charts/options/annotations_options.rb} +3 -1
- data/lib/{apexcharts/options/axis.rb → apex_charts/options/axis_options.rb} +3 -1
- data/lib/{apexcharts/options/chart.rb → apex_charts/options/chart_options.rb} +3 -1
- data/lib/{apexcharts/options/data_labels.rb → apex_charts/options/data_labels_options.rb} +3 -1
- data/lib/{apexcharts → apex_charts}/options/div_attributes.rb +3 -1
- data/lib/{apexcharts/options/fill.rb → apex_charts/options/fill_options.rb} +3 -1
- data/lib/{apexcharts/options/grid.rb → apex_charts/options/grid_options.rb} +3 -1
- data/lib/{apexcharts/options/legend.rb → apex_charts/options/legend_options.rb} +3 -1
- data/lib/{apexcharts/options/markers.rb → apex_charts/options/markers_options.rb} +3 -1
- data/lib/{apexcharts/options/no_data.rb → apex_charts/options/no_data_options.rb} +3 -1
- data/lib/{apexcharts → apex_charts}/options/plot_options.rb +3 -1
- data/lib/{apexcharts/options/root.rb → apex_charts/options/root_options.rb} +6 -4
- data/lib/{apexcharts/options/states.rb → apex_charts/options/states_options.rb} +3 -1
- data/lib/{apexcharts/options/stroke.rb → apex_charts/options/stroke_options.rb} +3 -1
- data/lib/{apexcharts/options/theme.rb → apex_charts/options/theme_options.rb} +3 -1
- data/lib/{apexcharts/options/title.rb → apex_charts/options/title_subtitle_options.rb} +4 -2
- data/lib/{apexcharts/options/tooltip.rb → apex_charts/options/tooltip_options.rb} +3 -1
- data/lib/{apexcharts/options/x_axis.rb → apex_charts/options/x_axis_options.rb} +4 -2
- data/lib/{apexcharts/options/y_axis.rb → apex_charts/options/y_axis_options.rb} +4 -2
- data/lib/{apexcharts → apex_charts}/options_builder.rb +37 -34
- data/lib/apex_charts/prefix_with_apex.rb +7 -0
- data/lib/{apexcharts → apex_charts}/prefixer.rb +2 -0
- data/lib/{apexcharts → apex_charts}/renderer.rb +7 -1
- data/lib/apex_charts/series.rb +7 -0
- data/lib/{apexcharts/series/bubble.rb → apex_charts/series/bubble_series.rb} +4 -2
- data/lib/{apexcharts/series/cartesian.rb → apex_charts/series/cartesian_series.rb} +4 -2
- data/lib/{apexcharts/series/polar.rb → apex_charts/series/polar_series.rb} +4 -2
- data/lib/{apexcharts → apex_charts}/support/rails.rb +0 -0
- data/lib/{apexcharts → apex_charts}/support/sinatra.rb +0 -0
- data/lib/{apexcharts → apex_charts}/theme.rb +0 -0
- data/lib/{apexcharts → apex_charts}/utils.rb +0 -0
- data/lib/{apexcharts → apex_charts}/utils/copy.rb +2 -0
- data/lib/{apexcharts → apex_charts}/utils/date_time.rb +2 -0
- data/lib/{apexcharts → apex_charts}/utils/hash.rb +2 -0
- data/lib/{apexcharts → apex_charts}/version.rb +1 -1
- data/lib/apexcharts.rb +3 -3
- data/lib/apexcharts/prefix_with_apex.rb +18 -3
- data/vendor/assets/javascripts/apexcharts.js +11 -3
- metadata +67 -67
- data/lib/apexcharts/charts.rb +0 -19
- data/lib/apexcharts/charts/polar.rb +0 -7
- data/lib/apexcharts/config/default_options.rb +0 -12
- data/lib/apexcharts/options/subtitle.rb +0 -9
- data/lib/apexcharts/series.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 737afc5c5ce435bfa18cfe6b7d00f51ffd74c040f8f5f51728dec1711a2514fc
|
4
|
+
data.tar.gz: e46f31763675b25c6cf0f010a16423aa2e6249240302af88e793f65277c7a816
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4d469bb0d6ccb22595939a9e5305ce8cfb75db59c2e54db786d937c10cf1f07d0cfe342238ab3289fbebad2149b7e3eee0df5c20fcea17230c9eb45fb8b0cee
|
7
|
+
data.tar.gz: 67de41d4a272ee5ed1cfd200c20e9d2b2a95300c00d03463a9561000481655af329f6629f1a6a3d1443ef92bffbc33f4593247f983943faa58eae78cbd3e559f
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
<p align="center">
|
2
|
-
<img src="images/
|
2
|
+
<img src="images/apexcharts.rb.png" height="150" />
|
3
3
|
</p>
|
4
4
|
|
5
5
|
<p align="center">
|
@@ -39,8 +39,11 @@
|
|
39
39
|
|
40
40
|
## Trusted By
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
Organization/Company | Use Case
|
43
|
+
-----------------------------------------------------------------------|------------------------------------------------------------------
|
44
|
+
<img src="/images/users/copient-health.png" width="143" height="40" /> | Reports/charts related to Operating Room utilization statistics
|
45
|
+
<img src="/images/users/bilendo.png" width="202" height="40" /> | Enterprise dashboards to visualize account receivables data
|
46
|
+
<img src="/images/users/ventrata.png" width="180" height="40" /> | Ticket sales for clients (visitor attractions and tour operators)
|
44
47
|
|
45
48
|
> If your organization/company uses ApexCharts.RB in production, please comment on
|
46
49
|
> [this issue](https://github.com/styd/apexcharts.rb/issues/34).
|
@@ -49,7 +52,7 @@
|
|
49
52
|
## Supported By
|
50
53
|
|
51
54
|
<a href="https://www.jetbrains.com/?from=ApexCharts.RB">
|
52
|
-
<img src="images/supporters/jetbrains.svg" title="Grants 1 License for All Products Pack
|
55
|
+
<img src="images/supporters/jetbrains.svg" title="Grants 1 License for All Products Pack" width="120" height="120" />
|
53
56
|
</a>
|
54
57
|
|
55
58
|
|
@@ -58,7 +61,7 @@
|
|
58
61
|
This README might not be for the version you use.
|
59
62
|
Choose the right README:
|
60
63
|
|
61
|
-
> [v0.1.8] | [v0.1.7] | [v0.1.6] | [v0.1.5] | [v0.1.4] | [v0.1.3] | [v0.1.2] | [v0.1.1]
|
64
|
+
> [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]
|
62
65
|
|
63
66
|
## Table of Contents
|
64
67
|
|
@@ -249,13 +252,18 @@ Given:
|
|
249
252
|
<%
|
250
253
|
require 'date'
|
251
254
|
|
252
|
-
def
|
253
|
-
|
255
|
+
def candlestick_data
|
256
|
+
@acc = rand(6570..6650)
|
257
|
+
60.times.map {|i| [Date.today - 60 + i, ohlc] }.to_h
|
254
258
|
end
|
255
259
|
|
256
|
-
|
257
|
-
|
258
|
-
|
260
|
+
def ohlc
|
261
|
+
open = @acc + rand(-20..20)
|
262
|
+
high = open + rand(0..100)
|
263
|
+
low = open - rand(0..100)
|
264
|
+
@acc = close = open + rand(-((high-low)/3)..((high-low)/2))
|
265
|
+
[open, high, low, close]
|
266
|
+
end
|
259
267
|
|
260
268
|
candlestick_options = {
|
261
269
|
plot_options: {
|
@@ -275,9 +283,6 @@ You can make candlestick chart with this:
|
|
275
283
|
```
|
276
284
|
![Example Candlestick Chart](images/candlestick_chart.gif)
|
277
285
|
|
278
|
-
Real life candlestick chart probably don't look like that.
|
279
|
-
That's because I just use random sets of numbers as the data.
|
280
|
-
|
281
286
|
|
282
287
|
#### Mixed Charts
|
283
288
|
|
@@ -626,6 +631,12 @@ use it like so:
|
|
626
631
|
<%= area_chart series, tooltip: {y: {formatter: function(val) { return '$' + parseFloat(val).toLocaleString() }}} %>
|
627
632
|
```
|
628
633
|
|
634
|
+
Or, without the _functionable-json_ gem, use function as object as follows:
|
635
|
+
|
636
|
+
```erb
|
637
|
+
<%= area_chart series, tooltip: {y: {formatter: {function: {args: "val", body: "return '$' + parseFloat(val).toLocaleString();"}} }} %>
|
638
|
+
```
|
639
|
+
|
629
640
|
|
630
641
|
## Reusable Custom Palette
|
631
642
|
|
@@ -692,7 +703,7 @@ Besides setting the environtment variable, if you just want a quick prefix, you
|
|
692
703
|
do this on your _Gemfile_:
|
693
704
|
|
694
705
|
```ruby
|
695
|
-
gem 'apexcharts', require: '
|
706
|
+
gem 'apexcharts', require: 'apex_charts/prefix_with_apex'
|
696
707
|
```
|
697
708
|
|
698
709
|
and you'll get `apex_line_chart`, `apex_area_chart`, etc.
|
@@ -878,18 +889,16 @@ The gem is available as open source under the terms of the
|
|
878
889
|
[MIT License](https://opensource.org/licenses/MIT).
|
879
890
|
|
880
891
|
|
881
|
-
##
|
882
|
-
|
883
|
-
Consider donating to the author of [ApexCharts.JS] to support his awesome library.
|
884
|
-
This project wouldn't be possible without it.
|
892
|
+
## Articles
|
885
893
|
|
886
|
-
|
887
|
-
|
894
|
+
- [Rails em 8 minutos: Criando gráficos incríveis com ApexCharts](https://onebitcode.com/graficos-incriveis-no-ruby-on-rails/)
|
895
|
+
- [【Rails】 5分でApexChart.jsを導入する方法](https://qiita.com/syukan3/items/aa741df278f628087a3c)
|
888
896
|
|
889
897
|
|
890
898
|
[ApexCharts.JS]: https://github.com/apexcharts/apexcharts.js
|
891
899
|
|
892
900
|
|
901
|
+
[v0.1.9]: https://github.com/styd/apexcharts.rb/blob/v0.1.9/README.md
|
893
902
|
[v0.1.8]: https://github.com/styd/apexcharts.rb/blob/v0.1.8/README.md
|
894
903
|
[v0.1.7]: https://github.com/styd/apexcharts.rb/blob/v0.1.7/README.md
|
895
904
|
[v0.1.6]: https://github.com/styd/apexcharts.rb/blob/v0.1.6/README.md
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ApexCharts::Charts
|
4
|
+
%w[
|
5
|
+
base cartesian line area bar column scatter
|
6
|
+
candlestick heatmap bubble radar polar pie donut
|
7
|
+
].each do |type|
|
8
|
+
autoload :"#{type.capitalize}Chart", "apex_charts/charts/#{type}_chart.rb"
|
9
|
+
end
|
10
|
+
|
11
|
+
autoload :RangeBarChart, 'apex_charts/charts/range_bar_chart.rb'
|
12
|
+
autoload :RadialBarChart, 'apex_charts/charts/radial_bar_chart.rb'
|
13
|
+
|
14
|
+
autoload :MixedCharts, 'apex_charts/charts/mixed_charts.rb'
|
15
|
+
autoload :SyncingCharts, 'apex_charts/charts/syncing_charts.rb'
|
16
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ApexCharts::Charts
|
2
4
|
class BaseChart
|
3
|
-
include Utils::Hash
|
5
|
+
include ApexCharts::Utils::Hash
|
4
6
|
|
5
7
|
attr_reader :options, :series, :sample
|
6
8
|
|
@@ -10,7 +12,7 @@ module ApexCharts
|
|
10
12
|
end
|
11
13
|
|
12
14
|
def render
|
13
|
-
Renderer.render_default(options)
|
15
|
+
ApexCharts::Renderer.render_default(options)
|
14
16
|
end
|
15
17
|
|
16
18
|
def chart_type; end
|
@@ -25,7 +27,7 @@ module ApexCharts
|
|
25
27
|
|
26
28
|
def build_options(options)
|
27
29
|
deep_merge(
|
28
|
-
OptionsBuilder.new(sample, options).build_options,
|
30
|
+
ApexCharts::OptionsBuilder.new(sample, options).build_options,
|
29
31
|
camelize_keys(
|
30
32
|
{**@series, chart: {type: chart_type}}.compact
|
31
33
|
)
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'features/annotations'
|
4
|
+
require_relative 'features/mixable'
|
3
5
|
require_relative '../utils/hash'
|
4
6
|
|
5
|
-
module ApexCharts
|
7
|
+
module ApexCharts::Charts
|
6
8
|
class CartesianChart < BaseChart
|
7
|
-
include Annotations
|
8
|
-
include Mixable
|
9
|
-
include Utils::Hash
|
9
|
+
include Features::Annotations
|
10
|
+
include Features::Mixable
|
11
|
+
include ApexCharts::Utils::Hash
|
10
12
|
|
11
13
|
def initialize(outer_self, data, options={}, &block)
|
12
14
|
@outer_self = outer_self
|
@@ -27,7 +29,7 @@ module ApexCharts
|
|
27
29
|
end
|
28
30
|
|
29
31
|
def series_type
|
30
|
-
CartesianSeries
|
32
|
+
ApexCharts::Series::CartesianSeries
|
31
33
|
end
|
32
34
|
|
33
35
|
def more_options
|
@@ -74,7 +76,7 @@ module ApexCharts
|
|
74
76
|
end
|
75
77
|
|
76
78
|
def handle_time(input)
|
77
|
-
Utils::DateTime.convert(input)
|
79
|
+
ApexCharts::Utils::DateTime.convert(input)
|
78
80
|
end
|
79
81
|
end
|
80
82
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ApexCharts::Charts::Features
|
2
4
|
module Annotations
|
3
5
|
def annotation(axis, value:, text:, color: nil, **options)
|
4
6
|
@annotations ||= {}
|
@@ -35,7 +37,7 @@ module ApexCharts
|
|
35
37
|
axis = axis.to_s.delete_suffix('axis').to_sym
|
36
38
|
case value
|
37
39
|
when Range
|
38
|
-
value = Utils::DateTime.convert_range(value)
|
40
|
+
value = ApexCharts::Utils::DateTime.convert_range(value)
|
39
41
|
|
40
42
|
case axis
|
41
43
|
when :x
|
@@ -47,10 +49,10 @@ module ApexCharts
|
|
47
49
|
end
|
48
50
|
else
|
49
51
|
if axis == :points
|
50
|
-
value.map! {|x| Utils::DateTime.convert(x) }
|
52
|
+
value.map! {|x| ApexCharts::Utils::DateTime.convert(x) }
|
51
53
|
{x: value.first, y: value.last}
|
52
54
|
else
|
53
|
-
value = Utils::DateTime.convert(value)
|
55
|
+
value = ApexCharts::Utils::DateTime.convert(value)
|
54
56
|
{axis => value}
|
55
57
|
end
|
56
58
|
end
|
@@ -69,6 +71,6 @@ module ApexCharts
|
|
69
71
|
}
|
70
72
|
end
|
71
73
|
|
72
|
-
include Utils::Hash
|
74
|
+
include ApexCharts::Utils::Hash
|
73
75
|
end
|
74
76
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'features/annotations'
|
4
|
+
|
5
|
+
module ApexCharts::Charts
|
4
6
|
class MixedCharts < BaseChart
|
5
|
-
include Annotations
|
6
|
-
include Utils::Hash
|
7
|
+
include Features::Annotations
|
8
|
+
include ApexCharts::Utils::Hash
|
7
9
|
|
8
10
|
def initialize(outer_self, options={}, &block)
|
9
11
|
@outer_self = outer_self
|
@@ -93,7 +95,7 @@ module ApexCharts
|
|
93
95
|
end
|
94
96
|
|
95
97
|
def handle_time(input)
|
96
|
-
Utils::DateTime.convert(input)
|
98
|
+
ApexCharts::Utils::DateTime.convert(input)
|
97
99
|
end
|
98
100
|
end
|
99
101
|
end
|
@@ -17,7 +17,8 @@ module ApexCharts
|
|
17
17
|
def clean(colors)
|
18
18
|
colors = colors.respond_to?(:to_set) ? colors.to_a.flatten : Array(colors)
|
19
19
|
colors.map do |color|
|
20
|
-
|
20
|
+
color = color.upcase
|
21
|
+
raise "unrecognized color #{color}" unless color[/^#[0-9A-F]{6}/]
|
21
22
|
|
22
23
|
color
|
23
24
|
end
|