apexcharts 0.1.5 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +456 -38
- 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/apex_charts/charts/base_chart.rb +37 -0
- data/lib/apex_charts/charts/bubble_chart.rb +13 -0
- data/lib/{apexcharts/charts/candlestick.rb → apex_charts/charts/candlestick_chart.rb} +1 -1
- data/lib/apex_charts/charts/cartesian_chart.rb +82 -0
- 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 -2
- data/lib/{apexcharts → apex_charts}/charts/features/annotations.rb +22 -21
- data/lib/{apexcharts → apex_charts}/charts/features/mixable.rb +2 -3
- data/lib/{apexcharts/charts/heatmap.rb → apex_charts/charts/heatmap_chart.rb} +3 -5
- data/lib/{apexcharts/charts/line.rb → apex_charts/charts/line_chart.rb} +1 -1
- data/lib/apex_charts/charts/mixed_charts.rb +101 -0
- data/lib/{apexcharts/charts/pie.rb → apex_charts/charts/pie_chart.rb} +1 -2
- data/lib/apex_charts/charts/polar_chart.rb +9 -0
- data/lib/{apexcharts/charts/radar.rb → apex_charts/charts/radar_chart.rb} +3 -5
- data/lib/{apexcharts/charts/radial_bar.rb → apex_charts/charts/radial_bar_chart.rb} +1 -2
- data/lib/apex_charts/charts/range_bar_chart.rb +9 -0
- data/lib/{apexcharts/charts/scatter.rb → apex_charts/charts/scatter_chart.rb} +1 -1
- data/lib/apex_charts/charts/syncing_charts.rb +84 -0
- data/lib/apex_charts/colors.rb +27 -0
- data/lib/apex_charts/config/default_options.rb +16 -0
- data/lib/apex_charts/configuration.rb +25 -0
- data/lib/apex_charts/helper.rb +190 -0
- data/lib/apex_charts/options/annotations_options.rb +15 -0
- data/lib/apex_charts/options/chart_options.rb +32 -0
- data/lib/apex_charts/options/data_labels_options.rb +18 -0
- data/lib/apex_charts/options/div_attributes.rb +11 -0
- data/lib/apex_charts/options/fill_options.rb +14 -0
- data/lib/apex_charts/options/grid_options.rb +17 -0
- data/lib/apex_charts/options/legend_options.rb +32 -0
- data/lib/apex_charts/options/markers_options.rb +24 -0
- data/lib/apex_charts/options/no_data_options.rb +14 -0
- data/lib/apex_charts/options/plot_options.rb +16 -0
- data/lib/apex_charts/options/root_options.rb +47 -0
- data/lib/apex_charts/options/states_options.rb +11 -0
- data/lib/apex_charts/options/stroke_options.rb +14 -0
- data/lib/apex_charts/options/theme_options.rb +11 -0
- data/lib/apex_charts/options/title_subtitle_options.rb +15 -0
- data/lib/apex_charts/options/tooltip_options.rb +25 -0
- data/lib/apex_charts/options/x_axis_options.rb +26 -0
- data/lib/apex_charts/options/y_axis_options.rb +28 -0
- data/lib/{apexcharts → apex_charts}/options_builder.rb +95 -90
- data/lib/apex_charts/prefix_with_apex.rb +7 -0
- data/lib/apex_charts/prefixer.rb +21 -0
- data/lib/apex_charts/renderer.rb +113 -0
- data/lib/apex_charts/series.rb +7 -0
- data/lib/apex_charts/series/bubble_series.rb +50 -0
- data/lib/apex_charts/series/cartesian_series.rb +81 -0
- data/lib/apex_charts/series/polar_series.rb +48 -0
- data/lib/{apexcharts → apex_charts}/support/rails.rb +1 -1
- data/lib/apex_charts/support/sinatra.rb +9 -0
- data/lib/apex_charts/theme.rb +60 -0
- data/lib/{apexcharts → apex_charts}/utils.rb +1 -0
- data/lib/apex_charts/utils/copy.rb +11 -0
- data/lib/apex_charts/utils/date_time.rb +70 -0
- data/lib/{apexcharts → apex_charts}/utils/hash.rb +4 -3
- data/lib/{apexcharts → apex_charts}/version.rb +2 -1
- data/lib/apexcharts.rb +3 -2
- data/vendor/assets/javascripts/apexcharts.js +11 -3
- metadata +85 -65
- data/lib/apexcharts/charts.rb +0 -19
- data/lib/apexcharts/charts/base.rb +0 -34
- data/lib/apexcharts/charts/bubble.rb +0 -19
- data/lib/apexcharts/charts/cartesian.rb +0 -81
- data/lib/apexcharts/charts/mixed.rb +0 -85
- data/lib/apexcharts/charts/polar.rb +0 -14
- data/lib/apexcharts/charts/syncing.rb +0 -70
- data/lib/apexcharts/helper.rb +0 -109
- data/lib/apexcharts/options/annotations.rb +0 -10
- data/lib/apexcharts/options/axis.rb +0 -17
- data/lib/apexcharts/options/chart.rb +0 -26
- data/lib/apexcharts/options/data_labels.rb +0 -12
- data/lib/apexcharts/options/div_attributes.rb +0 -10
- data/lib/apexcharts/options/fill.rb +0 -12
- data/lib/apexcharts/options/grid.rb +0 -15
- data/lib/apexcharts/options/legend.rb +0 -24
- data/lib/apexcharts/options/markers.rb +0 -18
- data/lib/apexcharts/options/no_data.rb +0 -12
- data/lib/apexcharts/options/plot_options.rb +0 -12
- data/lib/apexcharts/options/root.rb +0 -42
- data/lib/apexcharts/options/states.rb +0 -9
- data/lib/apexcharts/options/stroke.rb +0 -12
- data/lib/apexcharts/options/subtitle.rb +0 -7
- data/lib/apexcharts/options/theme.rb +0 -8
- data/lib/apexcharts/options/title.rb +0 -13
- data/lib/apexcharts/options/tooltip.rb +0 -22
- data/lib/apexcharts/options/x_axis.rb +0 -12
- data/lib/apexcharts/options/y_axis.rb +0 -15
- data/lib/apexcharts/renderer.rb +0 -21
- data/lib/apexcharts/series.rb +0 -5
- data/lib/apexcharts/series/bubble.rb +0 -37
- data/lib/apexcharts/series/cartesian.rb +0 -65
- data/lib/apexcharts/series/polar.rb +0 -32
- data/lib/apexcharts/utils/date_time.rb +0 -59
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ApexCharts::Options
|
4
|
+
class DataLabelsOptions < ::SmartKv
|
5
|
+
optional *%i[
|
6
|
+
background
|
7
|
+
distributed
|
8
|
+
dropShadow
|
9
|
+
enabled
|
10
|
+
enabledOnSeries
|
11
|
+
formatter
|
12
|
+
offsetX
|
13
|
+
offsetY
|
14
|
+
style
|
15
|
+
textAnchor
|
16
|
+
]
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ApexCharts::Options
|
4
|
+
class LegendOptions < ::SmartKv
|
5
|
+
optional *%i[
|
6
|
+
containerMargin
|
7
|
+
floating
|
8
|
+
fontFamily
|
9
|
+
fontSize
|
10
|
+
fontWeight
|
11
|
+
formatter
|
12
|
+
height
|
13
|
+
horizontalAlign
|
14
|
+
inverseOrder
|
15
|
+
itemMargin
|
16
|
+
labels
|
17
|
+
markers
|
18
|
+
offsetX
|
19
|
+
offsetY
|
20
|
+
onItemClick
|
21
|
+
onItemHover
|
22
|
+
position
|
23
|
+
show
|
24
|
+
showForNullSeries
|
25
|
+
showForSingleSeries
|
26
|
+
showForZeroSeries
|
27
|
+
textAnchor
|
28
|
+
tooltipHoverFormatter
|
29
|
+
width
|
30
|
+
]
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ApexCharts::Options
|
4
|
+
class MarkersOptions < ::SmartKv
|
5
|
+
optional *%i[
|
6
|
+
colors
|
7
|
+
discrete
|
8
|
+
fillOpacity
|
9
|
+
hover
|
10
|
+
offsetX
|
11
|
+
offsetY
|
12
|
+
radius
|
13
|
+
shape
|
14
|
+
size
|
15
|
+
strokeColors
|
16
|
+
strokeOpacity
|
17
|
+
strokeWidth
|
18
|
+
strokeDashArray
|
19
|
+
showNullDataPoints
|
20
|
+
onClick
|
21
|
+
onDblClick
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'div_attributes'
|
4
|
+
require_relative 'chart_options'
|
5
|
+
require_relative 'stroke_options'
|
6
|
+
require_relative 'states_options'
|
7
|
+
|
8
|
+
module ApexCharts::Options
|
9
|
+
class RootOptions < ::SmartKv
|
10
|
+
optional *%i[
|
11
|
+
annotations
|
12
|
+
brushTarget
|
13
|
+
chart
|
14
|
+
chartId
|
15
|
+
colors
|
16
|
+
dataLabels
|
17
|
+
defer
|
18
|
+
fill
|
19
|
+
grid
|
20
|
+
group
|
21
|
+
labels
|
22
|
+
legend
|
23
|
+
markers
|
24
|
+
noData
|
25
|
+
plotOptions
|
26
|
+
responsive
|
27
|
+
series
|
28
|
+
states
|
29
|
+
stroke
|
30
|
+
subtitle
|
31
|
+
theme
|
32
|
+
title
|
33
|
+
tooltip
|
34
|
+
var
|
35
|
+
xaxis
|
36
|
+
xtitle
|
37
|
+
xtype
|
38
|
+
yaxis
|
39
|
+
ytitle
|
40
|
+
ytype
|
41
|
+
],
|
42
|
+
*DivAttributes.optional_keys,
|
43
|
+
*ChartOptions.optional_keys,
|
44
|
+
*StrokeOptions.optional_keys,
|
45
|
+
*StatesOptions.optional_keys
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ApexCharts::Options
|
4
|
+
class TooltipOptions < ::SmartKv
|
5
|
+
optional *%i[
|
6
|
+
custom
|
7
|
+
enabled
|
8
|
+
enabledOnSeries
|
9
|
+
fillSeriesColor
|
10
|
+
fixed
|
11
|
+
followCursor
|
12
|
+
intersect
|
13
|
+
inverseOrder
|
14
|
+
items
|
15
|
+
marker
|
16
|
+
onDatasetHover
|
17
|
+
shared
|
18
|
+
style
|
19
|
+
theme
|
20
|
+
x
|
21
|
+
y
|
22
|
+
z
|
23
|
+
]
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ApexCharts::Options
|
4
|
+
class XAxisOptions < ::SmartKv
|
5
|
+
optional *%i[
|
6
|
+
axisBorder
|
7
|
+
axisTicks
|
8
|
+
categories
|
9
|
+
crosshairs
|
10
|
+
floating
|
11
|
+
labels
|
12
|
+
max
|
13
|
+
min
|
14
|
+
position
|
15
|
+
range
|
16
|
+
tickAmount
|
17
|
+
tickPlacement
|
18
|
+
title
|
19
|
+
tooltip
|
20
|
+
type
|
21
|
+
offsetX
|
22
|
+
offsetY
|
23
|
+
sorted
|
24
|
+
]
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ApexCharts::Options
|
4
|
+
class YAxisOptions < ::SmartKv
|
5
|
+
optional *%i[
|
6
|
+
axisBorder
|
7
|
+
axisTicks
|
8
|
+
crosshairs
|
9
|
+
decimalsInFloat
|
10
|
+
floating
|
11
|
+
forceNiceScale
|
12
|
+
labels
|
13
|
+
logarithmic
|
14
|
+
max
|
15
|
+
min
|
16
|
+
opposite
|
17
|
+
reversed
|
18
|
+
seriesName
|
19
|
+
show
|
20
|
+
showAlways
|
21
|
+
showForNullSeries
|
22
|
+
tickAmount
|
23
|
+
title
|
24
|
+
tooltip
|
25
|
+
type
|
26
|
+
]
|
27
|
+
end
|
28
|
+
end
|
@@ -1,47 +1,52 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'smart_kv'
|
4
|
-
require_relative 'options/
|
5
|
-
require_relative 'options/
|
6
|
-
require_relative 'options/
|
7
|
-
require_relative 'options/
|
8
|
-
require_relative 'options/
|
9
|
-
require_relative 'options/
|
10
|
-
require_relative 'options/
|
11
|
-
require_relative 'options/
|
4
|
+
require_relative 'options/root_options'
|
5
|
+
require_relative 'options/annotations_options'
|
6
|
+
require_relative 'options/data_labels_options'
|
7
|
+
require_relative 'options/fill_options'
|
8
|
+
require_relative 'options/grid_options'
|
9
|
+
require_relative 'options/legend_options'
|
10
|
+
require_relative 'options/markers_options'
|
11
|
+
require_relative 'options/no_data_options'
|
12
12
|
require_relative 'options/plot_options'
|
13
|
-
require_relative 'options/
|
14
|
-
require_relative 'options/
|
15
|
-
require_relative 'options/
|
16
|
-
require_relative 'options/
|
17
|
-
require_relative 'options/
|
18
|
-
require_relative 'options/
|
13
|
+
require_relative 'options/states_options'
|
14
|
+
require_relative 'options/title_subtitle_options'
|
15
|
+
require_relative 'options/theme_options'
|
16
|
+
require_relative 'options/tooltip_options'
|
17
|
+
require_relative 'options/x_axis_options'
|
18
|
+
require_relative 'options/y_axis_options'
|
19
19
|
|
20
20
|
module ApexCharts
|
21
21
|
class OptionsBuilder
|
22
|
-
|
23
|
-
|
22
|
+
include ApexCharts::Utils::Hash
|
23
|
+
include ApexCharts::Utils::DateTime
|
24
24
|
|
25
25
|
attr_reader :built
|
26
26
|
|
27
|
-
def initialize(
|
28
|
-
@options =
|
27
|
+
def initialize(sample, options)
|
28
|
+
@options = camelize_keys(options)
|
29
29
|
if options[:plotOptions]&.[](:bar)&.[](:horizontal)
|
30
|
-
@ytype =
|
30
|
+
@ytype = type(sample)
|
31
31
|
else
|
32
|
-
@xtype =
|
32
|
+
@xtype = type(sample)
|
33
33
|
end
|
34
34
|
@built = {}
|
35
35
|
end
|
36
36
|
|
37
37
|
def build_options
|
38
|
-
RootOptions.check @options
|
38
|
+
Options::RootOptions.check @options
|
39
39
|
|
40
40
|
build_chart
|
41
41
|
build_div
|
42
|
+
build_general_options
|
43
|
+
end
|
44
|
+
|
45
|
+
def build_general_options
|
42
46
|
build_annotations
|
43
47
|
build_colors
|
44
48
|
build_data_labels
|
49
|
+
build_defer
|
45
50
|
build_fill
|
46
51
|
build_grid
|
47
52
|
build_labels
|
@@ -72,25 +77,18 @@ module ApexCharts
|
|
72
77
|
|
73
78
|
def build_annotations
|
74
79
|
annotations = @options.delete :annotations
|
75
|
-
@built[:annotations] =
|
76
|
-
|
77
|
-
|
80
|
+
@built[:annotations] = (
|
81
|
+
Options::AnnotationsOptions.check annotations.compact if annotations.is_a? Hash
|
82
|
+
)
|
78
83
|
end
|
79
84
|
|
80
85
|
def build_chart
|
81
|
-
@built[:chart] =
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
selection: {
|
88
|
-
enabled: true
|
89
|
-
}
|
90
|
-
}
|
91
|
-
else
|
92
|
-
{}
|
93
|
-
end
|
86
|
+
@built[:chart] =
|
87
|
+
if target = @options.delete(:brushTarget)
|
88
|
+
{brush: {enabled: true, target: target.to_s}, selection: {enabled: true}}
|
89
|
+
else
|
90
|
+
{}
|
91
|
+
end
|
94
92
|
|
95
93
|
@built[:chart].merge!({
|
96
94
|
id: @options[:chartId] || @options[:id],
|
@@ -105,9 +103,10 @@ module ApexCharts
|
|
105
103
|
}.compact)
|
106
104
|
|
107
105
|
chart = @options.delete :chart
|
108
|
-
|
109
|
-
|
110
|
-
|
106
|
+
|
107
|
+
return unless chart.is_a? Hash
|
108
|
+
|
109
|
+
@built[:chart].merge! Options::ChartOptions.check(chart.compact)
|
111
110
|
end
|
112
111
|
|
113
112
|
def build_colors
|
@@ -119,19 +118,26 @@ module ApexCharts
|
|
119
118
|
def build_data_labels
|
120
119
|
data_labels = @options.delete :dataLabels
|
121
120
|
return if data_labels.nil?
|
121
|
+
|
122
122
|
@built[:dataLabels] = if [true, false].include? data_labels
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
123
|
+
{enabled: data_labels}
|
124
|
+
elsif data_labels.is_a? Hash
|
125
|
+
Options::DataLabelsOptions.check data_labels.compact
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def build_defer
|
130
|
+
defer = @options.delete :defer
|
131
|
+
@built[:defer] = defer == true
|
127
132
|
end
|
128
133
|
|
134
|
+
|
129
135
|
def build_fill
|
130
136
|
fill = @options.delete :fill
|
131
137
|
@built[:fill] = if fill.is_a? String
|
132
138
|
{type: fill}
|
133
139
|
elsif fill.is_a? Hash
|
134
|
-
FillOptions.check fill.compact
|
140
|
+
Options::FillOptions.check fill.compact
|
135
141
|
end
|
136
142
|
end
|
137
143
|
|
@@ -140,7 +146,7 @@ module ApexCharts
|
|
140
146
|
@built[:grid] = if [true, false].include? grid
|
141
147
|
{show: grid}
|
142
148
|
elsif grid.is_a? Hash
|
143
|
-
GridOptions.check grid.compact
|
149
|
+
Options::GridOptions.check grid.compact
|
144
150
|
end
|
145
151
|
end
|
146
152
|
|
@@ -157,7 +163,7 @@ module ApexCharts
|
|
157
163
|
elsif legend.is_a? String
|
158
164
|
{show: true, position: legend}
|
159
165
|
elsif legend.is_a? Hash
|
160
|
-
LegendOptions.check legend.compact
|
166
|
+
Options::LegendOptions.check legend.compact
|
161
167
|
end
|
162
168
|
end
|
163
169
|
|
@@ -166,24 +172,25 @@ module ApexCharts
|
|
166
172
|
@built[:markers] = if markers.is_a? String
|
167
173
|
{shape: markers}
|
168
174
|
elsif markers.is_a? Hash
|
169
|
-
MarkersOptions.check markers.compact
|
175
|
+
Options::MarkersOptions.check markers.compact
|
170
176
|
end
|
171
177
|
end
|
172
178
|
|
173
179
|
def build_no_data
|
174
180
|
no_data = @options.delete :noData
|
175
181
|
@built[:noData] = if no_data.is_a? String
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
182
|
+
{text: no_data}
|
183
|
+
elsif no_data.is_a? Hash
|
184
|
+
Options::NoDataOptions.check no_data.compact
|
185
|
+
end
|
180
186
|
end
|
181
187
|
|
182
188
|
def build_plot_options
|
183
189
|
plot_options = @options.delete :plotOptions
|
184
|
-
|
185
|
-
|
186
|
-
|
190
|
+
return unless plot_options.is_a? Hash
|
191
|
+
|
192
|
+
@built[:plotOptions] =
|
193
|
+
Options::PlotOptions.check plot_options.compact
|
187
194
|
end
|
188
195
|
|
189
196
|
def build_responsive
|
@@ -194,15 +201,13 @@ module ApexCharts
|
|
194
201
|
|
195
202
|
def build_states
|
196
203
|
@built[:states] = {
|
197
|
-
normal: filter_type_hash(@options.delete
|
198
|
-
hover: filter_type_hash(@options.delete
|
199
|
-
active: filter_type_hash(@options.delete
|
204
|
+
normal: filter_type_hash(@options.delete(:normal)),
|
205
|
+
hover: filter_type_hash(@options.delete(:hover)),
|
206
|
+
active: filter_type_hash(@options.delete(:active))
|
200
207
|
}.compact
|
201
208
|
|
202
209
|
states = @options.delete :states
|
203
|
-
if states.is_a? Hash
|
204
|
-
@built[:states].merge! StatesOptions.check(states.compact)
|
205
|
-
end
|
210
|
+
@built[:states].merge! Options::StatesOptions.check(states.compact) if states.is_a? Hash
|
206
211
|
|
207
212
|
@built[:states] = nil if @built[:states].empty?
|
208
213
|
end
|
@@ -213,9 +218,9 @@ module ApexCharts
|
|
213
218
|
|
214
219
|
stroke = @options.delete :stroke
|
215
220
|
if [true, false].include? stroke
|
216
|
-
@built[:stroke].merge!(
|
221
|
+
@built[:stroke].merge!(show: stroke)
|
217
222
|
elsif stroke.is_a? Hash
|
218
|
-
@built[:stroke].merge! StrokeOptions.check(stroke.compact)
|
223
|
+
@built[:stroke].merge! Options::StrokeOptions.check(stroke.compact)
|
219
224
|
end
|
220
225
|
|
221
226
|
@built[:stroke] = nil if @built[:stroke].empty?
|
@@ -226,7 +231,7 @@ module ApexCharts
|
|
226
231
|
@built[:subtitle] = if subtitle.is_a? String
|
227
232
|
{text: subtitle}
|
228
233
|
elsif subtitle.is_a? Hash
|
229
|
-
|
234
|
+
Options::TitleSubtitleOptions.check subtitle.compact
|
230
235
|
end
|
231
236
|
end
|
232
237
|
|
@@ -235,14 +240,14 @@ module ApexCharts
|
|
235
240
|
@built[:theme] = if theme.is_a? String
|
236
241
|
case theme
|
237
242
|
when 'random'
|
238
|
-
|
243
|
+
resolve_theme(Theme::Local.all_palettes.sample)
|
239
244
|
when 'monochrome'
|
240
245
|
{monochrome: {enabled: true}}
|
241
246
|
else
|
242
|
-
|
247
|
+
resolve_theme(theme)
|
243
248
|
end
|
244
249
|
elsif theme.is_a? Hash
|
245
|
-
ThemeOptions.check theme.compact
|
250
|
+
Options::ThemeOptions.check theme.compact
|
246
251
|
end
|
247
252
|
end
|
248
253
|
|
@@ -251,7 +256,7 @@ module ApexCharts
|
|
251
256
|
@built[:title] = if title.is_a? String
|
252
257
|
{text: title}
|
253
258
|
elsif title.is_a? Hash
|
254
|
-
|
259
|
+
Options::TitleSubtitleOptions.check title.compact
|
255
260
|
end
|
256
261
|
end
|
257
262
|
|
@@ -260,68 +265,59 @@ module ApexCharts
|
|
260
265
|
@built[:tooltip] = if [true, false].include? tooltip
|
261
266
|
{enabled: tooltip}
|
262
267
|
elsif tooltip.is_a? Hash
|
263
|
-
TooltipOptions.check tooltip.compact
|
268
|
+
Options::TooltipOptions.check tooltip.compact
|
264
269
|
end
|
265
270
|
end
|
266
271
|
|
267
272
|
def build_xaxis
|
268
273
|
xaxis = @options.delete :xaxis
|
269
274
|
@built[:xaxis] = {
|
270
|
-
type: @options.delete(:xtype){ @xtype },
|
275
|
+
type: @options.delete(:xtype) { @xtype },
|
271
276
|
title: {
|
272
277
|
text: @options.delete(:xtitle)
|
273
278
|
}.compact
|
274
279
|
}.compact
|
275
|
-
if @built[:xaxis][:title].empty?
|
276
|
-
@built[:xaxis].delete(:title)
|
277
|
-
end
|
280
|
+
@built[:xaxis].delete(:title) if @built[:xaxis][:title].empty?
|
278
281
|
|
279
282
|
if xaxis.is_a? String
|
280
283
|
@built[:xaxis][:title] = {text: xaxis}
|
281
284
|
elsif xaxis.is_a? Hash
|
282
|
-
XAxisOptions.check xaxis
|
285
|
+
Options::XAxisOptions.check xaxis
|
283
286
|
@built[:xaxis].merge! xaxis
|
284
287
|
end
|
288
|
+
|
289
|
+
@built[:xaxis] = nil if @built[:xaxis].empty?
|
285
290
|
end
|
286
291
|
|
287
292
|
def build_yaxis
|
288
293
|
yaxis = @options.delete :yaxis
|
289
294
|
@built[:yaxis] = [{
|
290
|
-
type: @options.delete(:ytype){ @ytype },
|
295
|
+
type: @options.delete(:ytype) { @ytype },
|
291
296
|
title: {
|
292
297
|
text: @options.delete(:ytitle)
|
293
298
|
}.compact
|
294
299
|
}.compact]
|
295
|
-
if @built[:yaxis][0][:title].empty?
|
296
|
-
@built[:yaxis][0].delete(:title)
|
297
|
-
end
|
300
|
+
@built[:yaxis][0].delete(:title) if @built[:yaxis][0][:title].empty?
|
298
301
|
|
299
302
|
if yaxis.is_a? String
|
300
303
|
@built[:yaxis][0][:title] = {text: yaxis}
|
301
304
|
elsif yaxis.is_a? Hash
|
302
|
-
YAxisOptions.check yaxis
|
305
|
+
Options::YAxisOptions.check yaxis
|
303
306
|
@built[:yaxis][0].merge! yaxis
|
304
307
|
end
|
305
|
-
end
|
306
308
|
|
307
|
-
|
308
|
-
if DateTime.iso8601(x).iso8601 == x
|
309
|
-
'datetime'
|
310
|
-
elsif Date.iso8601(x).iso8601 = x
|
311
|
-
'datetime'
|
312
|
-
end
|
313
|
-
rescue
|
314
|
-
'number'
|
309
|
+
@built[:yaxis] = nil if @built[:yaxis].all?(&:empty?)
|
315
310
|
end
|
316
311
|
|
317
312
|
def enabled(options)
|
318
|
-
boolean_to_hash(options) do |
|
319
|
-
{enabled:
|
313
|
+
boolean_to_hash(options) do |opts|
|
314
|
+
{enabled: opts}
|
320
315
|
end
|
321
316
|
end
|
322
317
|
|
323
318
|
def boolean_to_hash(options)
|
324
319
|
return if options.nil?
|
320
|
+
|
325
321
|
if [true, false].include? options
|
326
322
|
yield(options)
|
327
323
|
elsif options.is_a?(Hash)
|
@@ -336,5 +332,14 @@ module ApexCharts
|
|
336
332
|
state.compact
|
337
333
|
end
|
338
334
|
end
|
335
|
+
|
336
|
+
def resolve_theme(theme)
|
337
|
+
if Theme::PALETTES.include? theme
|
338
|
+
{palette: theme}
|
339
|
+
elsif Theme::Local.palette_names.include? theme
|
340
|
+
@built[:colors] = Theme::Local.get_colors(theme)
|
341
|
+
nil
|
342
|
+
end
|
343
|
+
end
|
339
344
|
end
|
340
345
|
end
|