apexcharts 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README.md +132 -0
- data/lib/apexcharts/charts/area.rb +7 -0
- data/lib/apexcharts/charts/bar.rb +11 -0
- data/lib/apexcharts/charts/capabilities/annotations.rb +75 -0
- data/lib/apexcharts/charts/cartesian.rb +60 -0
- data/lib/apexcharts/charts/column.rb +7 -0
- data/lib/apexcharts/charts/line.rb +7 -0
- data/lib/apexcharts/charts/mixed.rb +72 -0
- data/lib/apexcharts/charts/scatter.rb +7 -0
- data/lib/apexcharts/charts/syncing.rb +61 -0
- data/lib/apexcharts/charts.rb +8 -0
- data/lib/apexcharts/helper.rb +66 -0
- data/lib/apexcharts/options/annotations.rb +10 -0
- data/lib/apexcharts/options/axis.rb +17 -0
- data/lib/apexcharts/options/chart.rb +24 -0
- data/lib/apexcharts/options/data_labels.rb +12 -0
- data/lib/apexcharts/options/div_attributes.rb +10 -0
- data/lib/apexcharts/options/fill.rb +12 -0
- data/lib/apexcharts/options/grid.rb +15 -0
- data/lib/apexcharts/options/legend.rb +24 -0
- data/lib/apexcharts/options/markers.rb +18 -0
- data/lib/apexcharts/options/no_data.rb +12 -0
- data/lib/apexcharts/options/plot_options.rb +11 -0
- data/lib/apexcharts/options/root.rb +41 -0
- data/lib/apexcharts/options/states.rb +9 -0
- data/lib/apexcharts/options/stroke.rb +12 -0
- data/lib/apexcharts/options/subtitle.rb +7 -0
- data/lib/apexcharts/options/theme.rb +8 -0
- data/lib/apexcharts/options/title.rb +13 -0
- data/lib/apexcharts/options/tooltip.rb +22 -0
- data/lib/apexcharts/options/x_axis.rb +12 -0
- data/lib/apexcharts/options/y_axis.rb +15 -0
- data/lib/apexcharts/options_builder.rb +320 -0
- data/lib/apexcharts/series/cartesian.rb +24 -0
- data/lib/apexcharts/series.rb +1 -0
- data/lib/apexcharts/support/rails.rb +9 -0
- data/lib/apexcharts/utils/date_time.rb +60 -0
- data/lib/apexcharts/utils/hash.rb +31 -0
- data/lib/apexcharts/utils.rb +2 -0
- data/lib/apexcharts/version.rb +3 -0
- data/lib/apexcharts.rb +2 -0
- data/vendor/assets/javascripts/apexcharts.js +6 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e6b3b98ec99c06971c628785c5cad67c383761d510143618f44eb35d66b14b64
|
4
|
+
data.tar.gz: 5529e49eb4a68568e307d811405252b7edb9917e9d2f1f0d3747974cb4846490
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 27524883c3b7bc5fd74d61dce05996807e891b6a8162ba3443618060a60ccdbf211b47d1f8bccd6d23f3f724247bbf9ccb3035b2366d62ac66dd504f4088c23e
|
7
|
+
data.tar.gz: 8be3f7162a6df1afdd91178f12576594932755e11152ab7b4d1f2a8b7ffd15d17d7ca01ccb62e96de3c10b0217df29fb9f68ad82bda2004b97ae642bac195c9b
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019 Adrian Setyadi
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
<p align="center">
|
2
|
+
<img src="https://apexcharts.com/media/apexcharts-logo.png" height="90">
|
3
|
+
<span style="font-size: 40px; vertical-align: top; margin-right: 10px;">+</span>
|
4
|
+
<img src="https://www.ruby-lang.org/images/header-ruby-logo.png">
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<p align="center">
|
8
|
+
<a href="https://github.com/styd/apexcharts.rb/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT-brightgreen.svg" alt="License"></a>
|
9
|
+
<a href="https://travis-ci.com/styd/apexcharts.rb"><img src="https://api.travis-ci.com/styd/apexcharts.rb.svg?branch=master" alt="build" /></a>
|
10
|
+
</p>
|
11
|
+
|
12
|
+
|
13
|
+
<p align="center">
|
14
|
+
<a href="https://twitter.com/intent/tweet?text=Create%20visualizations%20with%20this%20free%20and%20open-source%20JavaScript%20Chart%20library&url=https://www.apexcharts.com&hashtags=javascript,charts,visualizations,developers,apexcharts"><img src="https://img.shields.io/twitter/url/http/shields.io.svg?style=social"> </a>
|
15
|
+
</p>
|
16
|
+
|
17
|
+
<p align="center">Beautiful and interactive web charts for rubyist.</p>
|
18
|
+
|
19
|
+
|
20
|
+
<p align="center"><img src="https://apexcharts.com/media/apexcharts-banner.png"></p>
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
Add this line to your application's Gemfile:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem 'apexcharts'
|
27
|
+
```
|
28
|
+
|
29
|
+
And then execute:
|
30
|
+
```bash
|
31
|
+
$ bundle
|
32
|
+
```
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
|
36
|
+
### Cartesian Charts
|
37
|
+
|
38
|
+
Example series used for mixable charts:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
series = [
|
42
|
+
{name: "Total", data: @total_users},
|
43
|
+
{name: "Verified", data: @verified_users},
|
44
|
+
{name: "Unverified", data: @unverified_users}
|
45
|
+
]
|
46
|
+
```
|
47
|
+
To build the data, you can use gem [groupdate](https://github.com/ankane/groupdate).
|
48
|
+
|
49
|
+
Example options used for mixable charts:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
options = {
|
53
|
+
title: 'Users Growth',
|
54
|
+
subtitle: 'Grouped Per Week',
|
55
|
+
xtitle: 'Week', ytitle: 'Users'
|
56
|
+
}
|
57
|
+
```
|
58
|
+
|
59
|
+
#### Line Chart
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
<%= line_chart(series, options) %>
|
63
|
+
```
|
64
|
+
|
65
|
+
#### Area Chart
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
<%= area_chart(series, options) %>
|
69
|
+
```
|
70
|
+
|
71
|
+
#### Column Chart
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
<%= column_chart(series, options) %>
|
75
|
+
```
|
76
|
+
|
77
|
+
#### Bar Chart
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
<%= bar_chart(series, options) %>
|
81
|
+
```
|
82
|
+
|
83
|
+
#### Scatter Chart
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
<%= scatter_chart(series, options) %>
|
87
|
+
```
|
88
|
+
|
89
|
+
All charts can have annotations, for example:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
<%= line_chart(series, options) do %>
|
93
|
+
<% x_annotation(value: ('2018-11-18'..'2018-12-02'),
|
94
|
+
text: "Busy Time", color: 'green') %>
|
95
|
+
<% y_annotation(value: 59, text: "Max Users", color: 'blue') %>
|
96
|
+
<% point_annotation(value: ['2018-07-22', 12],
|
97
|
+
text: "First Peak", color: 'magenta') %>
|
98
|
+
<% end %>
|
99
|
+
```
|
100
|
+
|
101
|
+
![Example Line Chart with Annotations](images/example-annotations.png)
|
102
|
+
|
103
|
+
## Web Framework
|
104
|
+
|
105
|
+
### Rails
|
106
|
+
|
107
|
+
After installing the gem, require it in your `app/assets/javascripts/application.js`.
|
108
|
+
```js
|
109
|
+
//= require 'apexcharts'
|
110
|
+
```
|
111
|
+
|
112
|
+
Or, if you use `webpacker`, you can run:
|
113
|
+
```bash
|
114
|
+
yarn add apexcharts
|
115
|
+
```
|
116
|
+
and then require it in your `app/javascript/packs/application.js`.
|
117
|
+
```js
|
118
|
+
require("apexcharts")
|
119
|
+
```
|
120
|
+
|
121
|
+
## Objective
|
122
|
+
- To bring out as much apexcharts.js capabilities as possible but in ruby ways.
|
123
|
+
|
124
|
+
## Roadmap
|
125
|
+
- Other charts (pie, donut, radar, heatmap, etc.)
|
126
|
+
- Support other ruby frameworks (sinatra, hanami, etc.)
|
127
|
+
|
128
|
+
## Contributing
|
129
|
+
Contribution directions go here.
|
130
|
+
|
131
|
+
## License
|
132
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Apexcharts
|
2
|
+
module Annotations
|
3
|
+
def annotation(position, value:, text:, color: nil, **options)
|
4
|
+
@annotations ||= {}
|
5
|
+
|
6
|
+
unless [:xaxis, :yaxis, :points].include? position
|
7
|
+
raise "unrecognized position: #{position}"
|
8
|
+
end
|
9
|
+
@annotations[position] ||= []
|
10
|
+
@annotations[position] << annotation_value(position, value).merge(
|
11
|
+
if position == :points
|
12
|
+
{marker: {size: 8, fillColor: 'white', strokeColor: color, radius: 2}, **options}
|
13
|
+
else
|
14
|
+
{borderColor: color, fillColor: color, opacity: 0.2}
|
15
|
+
end
|
16
|
+
).merge(
|
17
|
+
annotation_label(text, color, **options)
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def x_annotation **args
|
22
|
+
annotation :xaxis, **args
|
23
|
+
end
|
24
|
+
|
25
|
+
def y_annotation **args
|
26
|
+
annotation :yaxis, **args
|
27
|
+
end
|
28
|
+
|
29
|
+
def point_annotation **args
|
30
|
+
annotation :points, **args
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def annotation_value position, value
|
36
|
+
position = position.to_s.delete_suffix('axis').to_sym
|
37
|
+
case value
|
38
|
+
when Range
|
39
|
+
value = Utils::DateTime.convert_range(value)
|
40
|
+
|
41
|
+
case position
|
42
|
+
when :x
|
43
|
+
{x: value.first, x2: value.last}
|
44
|
+
when :y
|
45
|
+
{y: value.first, y2: value.last}
|
46
|
+
else
|
47
|
+
raise "position :points doesn't accept value of type Range"
|
48
|
+
end
|
49
|
+
else
|
50
|
+
if position == :points
|
51
|
+
value.map!{ |x| Utils::DateTime.convert(x) }
|
52
|
+
{x: value.first, y: value.last}
|
53
|
+
else
|
54
|
+
value = Utils::DateTime.convert(value)
|
55
|
+
{position => value}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def annotation_label text, color, **options
|
61
|
+
{
|
62
|
+
label: {
|
63
|
+
borderColor: color,
|
64
|
+
style: {
|
65
|
+
color: 'white',
|
66
|
+
background: color
|
67
|
+
},
|
68
|
+
text: text
|
69
|
+
}, **options
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
include Utils::Hash
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require_relative 'capabilities/annotations'
|
2
|
+
|
3
|
+
module Apexcharts
|
4
|
+
class CartesianChart
|
5
|
+
include Annotations
|
6
|
+
|
7
|
+
def initialize data, options={}, &block
|
8
|
+
options = {**options, **plot_options}
|
9
|
+
instance_eval &block if block_given?
|
10
|
+
|
11
|
+
options[:annotations] = @annotations if @annotations
|
12
|
+
@data = sanitize_data(data)
|
13
|
+
@options = Utils::Hash.camelize_keys(
|
14
|
+
Utils::Hash.deep_merge(
|
15
|
+
build_options(@data[0][:data][0][:x], options),
|
16
|
+
{series: @data, chart: {type: chart_type}}.compact
|
17
|
+
)
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def chart_type
|
22
|
+
end
|
23
|
+
|
24
|
+
def plot_options
|
25
|
+
{}
|
26
|
+
end
|
27
|
+
|
28
|
+
def mixed_series
|
29
|
+
@data.each{|d| d.merge!(type: chart_type) }
|
30
|
+
@data
|
31
|
+
end
|
32
|
+
|
33
|
+
def render
|
34
|
+
attributes = @options.delete(:div)
|
35
|
+
variable = attributes.delete(:var) || "chart#{attributes[:id][/\d+/]}"
|
36
|
+
element_id = attributes.delete(:id)
|
37
|
+
css_class = attributes.delete(:class)
|
38
|
+
height = "#{@options[:chart][:height].to_i}px"
|
39
|
+
style = "height: #{height}; #{attributes.delete(:style)}"
|
40
|
+
html =<<~HTML
|
41
|
+
<div id="#{element_id}" class="#{css_class}" style="#{style}"></div>
|
42
|
+
<script type="text/javascript">
|
43
|
+
var #{variable} = new ApexCharts(document.querySelector("##{element_id}"), #{@options.to_json});
|
44
|
+
#{variable}.render();
|
45
|
+
</script>
|
46
|
+
HTML
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def sanitize_data(data)
|
52
|
+
Apexcharts::CartesianSeries.new(data).sanitized
|
53
|
+
end
|
54
|
+
|
55
|
+
def build_options(x_sample, options)
|
56
|
+
Apexcharts::OptionsBuilder.new(x_sample, options).built
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Apexcharts
|
2
|
+
class MixedChart
|
3
|
+
include Annotations
|
4
|
+
|
5
|
+
def initialize options={}, bindings, &block
|
6
|
+
@bindings = bindings
|
7
|
+
@mixed_series = []
|
8
|
+
build_instance_variables
|
9
|
+
instance_eval &block
|
10
|
+
|
11
|
+
options[:annotations] = @annotations if @annotations
|
12
|
+
@options = Utils::Hash.camelize_keys(
|
13
|
+
Utils::Hash.deep_merge(
|
14
|
+
build_options(@mixed_series[0][:data][0][:x], options),
|
15
|
+
{chart: {type: 'area'}, series: @mixed_series}
|
16
|
+
)
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def line_chart data, options={}, &block
|
21
|
+
@mixed_series += LineChart.new(data, options, &block).mixed_series
|
22
|
+
end
|
23
|
+
|
24
|
+
def area_chart data, options={}, &block
|
25
|
+
@mixed_series += AreaChart.new(data, options, &block).mixed_series
|
26
|
+
end
|
27
|
+
|
28
|
+
def bar_chart data, options={}, &block
|
29
|
+
@mixed_series += BarChart.new(data, options, &block).mixed_series
|
30
|
+
end
|
31
|
+
|
32
|
+
def column_chart data, options={}, &block
|
33
|
+
@mixed_series += ColumnChart.new(data, options, &block).mixed_series
|
34
|
+
end
|
35
|
+
|
36
|
+
def scatter_chart data, options={}, &block
|
37
|
+
@mixed_series += ScatterChart.new(data, options, &block).mixed_series
|
38
|
+
end
|
39
|
+
|
40
|
+
def render
|
41
|
+
attributes = @options.delete(:div)
|
42
|
+
variable = attributes.delete(:var) || "chart#{attributes[:id][/\d+/]}"
|
43
|
+
element_id = attributes.delete(:id)
|
44
|
+
css_class = attributes.delete(:class)
|
45
|
+
height = "#{@options[:chart][:height].to_i}px"
|
46
|
+
style = "height: #{height};#{attributes.delete(:style)}"
|
47
|
+
html =<<~HTML
|
48
|
+
<div id="#{element_id}" class="#{css_class}" style="#{style}"></div>
|
49
|
+
<script type="text/javascript">
|
50
|
+
var #{variable} = new ApexCharts(document.querySelector("##{element_id}"), #{@options.to_json});
|
51
|
+
#{variable}.render();
|
52
|
+
</script>
|
53
|
+
HTML
|
54
|
+
end
|
55
|
+
|
56
|
+
def method_missing method, *args, &block
|
57
|
+
@bindings.send method, *args, &block
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def build_instance_variables
|
63
|
+
(@bindings.instance_variables - instance_variables).each do |i|
|
64
|
+
instance_variable_set(i, @bindings.instance_variable_get(i))
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def build_options(x_sample, options)
|
69
|
+
Apexcharts::OptionsBuilder.new(x_sample, options).built
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Apexcharts
|
2
|
+
class SyncingChart
|
3
|
+
def initialize options={}, bindings, &block
|
4
|
+
@bindings = bindings
|
5
|
+
@html = ""
|
6
|
+
build_instance_variables
|
7
|
+
@options = options
|
8
|
+
instance_eval &block
|
9
|
+
|
10
|
+
@options[:annotations] = @_annotations if @_annotations
|
11
|
+
end
|
12
|
+
|
13
|
+
def line_chart data, options={}, &block
|
14
|
+
options[:id] = apexcharts_id
|
15
|
+
@html += LineChart.new(data, @options.merge(options), &block).render
|
16
|
+
end
|
17
|
+
|
18
|
+
def area_chart data, options={}, &block
|
19
|
+
options[:id] = apexcharts_id
|
20
|
+
@html += AreaChart.new(data, @options.merge(options), &block).render
|
21
|
+
end
|
22
|
+
|
23
|
+
def bar_chart data, options={}, &block
|
24
|
+
options[:id] = apexcharts_id
|
25
|
+
@html += BarChart.new(data, @options.merge(options), &block).render
|
26
|
+
end
|
27
|
+
|
28
|
+
def column_chart data, options={}, &block
|
29
|
+
options[:id] = apexcharts_id
|
30
|
+
@html += ColumnChart.new(data, @options.merge(options), &block).render
|
31
|
+
end
|
32
|
+
|
33
|
+
def scatter_chart data, options={}, &block
|
34
|
+
options[:id] = apexcharts_id
|
35
|
+
@html += ScatterChart.new(data, @options.merge(options), &block).render
|
36
|
+
end
|
37
|
+
|
38
|
+
def mixed_chart options={}, &block
|
39
|
+
options[:id] = apexcharts_id
|
40
|
+
bindings = eval "self", block.binding
|
41
|
+
@html += MixedChart.new(@options.merge(options), bindings, &block).render
|
42
|
+
end
|
43
|
+
alias_method :combo_chart, :mixed_chart
|
44
|
+
|
45
|
+
def render
|
46
|
+
@html
|
47
|
+
end
|
48
|
+
|
49
|
+
def method_missing method, *args, &block
|
50
|
+
@bindings.send method, *args, &block
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def build_instance_variables
|
56
|
+
(@bindings.instance_variables - instance_variables).each do |i|
|
57
|
+
instance_variable_set(i, @bindings.instance_variable_get(i))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require_relative 'charts/cartesian'
|
2
|
+
require_relative 'charts/line'
|
3
|
+
require_relative 'charts/area'
|
4
|
+
require_relative 'charts/bar'
|
5
|
+
require_relative 'charts/column'
|
6
|
+
require_relative 'charts/scatter'
|
7
|
+
require_relative 'charts/mixed'
|
8
|
+
require_relative 'charts/syncing'
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require_relative 'series'
|
2
|
+
require_relative 'options_builder'
|
3
|
+
require_relative 'utils'
|
4
|
+
require_relative 'charts'
|
5
|
+
|
6
|
+
module Apexcharts
|
7
|
+
module Helper
|
8
|
+
def line_chart data, options={}, &block
|
9
|
+
options[:id] ||= apexcharts_id
|
10
|
+
draw_chart(LineChart.new(data, options, &block))
|
11
|
+
end
|
12
|
+
|
13
|
+
def area_chart data, options={}, &block
|
14
|
+
options[:id] ||= apexcharts_id
|
15
|
+
draw_chart(AreaChart.new(data, options, &block))
|
16
|
+
end
|
17
|
+
|
18
|
+
def column_chart data, options={}, &block
|
19
|
+
options[:id] ||= apexcharts_id
|
20
|
+
draw_chart(ColumnChart.new(data, options, &block))
|
21
|
+
end
|
22
|
+
|
23
|
+
def bar_chart data, options={}, &block
|
24
|
+
options[:id] ||= apexcharts_id
|
25
|
+
draw_chart(BarChart.new(data, options, &block))
|
26
|
+
end
|
27
|
+
|
28
|
+
def scatter_chart data, options={}, &block
|
29
|
+
options[:id] ||= apexcharts_id
|
30
|
+
draw_chart(ScatterChart.new(data, options, &block))
|
31
|
+
end
|
32
|
+
|
33
|
+
def mixed_chart options={}, &block
|
34
|
+
options[:id] ||= apexcharts_id
|
35
|
+
bindings = eval "self", block.binding
|
36
|
+
draw_chart(MixedChart.new(options, bindings, &block))
|
37
|
+
end
|
38
|
+
alias_method :combo_chart, :mixed_chart
|
39
|
+
|
40
|
+
def syncing_chart options={}, &block
|
41
|
+
options[:group] ||= apexcharts_group
|
42
|
+
bindings = eval "self", block.binding
|
43
|
+
draw_chart(SyncingChart.new(options, bindings, &block))
|
44
|
+
end
|
45
|
+
alias_method :synchronized_chart, :syncing_chart
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def draw_chart chart
|
50
|
+
chart = chart.render
|
51
|
+
chart.respond_to?(:html_safe) ? chart.html_safe : chart
|
52
|
+
end
|
53
|
+
|
54
|
+
def apexcharts_id
|
55
|
+
@_apexcharts_id ||= 0
|
56
|
+
@_apexcharts_id += 1
|
57
|
+
"chart-#{@_apexcharts_id}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def apexcharts_group
|
61
|
+
@_apexcharts_group ||= 0
|
62
|
+
@_apexcharts_group += 1
|
63
|
+
"chart-group-#{@_apexcharts_group}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Apexcharts
|
2
|
+
class ChartOptions < ::SmartKv
|
3
|
+
optional *%i[ animations
|
4
|
+
background
|
5
|
+
brush
|
6
|
+
default_locale defaultLocale
|
7
|
+
drop_shadow dropShadow
|
8
|
+
events
|
9
|
+
font_family fontFamily
|
10
|
+
fore_color foreColor
|
11
|
+
height
|
12
|
+
id
|
13
|
+
locales
|
14
|
+
selection
|
15
|
+
sparkline
|
16
|
+
stack_type stackType
|
17
|
+
stacked
|
18
|
+
toolbar
|
19
|
+
type
|
20
|
+
width
|
21
|
+
zoom
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|