apexcharts 0.1.5 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +456 -38
  3. data/lib/apex_charts/charts.rb +16 -0
  4. data/lib/{apexcharts/charts/area.rb → apex_charts/charts/area_chart.rb} +1 -1
  5. data/lib/{apexcharts/charts/bar.rb → apex_charts/charts/bar_chart.rb} +1 -1
  6. data/lib/apex_charts/charts/base_chart.rb +37 -0
  7. data/lib/apex_charts/charts/bubble_chart.rb +13 -0
  8. data/lib/{apexcharts/charts/candlestick.rb → apex_charts/charts/candlestick_chart.rb} +1 -1
  9. data/lib/apex_charts/charts/cartesian_chart.rb +82 -0
  10. data/lib/{apexcharts/charts/column.rb → apex_charts/charts/column_chart.rb} +3 -1
  11. data/lib/{apexcharts/charts/donut.rb → apex_charts/charts/donut_chart.rb} +1 -2
  12. data/lib/{apexcharts → apex_charts}/charts/features/annotations.rb +22 -21
  13. data/lib/{apexcharts → apex_charts}/charts/features/mixable.rb +2 -3
  14. data/lib/{apexcharts/charts/heatmap.rb → apex_charts/charts/heatmap_chart.rb} +3 -5
  15. data/lib/{apexcharts/charts/line.rb → apex_charts/charts/line_chart.rb} +1 -1
  16. data/lib/apex_charts/charts/mixed_charts.rb +101 -0
  17. data/lib/{apexcharts/charts/pie.rb → apex_charts/charts/pie_chart.rb} +1 -2
  18. data/lib/apex_charts/charts/polar_chart.rb +9 -0
  19. data/lib/{apexcharts/charts/radar.rb → apex_charts/charts/radar_chart.rb} +3 -5
  20. data/lib/{apexcharts/charts/radial_bar.rb → apex_charts/charts/radial_bar_chart.rb} +1 -2
  21. data/lib/apex_charts/charts/range_bar_chart.rb +9 -0
  22. data/lib/{apexcharts/charts/scatter.rb → apex_charts/charts/scatter_chart.rb} +1 -1
  23. data/lib/apex_charts/charts/syncing_charts.rb +84 -0
  24. data/lib/apex_charts/colors.rb +27 -0
  25. data/lib/apex_charts/config/default_options.rb +16 -0
  26. data/lib/apex_charts/configuration.rb +25 -0
  27. data/lib/apex_charts/helper.rb +190 -0
  28. data/lib/apex_charts/options/annotations_options.rb +15 -0
  29. data/lib/apex_charts/options/chart_options.rb +32 -0
  30. data/lib/apex_charts/options/data_labels_options.rb +18 -0
  31. data/lib/apex_charts/options/div_attributes.rb +11 -0
  32. data/lib/apex_charts/options/fill_options.rb +14 -0
  33. data/lib/apex_charts/options/grid_options.rb +17 -0
  34. data/lib/apex_charts/options/legend_options.rb +32 -0
  35. data/lib/apex_charts/options/markers_options.rb +24 -0
  36. data/lib/apex_charts/options/no_data_options.rb +14 -0
  37. data/lib/apex_charts/options/plot_options.rb +16 -0
  38. data/lib/apex_charts/options/root_options.rb +47 -0
  39. data/lib/apex_charts/options/states_options.rb +11 -0
  40. data/lib/apex_charts/options/stroke_options.rb +14 -0
  41. data/lib/apex_charts/options/theme_options.rb +11 -0
  42. data/lib/apex_charts/options/title_subtitle_options.rb +15 -0
  43. data/lib/apex_charts/options/tooltip_options.rb +25 -0
  44. data/lib/apex_charts/options/x_axis_options.rb +26 -0
  45. data/lib/apex_charts/options/y_axis_options.rb +28 -0
  46. data/lib/{apexcharts → apex_charts}/options_builder.rb +95 -90
  47. data/lib/apex_charts/prefix_with_apex.rb +7 -0
  48. data/lib/apex_charts/prefixer.rb +21 -0
  49. data/lib/apex_charts/renderer.rb +113 -0
  50. data/lib/apex_charts/series.rb +7 -0
  51. data/lib/apex_charts/series/bubble_series.rb +50 -0
  52. data/lib/apex_charts/series/cartesian_series.rb +81 -0
  53. data/lib/apex_charts/series/polar_series.rb +48 -0
  54. data/lib/{apexcharts → apex_charts}/support/rails.rb +1 -1
  55. data/lib/apex_charts/support/sinatra.rb +9 -0
  56. data/lib/apex_charts/theme.rb +60 -0
  57. data/lib/{apexcharts → apex_charts}/utils.rb +1 -0
  58. data/lib/apex_charts/utils/copy.rb +11 -0
  59. data/lib/apex_charts/utils/date_time.rb +70 -0
  60. data/lib/{apexcharts → apex_charts}/utils/hash.rb +4 -3
  61. data/lib/{apexcharts → apex_charts}/version.rb +2 -1
  62. data/lib/apexcharts.rb +3 -2
  63. data/vendor/assets/javascripts/apexcharts.js +11 -3
  64. metadata +85 -65
  65. data/lib/apexcharts/charts.rb +0 -19
  66. data/lib/apexcharts/charts/base.rb +0 -34
  67. data/lib/apexcharts/charts/bubble.rb +0 -19
  68. data/lib/apexcharts/charts/cartesian.rb +0 -81
  69. data/lib/apexcharts/charts/mixed.rb +0 -85
  70. data/lib/apexcharts/charts/polar.rb +0 -14
  71. data/lib/apexcharts/charts/syncing.rb +0 -70
  72. data/lib/apexcharts/helper.rb +0 -109
  73. data/lib/apexcharts/options/annotations.rb +0 -10
  74. data/lib/apexcharts/options/axis.rb +0 -17
  75. data/lib/apexcharts/options/chart.rb +0 -26
  76. data/lib/apexcharts/options/data_labels.rb +0 -12
  77. data/lib/apexcharts/options/div_attributes.rb +0 -10
  78. data/lib/apexcharts/options/fill.rb +0 -12
  79. data/lib/apexcharts/options/grid.rb +0 -15
  80. data/lib/apexcharts/options/legend.rb +0 -24
  81. data/lib/apexcharts/options/markers.rb +0 -18
  82. data/lib/apexcharts/options/no_data.rb +0 -12
  83. data/lib/apexcharts/options/plot_options.rb +0 -12
  84. data/lib/apexcharts/options/root.rb +0 -42
  85. data/lib/apexcharts/options/states.rb +0 -9
  86. data/lib/apexcharts/options/stroke.rb +0 -12
  87. data/lib/apexcharts/options/subtitle.rb +0 -7
  88. data/lib/apexcharts/options/theme.rb +0 -8
  89. data/lib/apexcharts/options/title.rb +0 -13
  90. data/lib/apexcharts/options/tooltip.rb +0 -22
  91. data/lib/apexcharts/options/x_axis.rb +0 -12
  92. data/lib/apexcharts/options/y_axis.rb +0 -15
  93. data/lib/apexcharts/renderer.rb +0 -21
  94. data/lib/apexcharts/series.rb +0 -5
  95. data/lib/apexcharts/series/bubble.rb +0 -37
  96. data/lib/apexcharts/series/cartesian.rb +0 -65
  97. data/lib/apexcharts/series/polar.rb +0 -32
  98. data/lib/apexcharts/utils/date_time.rb +0 -59
@@ -1,14 +0,0 @@
1
- module ApexCharts
2
- class PolarChart < BaseChart
3
-
4
- protected
5
-
6
- def sanitize_data(data)
7
- ApexCharts::PolarSeries.new(data).sanitized
8
- end
9
-
10
- def x_sample
11
- end
12
- end
13
- end
14
-
@@ -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
@@ -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,10 +0,0 @@
1
- module ApexCharts
2
- class AnnotationsOptions < ::SmartKv
3
- optional *%i[
4
- points
5
- position
6
- xaxis
7
- yaxis
8
- ]
9
- end
10
- end
@@ -1,17 +0,0 @@
1
- module ApexCharts
2
- class AxisOptions < ::SmartKv
3
- optional *%i[
4
- axisBorder
5
- axisTicks
6
- crosshairs
7
- floating
8
- labels
9
- max
10
- min
11
- tickAmount
12
- title
13
- tooltip
14
- type
15
- ]
16
- end
17
- 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,12 +0,0 @@
1
- module ApexCharts
2
- class DataLabelsOptions < ::SmartKv
3
- optional *%i[
4
- dropShadow
5
- enabled
6
- offsetX
7
- offsetY
8
- style
9
- textAnchor
10
- ]
11
- end
12
- end
@@ -1,10 +0,0 @@
1
- module ApexCharts
2
- class DivAttributes < ::SmartKv
3
- optional *%i[
4
- class
5
- id
6
- style
7
- ]
8
- end
9
- end
10
-
@@ -1,12 +0,0 @@
1
- module ApexCharts
2
- class FillOptions < ::SmartKv
3
- optional *%i[
4
- colors
5
- gradient
6
- image
7
- opacity
8
- pattern
9
- type
10
- ]
11
- end
12
- end
@@ -1,15 +0,0 @@
1
- module ApexCharts
2
- class GridOptions < ::SmartKv
3
- optional *%i[
4
- borderColor
5
- column
6
- padding
7
- position
8
- row
9
- show
10
- strokeDashArray
11
- xaxis
12
- yaxis
13
- ]
14
- end
15
- 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,18 +0,0 @@
1
- module ApexCharts
2
- class MarkersOptions < ::SmartKv
3
- optional *%i[
4
- colors
5
- discrete
6
- fillOpacity
7
- hover
8
- offsetX
9
- offsetY
10
- radius
11
- shape
12
- size
13
- strokeColor
14
- strokeOpacity
15
- strokeWidth
16
- ]
17
- end
18
- end
@@ -1,12 +0,0 @@
1
- module ApexCharts
2
- class NoDataOptions < ::SmartKv
3
- optional *%i[
4
- align
5
- offsetX
6
- offsetY
7
- style
8
- text
9
- verticalAlign
10
- ]
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- module ApexCharts
2
- class PlotOptions < ::SmartKv
3
- optional *%i[
4
- bar
5
- candlestick
6
- heatmap
7
- pie
8
- radar
9
- radialBar
10
- ]
11
- end
12
- 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
@@ -1,9 +0,0 @@
1
- module ApexCharts
2
- class StatesOptions < ::SmartKv
3
- optional *%i[
4
- active
5
- hover
6
- normal
7
- ]
8
- end
9
- end
@@ -1,12 +0,0 @@
1
- module ApexCharts
2
- class StrokeOptions < ::SmartKv
3
- optional *%i[
4
- colors
5
- curve
6
- dashArray
7
- lineCap
8
- show
9
- width
10
- ]
11
- end
12
- end