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
@@ -1,70 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ApexCharts
|
4
|
-
class SyncingCharts
|
5
|
-
def initialize bindings, options={}, &block
|
6
|
-
@bindings = bindings
|
7
|
-
@html = ""
|
8
|
-
build_instance_variables
|
9
|
-
@options = options
|
10
|
-
@options[:group] ||= apexcharts_group
|
11
|
-
|
12
|
-
instance_eval &block
|
13
|
-
|
14
|
-
@options[:annotations] = @annotations if @annotations
|
15
|
-
end
|
16
|
-
|
17
|
-
def line_chart data, options={}, &block
|
18
|
-
options[:id] = apexcharts_id
|
19
|
-
bindings = eval("self", block.binding) if block_given?
|
20
|
-
@html += LineChart.new(bindings, data, @options.merge(options), &block).render
|
21
|
-
end
|
22
|
-
|
23
|
-
def area_chart data, options={}, &block
|
24
|
-
options[:id] = apexcharts_id
|
25
|
-
bindings = eval("self", block.binding) if block_given?
|
26
|
-
@html += AreaChart.new(bindings, data, @options.merge(options), &block).render
|
27
|
-
end
|
28
|
-
|
29
|
-
def bar_chart data, options={}, &block
|
30
|
-
options[:id] = apexcharts_id
|
31
|
-
bindings = eval("self", block.binding) if block_given?
|
32
|
-
@html += BarChart.new(bindings, data, @options.merge(options), &block).render
|
33
|
-
end
|
34
|
-
|
35
|
-
def column_chart data, options={}, &block
|
36
|
-
options[:id] = apexcharts_id
|
37
|
-
bindings = eval("self", block.binding) if block_given?
|
38
|
-
@html += ColumnChart.new(bindings, data, @options.merge(options), &block).render
|
39
|
-
end
|
40
|
-
|
41
|
-
def scatter_chart data, options={}, &block
|
42
|
-
options[:id] = apexcharts_id
|
43
|
-
bindings = eval("self", block.binding) if block_given?
|
44
|
-
@html += ScatterChart.new(bindings, data, @options.merge(options), &block).render
|
45
|
-
end
|
46
|
-
|
47
|
-
def mixed_charts options={}, &block
|
48
|
-
options[:id] = apexcharts_id
|
49
|
-
bindings = eval "self", block.binding
|
50
|
-
@html += MixedCharts.new(bindings, @options.merge(options), &block).render
|
51
|
-
end
|
52
|
-
alias_method :combo_charts, :mixed_charts
|
53
|
-
|
54
|
-
def render
|
55
|
-
@html
|
56
|
-
end
|
57
|
-
|
58
|
-
def method_missing method, *args, &block
|
59
|
-
@bindings.send method, *args, &block
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
|
-
def build_instance_variables
|
65
|
-
(@bindings.instance_variables - instance_variables).each do |i|
|
66
|
-
instance_variable_set(i, @bindings.instance_variable_get(i))
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
data/lib/apexcharts/helper.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'series'
|
4
|
-
require_relative 'options_builder'
|
5
|
-
require_relative 'utils'
|
6
|
-
require_relative 'renderer'
|
7
|
-
require_relative 'charts'
|
8
|
-
|
9
|
-
module ApexCharts
|
10
|
-
module Helper
|
11
|
-
def line_chart series, options={}, &block
|
12
|
-
bindings = eval("self", block.binding) if block_given?
|
13
|
-
draw_chart(LineChart.new(bindings, *prepare_series_and_options(series, options), &block))
|
14
|
-
end
|
15
|
-
|
16
|
-
def area_chart series, options={}, &block
|
17
|
-
bindings = eval("self", block.binding) if block_given?
|
18
|
-
draw_chart(AreaChart.new(bindings, *prepare_series_and_options(series, options), &block))
|
19
|
-
end
|
20
|
-
|
21
|
-
def column_chart series, options={}, &block
|
22
|
-
bindings = eval("self", block.binding) if block_given?
|
23
|
-
draw_chart(ColumnChart.new(bindings, *prepare_series_and_options(series, options), &block))
|
24
|
-
end
|
25
|
-
|
26
|
-
def bar_chart series, options={}, &block
|
27
|
-
bindings = eval("self", block.binding) if block_given?
|
28
|
-
draw_chart(BarChart.new(bindings, *prepare_series_and_options(series, options), &block))
|
29
|
-
end
|
30
|
-
|
31
|
-
def scatter_chart series, options={}, &block
|
32
|
-
bindings = eval("self", block.binding) if block_given?
|
33
|
-
draw_chart(ScatterChart.new(bindings, *prepare_series_and_options(series, options), &block))
|
34
|
-
end
|
35
|
-
|
36
|
-
def candlestick_chart series, options={}, &block
|
37
|
-
bindings = eval("self", block.binding) if block_given?
|
38
|
-
draw_chart(CandlestickChart.new(bindings, *prepare_series_and_options(series, options), &block))
|
39
|
-
end
|
40
|
-
alias_method :ohlc_chart, :candlestick_chart
|
41
|
-
|
42
|
-
def heatmap_chart series, options={}
|
43
|
-
draw_chart(HeatmapChart.new(*prepare_series_and_options(series, options)))
|
44
|
-
end
|
45
|
-
|
46
|
-
def bubble_chart series, options={}
|
47
|
-
draw_chart(BubbleChart.new(*prepare_series_and_options(series, options)))
|
48
|
-
end
|
49
|
-
|
50
|
-
def radar_chart series, options={}
|
51
|
-
draw_chart(RadarChart.new(*prepare_series_and_options(series, options)))
|
52
|
-
end
|
53
|
-
|
54
|
-
def mixed_charts options={}, &block
|
55
|
-
bindings = eval("self", block.binding)
|
56
|
-
draw_chart(MixedCharts.new(bindings, deep_copy(options), &block))
|
57
|
-
end
|
58
|
-
alias_method :combo_charts, :mixed_charts
|
59
|
-
|
60
|
-
def syncing_charts options={}, &block
|
61
|
-
bindings = eval("self", block.binding)
|
62
|
-
draw_chart(SyncingCharts.new(bindings, deep_copy(options), &block))
|
63
|
-
end
|
64
|
-
alias_method :synchronized_charts, :syncing_charts
|
65
|
-
|
66
|
-
def pie_chart series, options={}
|
67
|
-
draw_chart(PieChart.new(*prepare_series_and_options(series, options)))
|
68
|
-
end
|
69
|
-
|
70
|
-
def donut_chart series, options={}
|
71
|
-
draw_chart(DonutChart.new(*prepare_series_and_options(series, options)))
|
72
|
-
end
|
73
|
-
|
74
|
-
def radial_bar_chart series, options={}
|
75
|
-
draw_chart(RadialBarChart.new(*prepare_series_and_options(series, options)))
|
76
|
-
end
|
77
|
-
alias_method :circle_chart, :radial_bar_chart
|
78
|
-
|
79
|
-
private
|
80
|
-
|
81
|
-
def draw_chart chart
|
82
|
-
chart = chart.render
|
83
|
-
chart.respond_to?(:html_safe) ? chart.html_safe : chart
|
84
|
-
end
|
85
|
-
|
86
|
-
def prepare_series_and_options series, options
|
87
|
-
series = deep_copy(series)
|
88
|
-
options = deep_copy(options)
|
89
|
-
options[:id] ||= apexcharts_id
|
90
|
-
[series, options]
|
91
|
-
end
|
92
|
-
|
93
|
-
def apexcharts_id
|
94
|
-
@_apexcharts_id ||= 0
|
95
|
-
@_apexcharts_id += 1
|
96
|
-
"chart-#{@_apexcharts_id}"
|
97
|
-
end
|
98
|
-
|
99
|
-
def apexcharts_group
|
100
|
-
@_apexcharts_group ||= 0
|
101
|
-
@_apexcharts_group += 1
|
102
|
-
"chart-group-#{@_apexcharts_group}"
|
103
|
-
end
|
104
|
-
|
105
|
-
def deep_copy(options)
|
106
|
-
Marshal.load(Marshal.dump(options))
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module ApexCharts
|
2
|
-
class ChartOptions < ::SmartKv
|
3
|
-
optional *%i[
|
4
|
-
animations
|
5
|
-
background
|
6
|
-
brush
|
7
|
-
defaultLocale
|
8
|
-
dropShadow
|
9
|
-
events
|
10
|
-
fontFamily
|
11
|
-
foreColor
|
12
|
-
height
|
13
|
-
id
|
14
|
-
locales
|
15
|
-
parentHeightOffset
|
16
|
-
selection
|
17
|
-
sparkline
|
18
|
-
stackType
|
19
|
-
stacked
|
20
|
-
toolbar
|
21
|
-
type
|
22
|
-
width
|
23
|
-
zoom
|
24
|
-
]
|
25
|
-
end
|
26
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module ApexCharts
|
2
|
-
class LegendOptions < ::SmartKv
|
3
|
-
optional *%i[
|
4
|
-
containerMargin
|
5
|
-
floating
|
6
|
-
fontFamily
|
7
|
-
fontSize
|
8
|
-
formatter
|
9
|
-
horizontalAlign
|
10
|
-
itemMargin
|
11
|
-
labels
|
12
|
-
markers
|
13
|
-
offsetX
|
14
|
-
offsetY
|
15
|
-
onItemClick
|
16
|
-
onItemHover
|
17
|
-
position
|
18
|
-
show
|
19
|
-
showForSingleSeries
|
20
|
-
textAnchor
|
21
|
-
verticalAlign
|
22
|
-
]
|
23
|
-
end
|
24
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require_relative 'div_attributes'
|
2
|
-
require_relative 'chart'
|
3
|
-
require_relative 'stroke'
|
4
|
-
require_relative 'states'
|
5
|
-
|
6
|
-
module ApexCharts
|
7
|
-
class RootOptions < ::SmartKv
|
8
|
-
optional *%i[
|
9
|
-
annotations
|
10
|
-
brushTarget
|
11
|
-
chart
|
12
|
-
chartId
|
13
|
-
colors
|
14
|
-
dataLabels
|
15
|
-
fill
|
16
|
-
grid
|
17
|
-
group
|
18
|
-
labels
|
19
|
-
legend
|
20
|
-
markers
|
21
|
-
noData
|
22
|
-
plotOptions
|
23
|
-
responsive
|
24
|
-
series
|
25
|
-
states
|
26
|
-
stroke
|
27
|
-
subtitle
|
28
|
-
theme
|
29
|
-
title
|
30
|
-
tooltip
|
31
|
-
var
|
32
|
-
xaxis
|
33
|
-
xtitle
|
34
|
-
yaxis
|
35
|
-
ytitle
|
36
|
-
],
|
37
|
-
*DivAttributes.optional_keys,
|
38
|
-
*ChartOptions.optional_keys,
|
39
|
-
*StrokeOptions.optional_keys,
|
40
|
-
*StatesOptions.optional_keys
|
41
|
-
end
|
42
|
-
end
|