apexcharts 0.1.4 → 0.1.5
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 +231 -32
- data/lib/apexcharts.rb +3 -1
- data/lib/apexcharts/charts.rb +5 -0
- data/lib/apexcharts/charts/area.rb +3 -1
- data/lib/apexcharts/charts/bar.rb +3 -1
- data/lib/apexcharts/charts/base.rb +34 -0
- data/lib/apexcharts/charts/bubble.rb +7 -8
- data/lib/apexcharts/charts/candlestick.rb +9 -0
- data/lib/apexcharts/charts/cartesian.rb +15 -39
- data/lib/apexcharts/charts/column.rb +1 -1
- data/lib/apexcharts/charts/donut.rb +3 -1
- data/lib/apexcharts/charts/features/annotations.rb +1 -1
- data/lib/apexcharts/charts/features/mixable.rb +11 -0
- data/lib/apexcharts/charts/heatmap.rb +8 -3
- data/lib/apexcharts/charts/line.rb +3 -1
- data/lib/apexcharts/charts/mixed.rb +7 -25
- data/lib/apexcharts/charts/pie.rb +3 -1
- data/lib/apexcharts/charts/polar.rb +4 -33
- data/lib/apexcharts/charts/radar.rb +15 -0
- data/lib/apexcharts/charts/radial_bar.rb +3 -1
- data/lib/apexcharts/charts/scatter.rb +3 -1
- data/lib/apexcharts/charts/syncing.rb +3 -1
- data/lib/apexcharts/helper.rb +17 -6
- data/lib/apexcharts/options/annotations.rb +1 -1
- data/lib/apexcharts/options/axis.rb +4 -4
- data/lib/apexcharts/options/chart.rb +9 -7
- data/lib/apexcharts/options/data_labels.rb +5 -5
- data/lib/apexcharts/options/div_attributes.rb +1 -1
- data/lib/apexcharts/options/fill.rb +1 -1
- data/lib/apexcharts/options/grid.rb +3 -3
- data/lib/apexcharts/options/legend.rb +13 -13
- data/lib/apexcharts/options/markers.rb +7 -7
- data/lib/apexcharts/options/no_data.rb +4 -4
- data/lib/apexcharts/options/plot_options.rb +3 -2
- data/lib/apexcharts/options/root.rb +6 -6
- data/lib/apexcharts/options/states.rb +1 -1
- data/lib/apexcharts/options/stroke.rb +3 -3
- data/lib/apexcharts/options/subtitle.rb +1 -1
- data/lib/apexcharts/options/theme.rb +1 -1
- data/lib/apexcharts/options/title.rb +3 -3
- data/lib/apexcharts/options/tooltip.rb +5 -5
- data/lib/apexcharts/options/x_axis.rb +2 -2
- data/lib/apexcharts/options/y_axis.rb +5 -5
- data/lib/apexcharts/options_builder.rb +33 -32
- data/lib/apexcharts/renderer.rb +21 -0
- data/lib/apexcharts/series.rb +2 -0
- data/lib/apexcharts/series/bubble.rb +1 -1
- data/lib/apexcharts/series/cartesian.rb +14 -23
- data/lib/apexcharts/series/polar.rb +1 -1
- data/lib/apexcharts/support/rails.rb +3 -1
- data/lib/apexcharts/utils.rb +2 -0
- data/lib/apexcharts/utils/date_time.rb +1 -1
- data/lib/apexcharts/utils/hash.rb +7 -5
- data/lib/apexcharts/version.rb +4 -2
- metadata +52 -4
@@ -1,12 +1,12 @@
|
|
1
|
-
module
|
1
|
+
module ApexCharts
|
2
2
|
class DataLabelsOptions < ::SmartKv
|
3
3
|
optional *%i[
|
4
|
-
|
4
|
+
dropShadow
|
5
5
|
enabled
|
6
|
-
|
7
|
-
|
6
|
+
offsetX
|
7
|
+
offsetY
|
8
8
|
style
|
9
|
-
|
9
|
+
textAnchor
|
10
10
|
]
|
11
11
|
end
|
12
12
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
module
|
1
|
+
module ApexCharts
|
2
2
|
class GridOptions < ::SmartKv
|
3
3
|
optional *%i[
|
4
|
-
|
4
|
+
borderColor
|
5
5
|
column
|
6
6
|
padding
|
7
7
|
position
|
8
8
|
row
|
9
9
|
show
|
10
|
-
|
10
|
+
strokeDashArray
|
11
11
|
xaxis
|
12
12
|
yaxis
|
13
13
|
]
|
@@ -1,24 +1,24 @@
|
|
1
|
-
module
|
1
|
+
module ApexCharts
|
2
2
|
class LegendOptions < ::SmartKv
|
3
3
|
optional *%i[
|
4
|
-
|
4
|
+
containerMargin
|
5
5
|
floating
|
6
|
-
|
7
|
-
|
6
|
+
fontFamily
|
7
|
+
fontSize
|
8
8
|
formatter
|
9
|
-
|
10
|
-
|
9
|
+
horizontalAlign
|
10
|
+
itemMargin
|
11
11
|
labels
|
12
12
|
markers
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
offsetX
|
14
|
+
offsetY
|
15
|
+
onItemClick
|
16
|
+
onItemHover
|
17
17
|
position
|
18
18
|
show
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
showForSingleSeries
|
20
|
+
textAnchor
|
21
|
+
verticalAlign
|
22
22
|
]
|
23
23
|
end
|
24
24
|
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
module
|
1
|
+
module ApexCharts
|
2
2
|
class MarkersOptions < ::SmartKv
|
3
3
|
optional *%i[
|
4
4
|
colors
|
5
5
|
discrete
|
6
|
-
|
6
|
+
fillOpacity
|
7
7
|
hover
|
8
|
-
|
9
|
-
|
8
|
+
offsetX
|
9
|
+
offsetY
|
10
10
|
radius
|
11
11
|
shape
|
12
12
|
size
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
strokeColor
|
14
|
+
strokeOpacity
|
15
|
+
strokeWidth
|
16
16
|
]
|
17
17
|
end
|
18
18
|
end
|
@@ -3,23 +3,23 @@ require_relative 'chart'
|
|
3
3
|
require_relative 'stroke'
|
4
4
|
require_relative 'states'
|
5
5
|
|
6
|
-
module
|
6
|
+
module ApexCharts
|
7
7
|
class RootOptions < ::SmartKv
|
8
8
|
optional *%i[
|
9
9
|
annotations
|
10
|
-
|
10
|
+
brushTarget
|
11
11
|
chart
|
12
|
-
|
12
|
+
chartId
|
13
13
|
colors
|
14
|
-
|
14
|
+
dataLabels
|
15
15
|
fill
|
16
16
|
grid
|
17
17
|
group
|
18
18
|
labels
|
19
19
|
legend
|
20
20
|
markers
|
21
|
-
|
22
|
-
|
21
|
+
noData
|
22
|
+
plotOptions
|
23
23
|
responsive
|
24
24
|
series
|
25
25
|
states
|
@@ -1,16 +1,16 @@
|
|
1
|
-
module
|
1
|
+
module ApexCharts
|
2
2
|
class TooltipOptions < ::SmartKv
|
3
3
|
optional *%i[
|
4
4
|
custom
|
5
5
|
enabled
|
6
|
-
|
6
|
+
fillSeriesColor
|
7
7
|
fixed
|
8
|
-
|
8
|
+
followCursor
|
9
9
|
intersect
|
10
|
-
|
10
|
+
inverseOrder
|
11
11
|
items
|
12
12
|
marker
|
13
|
-
|
13
|
+
onDatasetHover
|
14
14
|
shared
|
15
15
|
style
|
16
16
|
theme
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require_relative 'axis'
|
2
2
|
|
3
|
-
module
|
3
|
+
module ApexCharts
|
4
4
|
class YAxisOptions < AxisOptions
|
5
5
|
optional *%i[
|
6
|
-
|
7
|
-
|
6
|
+
decimalsInFloat
|
7
|
+
forceNiceScale
|
8
8
|
logarithmic
|
9
9
|
opposite
|
10
|
-
|
10
|
+
seriesName
|
11
11
|
show
|
12
|
-
|
12
|
+
showAlways
|
13
13
|
]
|
14
14
|
end
|
15
15
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'smart_kv'
|
2
4
|
require_relative 'options/root'
|
3
5
|
require_relative 'options/annotations'
|
@@ -15,7 +17,7 @@ require_relative 'options/tooltip'
|
|
15
17
|
require_relative 'options/x_axis'
|
16
18
|
require_relative 'options/y_axis'
|
17
19
|
|
18
|
-
module
|
20
|
+
module ApexCharts
|
19
21
|
class OptionsBuilder
|
20
22
|
THEME_PALETTES = ["palette1", "palette2", "palette3", "palette4", "palette5",
|
21
23
|
"palette6", "palette7", "palette8", "palette9", "palette10"]
|
@@ -23,8 +25,8 @@ module Apexcharts
|
|
23
25
|
attr_reader :built
|
24
26
|
|
25
27
|
def initialize(x_sample, options)
|
26
|
-
@options = options
|
27
|
-
if options[:
|
28
|
+
@options = Utils::Hash.camelize_keys(options)
|
29
|
+
if options[:plotOptions]&.[](:bar)&.[](:horizontal)
|
28
30
|
@ytype = Utils::DateTime.type(x_sample)
|
29
31
|
else
|
30
32
|
@xtype = Utils::DateTime.type(x_sample)
|
@@ -38,6 +40,7 @@ module Apexcharts
|
|
38
40
|
build_chart
|
39
41
|
build_div
|
40
42
|
build_annotations
|
43
|
+
build_colors
|
41
44
|
build_data_labels
|
42
45
|
build_fill
|
43
46
|
build_grid
|
@@ -75,7 +78,7 @@ module Apexcharts
|
|
75
78
|
end
|
76
79
|
|
77
80
|
def build_chart
|
78
|
-
@built[:chart] = if target = @options.delete(:
|
81
|
+
@built[:chart] = if target = @options.delete(:brushTarget)
|
79
82
|
{
|
80
83
|
brush: {
|
81
84
|
enabled: true,
|
@@ -90,7 +93,7 @@ module Apexcharts
|
|
90
93
|
end
|
91
94
|
|
92
95
|
@built[:chart].merge!({
|
93
|
-
id: @options[:
|
96
|
+
id: @options[:chartId] || @options[:id],
|
94
97
|
group: @options.delete(:group),
|
95
98
|
height: @options.delete(:height) { target ? 180 : 400 },
|
96
99
|
width: @options.delete(:width),
|
@@ -98,9 +101,7 @@ module Apexcharts
|
|
98
101
|
animations: enabled(@options.delete(:animations)),
|
99
102
|
sparkline: enabled(@options.delete(:sparkline)),
|
100
103
|
background: @options.delete(:background),
|
101
|
-
|
102
|
-
@options.delete(:foreColor)
|
103
|
-
end
|
104
|
+
foreColor: @options.delete(:foreColor)
|
104
105
|
}.compact)
|
105
106
|
|
106
107
|
chart = @options.delete :chart
|
@@ -109,12 +110,16 @@ module Apexcharts
|
|
109
110
|
end
|
110
111
|
end
|
111
112
|
|
113
|
+
def build_colors
|
114
|
+
colors = @options.delete :colors
|
115
|
+
colors &&= Array(colors)
|
116
|
+
@built[:colors] = colors
|
117
|
+
end
|
118
|
+
|
112
119
|
def build_data_labels
|
113
|
-
data_labels = @options.delete :
|
114
|
-
@options.delete :dataLabels
|
115
|
-
end
|
120
|
+
data_labels = @options.delete :dataLabels
|
116
121
|
return if data_labels.nil?
|
117
|
-
@built[:
|
122
|
+
@built[:dataLabels] = if [true, false].include? data_labels
|
118
123
|
{enabled: data_labels}
|
119
124
|
elsif data_labels.is_a? Hash
|
120
125
|
DataLabelsOptions.check data_labels.compact
|
@@ -141,12 +146,8 @@ module Apexcharts
|
|
141
146
|
|
142
147
|
def build_labels
|
143
148
|
labels = @options.delete :labels
|
144
|
-
|
145
|
-
|
146
|
-
labels
|
147
|
-
else
|
148
|
-
[labels]
|
149
|
-
end
|
149
|
+
labels &&= Array(labels)
|
150
|
+
@built[:labels] = labels
|
150
151
|
end
|
151
152
|
|
152
153
|
def build_legend
|
@@ -170,8 +171,8 @@ module Apexcharts
|
|
170
171
|
end
|
171
172
|
|
172
173
|
def build_no_data
|
173
|
-
no_data = @options.delete :
|
174
|
-
@built[:
|
174
|
+
no_data = @options.delete :noData
|
175
|
+
@built[:noData] = if no_data.is_a? String
|
175
176
|
{text: no_data}
|
176
177
|
elsif no_data.is_a? Hash
|
177
178
|
NoDataOptions.check no_data.compact
|
@@ -179,22 +180,16 @@ module Apexcharts
|
|
179
180
|
end
|
180
181
|
|
181
182
|
def build_plot_options
|
182
|
-
plot_options = @options.delete :
|
183
|
-
|
184
|
-
end
|
185
|
-
@built[:plot_options] = if plot_options.is_a? Hash
|
183
|
+
plot_options = @options.delete :plotOptions
|
184
|
+
@built[:plotOptions] = if plot_options.is_a? Hash
|
186
185
|
PlotOptions.check plot_options.compact
|
187
186
|
end
|
188
187
|
end
|
189
188
|
|
190
189
|
def build_responsive
|
191
190
|
responsive = @options.delete :responsive
|
192
|
-
|
193
|
-
|
194
|
-
responsive
|
195
|
-
else
|
196
|
-
[responsive]
|
197
|
-
end
|
191
|
+
responsive &&= responsive.is_a?(Hash) ? [responsive] : Array(responsive)
|
192
|
+
@built[:responsive] = responsive
|
198
193
|
end
|
199
194
|
|
200
195
|
def build_states
|
@@ -237,7 +232,7 @@ module Apexcharts
|
|
237
232
|
|
238
233
|
def build_theme
|
239
234
|
theme = @options.delete(:theme)
|
240
|
-
@built[:theme] = if theme.is_a?
|
235
|
+
@built[:theme] = if theme.is_a? String
|
241
236
|
case theme
|
242
237
|
when 'random'
|
243
238
|
{palette: THEME_PALETTES.sample}
|
@@ -246,7 +241,7 @@ module Apexcharts
|
|
246
241
|
else
|
247
242
|
{palette: theme}
|
248
243
|
end
|
249
|
-
elsif theme.is_a?
|
244
|
+
elsif theme.is_a? Hash
|
250
245
|
ThemeOptions.check theme.compact
|
251
246
|
end
|
252
247
|
end
|
@@ -277,6 +272,9 @@ module Apexcharts
|
|
277
272
|
text: @options.delete(:xtitle)
|
278
273
|
}.compact
|
279
274
|
}.compact
|
275
|
+
if @built[:xaxis][:title].empty?
|
276
|
+
@built[:xaxis].delete(:title)
|
277
|
+
end
|
280
278
|
|
281
279
|
if xaxis.is_a? String
|
282
280
|
@built[:xaxis][:title] = {text: xaxis}
|
@@ -294,6 +292,9 @@ module Apexcharts
|
|
294
292
|
text: @options.delete(:ytitle)
|
295
293
|
}.compact
|
296
294
|
}.compact]
|
295
|
+
if @built[:yaxis][0][:title].empty?
|
296
|
+
@built[:yaxis][0].delete(:title)
|
297
|
+
end
|
297
298
|
|
298
299
|
if yaxis.is_a? String
|
299
300
|
@built[:yaxis][0][:title] = {text: yaxis}
|