trackplot 0.1.0 → 0.3.0

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.
@@ -0,0 +1,44 @@
1
+ require "securerandom"
2
+ require "json"
3
+
4
+ module Trackplot
5
+ class SparklineBuilder
6
+ attr_reader :data, :options
7
+
8
+ def initialize(data, **options)
9
+ @data = DataAdapter.normalize(data)
10
+ @options = options
11
+ end
12
+
13
+ def render(view_context)
14
+ config = build_config
15
+
16
+ view_context.content_tag(
17
+ "trackplot-sparkline",
18
+ nil,
19
+ config: config.to_json,
20
+ style: sparkline_style
21
+ )
22
+ end
23
+
24
+ private
25
+
26
+ def build_config
27
+ {
28
+ data: data,
29
+ key: options[:key].to_s,
30
+ type: (options[:type] || :line).to_s,
31
+ color: options[:color] || "#6366f1",
32
+ fill: options[:fill],
33
+ stroke_width: options[:stroke_width] || 1.5,
34
+ dot: options.fetch(:dot, false)
35
+ }.compact
36
+ end
37
+
38
+ def sparkline_style
39
+ width = options[:width] || "120px"
40
+ height = options[:height] || "32px"
41
+ "display:inline-block;width:#{width};height:#{height};"
42
+ end
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module Trackplot
2
- VERSION = "0.1.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/trackplot.rb CHANGED
@@ -3,8 +3,10 @@ require_relative "trackplot/engine" if defined?(Rails::Engine)
3
3
 
4
4
  module Trackplot
5
5
  autoload :ChartBuilder, "trackplot/chart_builder"
6
+ autoload :SparklineBuilder, "trackplot/sparkline_builder"
6
7
  autoload :DataAdapter, "trackplot/data_adapter"
7
8
  autoload :Theme, "trackplot/theme"
9
+ autoload :ColorScale, "trackplot/color_scale"
8
10
 
9
11
  module Components
10
12
  autoload :Base, "trackplot/components/base"
@@ -22,5 +24,14 @@ module Trackplot
22
24
  autoload :Candlestick, "trackplot/components/candlestick"
23
25
  autoload :Funnel, "trackplot/components/funnel"
24
26
  autoload :ReferenceLine, "trackplot/components/reference_line"
27
+ autoload :DataLabel, "trackplot/components/data_label"
28
+ autoload :Brush, "trackplot/components/brush"
29
+ autoload :Heatmap, "trackplot/components/heatmap"
30
+ autoload :Treemap, "trackplot/components/treemap"
31
+ autoload :Drilldown, "trackplot/components/drilldown"
25
32
  end
33
+
34
+ # Optional integrations — loaded only when their dependencies are available
35
+ autoload :Component, "trackplot/component"
36
+ autoload :PhlexComponent, "trackplot/phlex_component"
26
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trackplot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eagerworks
@@ -45,19 +45,27 @@ extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
47
  - LICENSE.txt
48
+ - app/assets/javascripts/trackplot/index.d.ts
48
49
  - app/assets/javascripts/trackplot/index.js
49
50
  - app/helpers/trackplot/chart_helper.rb
50
51
  - config/importmap.rb
51
52
  - lib/generators/trackplot/install_generator.rb
53
+ - lib/generators/trackplot/templates/trackplot_controller.js
52
54
  - lib/trackplot.rb
53
55
  - lib/trackplot/chart_builder.rb
56
+ - lib/trackplot/color_scale.rb
57
+ - lib/trackplot/component.rb
54
58
  - lib/trackplot/components/area.rb
55
59
  - lib/trackplot/components/axis.rb
56
60
  - lib/trackplot/components/bar.rb
57
61
  - lib/trackplot/components/base.rb
62
+ - lib/trackplot/components/brush.rb
58
63
  - lib/trackplot/components/candlestick.rb
64
+ - lib/trackplot/components/data_label.rb
65
+ - lib/trackplot/components/drilldown.rb
59
66
  - lib/trackplot/components/funnel.rb
60
67
  - lib/trackplot/components/grid.rb
68
+ - lib/trackplot/components/heatmap.rb
61
69
  - lib/trackplot/components/horizontal_bar.rb
62
70
  - lib/trackplot/components/legend.rb
63
71
  - lib/trackplot/components/line.rb
@@ -66,8 +74,11 @@ files:
66
74
  - lib/trackplot/components/reference_line.rb
67
75
  - lib/trackplot/components/scatter.rb
68
76
  - lib/trackplot/components/tooltip.rb
77
+ - lib/trackplot/components/treemap.rb
69
78
  - lib/trackplot/data_adapter.rb
70
79
  - lib/trackplot/engine.rb
80
+ - lib/trackplot/phlex_component.rb
81
+ - lib/trackplot/sparkline_builder.rb
71
82
  - lib/trackplot/theme.rb
72
83
  - lib/trackplot/version.rb
73
84
  homepage: https://github.com/eagerworks/trackplot