glimmer-libui-cc-graphs_and_charts 0.3.0 → 0.4.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +82 -9
- data/VERSION +1 -1
- data/examples/graphs_and_charts/basic_line_graph_relative.rb +0 -1
- data/examples/graphs_and_charts/basic_line_graph_relative_reverse_x.rb +50 -0
- data/examples/graphs_and_charts/basic_line_graph_reverse_x.rb +52 -0
- data/glimmer-libui-cc-graphs_and_charts.gemspec +5 -3
- data/lib/glimmer/view/line_graph.rb +59 -15
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 948c4d8554c7e5fb57b91c76595312f215a6de6b28bf47b90589049cefcd13e0
|
4
|
+
data.tar.gz: e80fa96b958cf4adfbb956daff54da211840811198c2a97f37b336873ff8c406
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bae6ff11171d38a2cb7369af7b042972390786087754fd1e2a73fcd280b05b174c76c0766ce61ab31b8204ee77af6fecb7f3d3161784df3a49ae5b3eb5540f8
|
7
|
+
data.tar.gz: d95518f90db54705575b50b8beea6e9875f7f613ae8f26052aec65c6100c8274ddd0220795fc2d735e02a2f7a53a6dfc6561170945bfed288354c1e4495ddd7b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.4.1
|
4
|
+
|
5
|
+
- Support `reverse_x` as `false` when rendering a line graph in relative mode (without `display_attributes_on_hover: true` for now).
|
6
|
+
- Add new `examples/graphs_and_charts/basic_line_graph_relative.rb` example that renders line graphs naturally from left to right (with reverse_x not specified, meaning having value `false`).
|
7
|
+
|
8
|
+
## 0.4.0
|
9
|
+
|
10
|
+
- Support `reverse_x` option; when `false`, line graphs are drawn naturally from left to right, and when `true`, line graphs are drawn like before from right to left.
|
11
|
+
- Rename previous line graph examples to indicate that they have reverse_x as `true`
|
12
|
+
- Add new `examples/graphs_and_charts/basic_line_graph.rb` example that renders line graphs naturally from left to right.
|
13
|
+
|
3
14
|
## 0.3.0
|
4
15
|
|
5
16
|
- Initial implementation of `bubble_chart` custom control
|
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
# Graphs and Charts 0.
|
1
|
+
# Graphs and Charts 0.4.1 (Alpha)
|
2
2
|
## [Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui) Custom Controls
|
3
3
|
[](http://badge.fury.io/rb/glimmer-libui-cc-graphs_and_charts)
|
4
4
|
[](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
5
5
|
|
6
|
-
Graphs and Charts (Custom Controls for [Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui))
|
6
|
+
Graphs and Charts (Custom Controls for [Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui)). It is used in [Kuiq (Sidekiq UI)](https://github.com/mperham/kuiq).
|
7
7
|
|
8
8
|

|
9
9
|
|
10
|
-

|
11
11
|
|
12
12
|

|
13
13
|
|
@@ -16,7 +16,7 @@ Graphs and Charts (Custom Controls for [Glimmer DSL for LibUI](https://github.co
|
|
16
16
|
Add this line to Bundler `Gemfile`:
|
17
17
|
|
18
18
|
```ruby
|
19
|
-
gem 'glimmer-libui-cc-graphs_and_charts', '~> 0.
|
19
|
+
gem 'glimmer-libui-cc-graphs_and_charts', '~> 0.4.1'
|
20
20
|
```
|
21
21
|
|
22
22
|
Run:
|
@@ -137,6 +137,8 @@ Note that you can use in absolute mode or relative mode for determining x-axis v
|
|
137
137
|
- Absolute Mode: pass `values` which maps x-axis values to y-axis values
|
138
138
|
- Relative Mode: pass `y_values`, `x_value_start`, and `x_interval_in_seconds` (x-axis values are calculated automatically in a uniform way from `x_value_start` deducting `x_interval_in_seconds`)
|
139
139
|
|
140
|
+
Look into [lib/glimmer/view/line_graph.rb](/lib/glimmer/view/line_graph.rb) to learn about all supported options.
|
141
|
+
|
140
142
|
**Absolute Mode:**
|
141
143
|
|
142
144
|
It supports any `Numeric` y-axis values in addition to `Time` x-axis values.
|
@@ -176,12 +178,85 @@ line_graph(
|
|
176
178
|
|
177
179
|

|
178
180
|
|
181
|
+
**Absolute Mode (reverse x):**
|
182
|
+
|
183
|
+
It supports any `Numeric` y-axis values in addition to `Time` x-axis values.
|
184
|
+
|
185
|
+
```ruby
|
186
|
+
line_graph(
|
187
|
+
reverse_x: true,
|
188
|
+
width: 900,
|
189
|
+
height: 300,
|
190
|
+
lines: [
|
191
|
+
{
|
192
|
+
name: 'Stock 1',
|
193
|
+
stroke: [163, 40, 39, thickness: 2],
|
194
|
+
values: {
|
195
|
+
Time.new(2030, 12, 1) => 80,
|
196
|
+
Time.new(2030, 12, 2) => 36,
|
197
|
+
Time.new(2030, 12, 4) => 10,
|
198
|
+
Time.new(2030, 12, 5) => 60,
|
199
|
+
Time.new(2030, 12, 6) => 20,
|
200
|
+
},
|
201
|
+
x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
|
202
|
+
},
|
203
|
+
{
|
204
|
+
name: 'Stock 2',
|
205
|
+
stroke: [47, 109, 104, thickness: 2],
|
206
|
+
values: {
|
207
|
+
Time.new(2030, 12, 1) => 62,
|
208
|
+
Time.new(2030, 12, 2) => 0,
|
209
|
+
Time.new(2030, 12, 3) => 90,
|
210
|
+
Time.new(2030, 12, 5) => 0,
|
211
|
+
Time.new(2030, 12, 7) => 17,
|
212
|
+
},
|
213
|
+
x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
|
214
|
+
},
|
215
|
+
],
|
216
|
+
)
|
217
|
+
```
|
218
|
+
|
219
|
+

|
220
|
+
|
179
221
|
**Relative Mode:**
|
180
222
|
|
181
223
|
Currently, it only supports `Integer` y-axis values in addition to `Time` x-axis values.
|
182
224
|
|
183
225
|
```ruby
|
184
226
|
line_graph(
|
227
|
+
width: 900,
|
228
|
+
height: 300,
|
229
|
+
graph_point_distance: :width_divided_by_point_count,
|
230
|
+
lines: [
|
231
|
+
{
|
232
|
+
name: 'Feature A',
|
233
|
+
stroke: [163, 40, 39, thickness: 2],
|
234
|
+
x_value_start: @start_time,
|
235
|
+
x_interval_in_seconds: 8,
|
236
|
+
x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
|
237
|
+
y_values: [80, 36, 10, 60, 20, 110, 16, 5, 36, 1, 77, 15, 3, 34, 8, 63, 12, 17, 90, 28, 70]
|
238
|
+
},
|
239
|
+
{
|
240
|
+
name: 'Feature B',
|
241
|
+
stroke: [47, 109, 104, thickness: 2],
|
242
|
+
x_value_start: @start_time,
|
243
|
+
x_interval_in_seconds: 8,
|
244
|
+
x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
|
245
|
+
y_values: [62, 0, 90, 0, 0, 27, 0, 56, 0, 0, 24, 0, 60, 0, 30, 0, 47, 0, 38, 90, 0]
|
246
|
+
},
|
247
|
+
],
|
248
|
+
)
|
249
|
+
```
|
250
|
+
|
251
|
+

|
252
|
+
|
253
|
+
**Relative Mode (reverse x):**
|
254
|
+
|
255
|
+
Currently, it only supports `Integer` y-axis values in addition to `Time` x-axis values.
|
256
|
+
|
257
|
+
```ruby
|
258
|
+
line_graph(
|
259
|
+
reverse_x: true,
|
185
260
|
width: 900,
|
186
261
|
height: 300,
|
187
262
|
graph_point_distance: :width_divided_by_point_count,
|
@@ -207,9 +282,7 @@ line_graph(
|
|
207
282
|
)
|
208
283
|
```
|
209
284
|
|
210
|
-

|
211
|
-
|
212
|
-
Look into [lib/glimmer/view/line_graph.rb](/lib/glimmer/view/line_graph.rb) to learn about all supported options.
|
285
|
+

|
213
286
|
|
214
287
|
**Basic Line Graph Example:**
|
215
288
|
|
@@ -266,7 +339,7 @@ end
|
|
266
339
|
BasicLineGraph.launch
|
267
340
|
```
|
268
341
|
|
269
|
-

|
342
|
+

|
270
343
|
|
271
344
|
**Basic Line Graph Relative Example:**
|
272
345
|
|
@@ -314,7 +387,7 @@ end
|
|
314
387
|
BasicLineGraphRelative.launch
|
315
388
|
```
|
316
389
|
|
317
|
-

|
390
|
+

|
318
391
|
|
319
392
|
### Bubble Chart
|
320
393
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.1
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# This line is only needed when running the example from inside the project directory
|
2
|
+
$LOAD_PATH.prepend(File.expand_path(File.join(__dir__, '..', '..', 'lib'))) if File.exist?(File.join(__dir__, '..', '..', 'lib'))
|
3
|
+
|
4
|
+
require 'glimmer-dsl-libui'
|
5
|
+
require 'glimmer/view/line_graph'
|
6
|
+
|
7
|
+
class BasicLineGraphRelative
|
8
|
+
include Glimmer::LibUI::Application
|
9
|
+
|
10
|
+
before_body do
|
11
|
+
@start_time = Time.now
|
12
|
+
end
|
13
|
+
|
14
|
+
body {
|
15
|
+
window('Basic Line Graph Relative', 900, 330) { |main_window|
|
16
|
+
@line_graph = line_graph(
|
17
|
+
reverse_x: true,
|
18
|
+
width: 900,
|
19
|
+
height: 300,
|
20
|
+
graph_point_distance: :width_divided_by_point_count,
|
21
|
+
lines: [
|
22
|
+
{
|
23
|
+
name: 'Feature A',
|
24
|
+
stroke: [163, 40, 39, thickness: 2],
|
25
|
+
x_value_start: @start_time,
|
26
|
+
x_interval_in_seconds: 8,
|
27
|
+
x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
|
28
|
+
y_values: [80, 36, 10, 60, 20, 110, 16, 5, 36, 1, 77, 15, 3, 34, 8, 63, 12, 17, 90, 28, 70]
|
29
|
+
},
|
30
|
+
{
|
31
|
+
name: 'Feature B',
|
32
|
+
stroke: [47, 109, 104, thickness: 2],
|
33
|
+
x_value_start: @start_time,
|
34
|
+
x_interval_in_seconds: 8,
|
35
|
+
x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
|
36
|
+
y_values: [62, 0, 90, 0, 0, 27, 0, 56, 0, 0, 24, 0, 60, 0, 30, 0, 47, 0, 38, 90, 0]
|
37
|
+
},
|
38
|
+
],
|
39
|
+
display_attributes_on_hover: true,
|
40
|
+
)
|
41
|
+
|
42
|
+
on_content_size_changed do
|
43
|
+
@line_graph.width = main_window.content_size[0]
|
44
|
+
@line_graph.height = main_window.content_size[1] - 30
|
45
|
+
end
|
46
|
+
}
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
BasicLineGraphRelative.launch
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# This line is only needed when running the example from inside the project directory
|
2
|
+
$LOAD_PATH.prepend(File.expand_path(File.join(__dir__, '..', '..', 'lib'))) if File.exist?(File.join(__dir__, '..', '..', 'lib'))
|
3
|
+
|
4
|
+
require 'glimmer-dsl-libui'
|
5
|
+
require 'glimmer/view/line_graph'
|
6
|
+
|
7
|
+
class BasicLineGraph
|
8
|
+
include Glimmer::LibUI::Application
|
9
|
+
|
10
|
+
body {
|
11
|
+
window('Basic Line Graph', 900, 300) { |main_window|
|
12
|
+
@line_graph = line_graph(
|
13
|
+
reverse_x: true,
|
14
|
+
width: 900,
|
15
|
+
height: 300,
|
16
|
+
lines: [
|
17
|
+
{
|
18
|
+
name: 'Stock 1',
|
19
|
+
stroke: [163, 40, 39, thickness: 2],
|
20
|
+
values: {
|
21
|
+
Time.new(2030, 12, 1) => 2,
|
22
|
+
Time.new(2030, 12, 2) => 2.5,
|
23
|
+
Time.new(2030, 12, 4) => 1,
|
24
|
+
Time.new(2030, 12, 5) => 0,
|
25
|
+
Time.new(2030, 12, 6) => 2,
|
26
|
+
},
|
27
|
+
x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
|
28
|
+
},
|
29
|
+
{
|
30
|
+
name: 'Stock 2',
|
31
|
+
stroke: [47, 109, 104, thickness: 2],
|
32
|
+
values: {
|
33
|
+
Time.new(2030, 12, 1) => 2,
|
34
|
+
Time.new(2030, 12, 2) => 0,
|
35
|
+
Time.new(2030, 12, 3) => 2.5,
|
36
|
+
Time.new(2030, 12, 5) => 1,
|
37
|
+
Time.new(2030, 12, 7) => 2,
|
38
|
+
},
|
39
|
+
x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
|
40
|
+
},
|
41
|
+
],
|
42
|
+
)
|
43
|
+
|
44
|
+
on_content_size_changed do
|
45
|
+
@line_graph.width = main_window.content_size[0]
|
46
|
+
@line_graph.height = main_window.content_size[1]
|
47
|
+
end
|
48
|
+
}
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
BasicLineGraph.launch
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: glimmer-libui-cc-graphs_and_charts 0.
|
5
|
+
# stub: glimmer-libui-cc-graphs_and_charts 0.4.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer-libui-cc-graphs_and_charts".freeze
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.4.1".freeze
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Andy Maleh".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2025-02-01"
|
15
15
|
s.description = "Graphs and Charts (Glimmer DSL for LibUI Custom Controls), like Line Graph, Bar Chart, and Bubble Chart.".freeze
|
16
16
|
s.email = "andy.am@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -28,6 +28,8 @@ Gem::Specification.new do |s|
|
|
28
28
|
"examples/graphs_and_charts/basic_bubble_chart.rb",
|
29
29
|
"examples/graphs_and_charts/basic_line_graph.rb",
|
30
30
|
"examples/graphs_and_charts/basic_line_graph_relative.rb",
|
31
|
+
"examples/graphs_and_charts/basic_line_graph_relative_reverse_x.rb",
|
32
|
+
"examples/graphs_and_charts/basic_line_graph_reverse_x.rb",
|
31
33
|
"glimmer-libui-cc-graphs_and_charts.gemspec",
|
32
34
|
"lib/glimmer-libui-cc-graphs_and_charts.rb",
|
33
35
|
"lib/glimmer/view/bar_chart.rb",
|
@@ -74,6 +74,7 @@ module Glimmer
|
|
74
74
|
option :graph_status_height, default: DEFAULT_GRAPH_STATUS_HEIGHT
|
75
75
|
|
76
76
|
option :display_attributes_on_hover, default: false
|
77
|
+
option :reverse_x, default: false
|
77
78
|
|
78
79
|
before_body do
|
79
80
|
self.lines = [lines] if lines.is_a?(Hash)
|
@@ -112,8 +113,13 @@ module Glimmer
|
|
112
113
|
|
113
114
|
if @hover_point && lines && lines[0] && @points && @points[lines[0]] && !@points[lines[0]].empty?
|
114
115
|
x = @hover_point[:x]
|
115
|
-
|
116
|
-
|
116
|
+
if lines[0][:x_interval_in_seconds]
|
117
|
+
closest_point_index = ((width - graph_padding_width - x) / graph_point_distance_for_line(lines[0])).round
|
118
|
+
else
|
119
|
+
closest_point_index = :absolute
|
120
|
+
end
|
121
|
+
if closest_point_index == :absolute || closest_point_index != @closest_point_index
|
122
|
+
# TODO look into optimizing this for absolute mode
|
117
123
|
@closest_point_index = closest_point_index
|
118
124
|
graph_area.queue_redraw_all
|
119
125
|
end
|
@@ -275,12 +281,14 @@ module Glimmer
|
|
275
281
|
end
|
276
282
|
|
277
283
|
def all_line_graphs
|
278
|
-
lines.each
|
284
|
+
lines.each(&method(:single_line_graph))
|
279
285
|
end
|
280
286
|
|
281
287
|
def single_line_graph(graph_line)
|
282
288
|
last_point = nil
|
283
289
|
points = calculate_points(graph_line)
|
290
|
+
# points are already calculated as reversed before here, so here we reverse again if needed
|
291
|
+
points = reverse_x_in_points(points) if !reverse_x
|
284
292
|
points.to_a.each do |point|
|
285
293
|
if last_point
|
286
294
|
line(last_point[:x], last_point[:y], point[:x], point[:y]) {
|
@@ -343,6 +351,23 @@ module Glimmer
|
|
343
351
|
@points[graph_line]
|
344
352
|
end
|
345
353
|
|
354
|
+
def reverse_x_in_points(points)
|
355
|
+
# TODO look into optimizing operations below by not iterating 3 times (perhaps one iteration could do everything)
|
356
|
+
points = points.map do |point|
|
357
|
+
point.merge(x: width_drawable.to_f - point[:x])
|
358
|
+
end
|
359
|
+
min_point = points.min_by {|point| point[:x]}
|
360
|
+
min_point_x = min_point[:x]
|
361
|
+
if min_point_x < 0
|
362
|
+
points.each do |point|
|
363
|
+
point[:x] = point[:x] - min_point_x
|
364
|
+
end
|
365
|
+
end
|
366
|
+
points.each do |point|
|
367
|
+
point[:x] = point[:x] + graph_padding_width.to_f
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
346
371
|
# this is the multiplier that we must multiply by the relative x value
|
347
372
|
def x_resolution
|
348
373
|
@x_resolution ||= width_drawable.to_f / x_value_range_for_all_lines.to_f
|
@@ -472,7 +497,19 @@ module Glimmer
|
|
472
497
|
|
473
498
|
if @hover_point && lines && lines[0] && @points && @points[lines[0]] && !@points[lines[0]].empty?
|
474
499
|
x = @hover_point[:x]
|
475
|
-
|
500
|
+
if @closest_point_index == :absolute # used in absolute mode
|
501
|
+
# TODO this is making a wrong assumption that there will be a point for every line
|
502
|
+
# some lines might end up with no points, so we need to filter them out
|
503
|
+
# we should start with the point across all lines that is closest to the mouse hover point
|
504
|
+
# and then pick up points that match its X value
|
505
|
+
closest_points = lines.map do |line|
|
506
|
+
line_points = @points[line]
|
507
|
+
point_distances_from_hover_point = line_points.map { |point| [point, PerfectShape::Point.point_distance(point[:x], point[:y], @hover_point[:x], @hover_point[:y])] }
|
508
|
+
closest_point = point_distances_from_hover_point.min_by(&:last).first
|
509
|
+
end
|
510
|
+
else
|
511
|
+
closest_points = lines.map { |line| @points[line][@closest_point_index] }
|
512
|
+
end
|
476
513
|
closest_x = closest_points[0]&.[](:x)
|
477
514
|
line(closest_x, graph_padding_height, closest_x, height - graph_padding_height) {
|
478
515
|
stroke graph_stroke_hover_line
|
@@ -488,14 +525,21 @@ module Glimmer
|
|
488
525
|
stroke stroke_value
|
489
526
|
}
|
490
527
|
end
|
491
|
-
text_label = formatted_x_value(@closest_point_index)
|
528
|
+
text_label = formatted_x_value(@closest_point_index, closest_points)
|
492
529
|
text_label_width = estimate_width_of_text(text_label, DEFAULT_GRAPH_FONT_MARKER_TEXT)
|
493
530
|
lines_with_closest_points = lines.each_with_index.map do |line, index|
|
494
531
|
next if closest_points[index].nil?
|
495
532
|
|
496
533
|
line
|
497
534
|
end.compact
|
498
|
-
closest_point_texts = lines_with_closest_points.map
|
535
|
+
closest_point_texts = lines_with_closest_points.each_with_index.map do |line, index|
|
536
|
+
if @closest_point_index == :absolute
|
537
|
+
line_point = closest_points[index]
|
538
|
+
"#{line[:name]}: #{line_point[:y_value]}"
|
539
|
+
else
|
540
|
+
"#{line[:name]}: #{line[:y_values][@closest_point_index]}"
|
541
|
+
end
|
542
|
+
end
|
499
543
|
closest_point_text_widths = closest_point_texts.map do |text|
|
500
544
|
estimate_width_of_text(text, graph_font_marker_text)
|
501
545
|
end
|
@@ -536,12 +580,10 @@ module Glimmer
|
|
536
580
|
end
|
537
581
|
end
|
538
582
|
|
539
|
-
def formatted_x_value(x_value_index)
|
540
|
-
# Today, we make the assumption that all lines have points along the same x-axis values
|
541
|
-
# TODO In the future, we can support different x values along different lines
|
583
|
+
def formatted_x_value(x_value_index, closest_points)
|
542
584
|
graph_line = lines[0]
|
543
585
|
x_value_format = graph_line[:x_value_format] || :to_s
|
544
|
-
x_value = calculated_x_value(x_value_index)
|
586
|
+
x_value = calculated_x_value(x_value_index, closest_points)
|
545
587
|
if (x_value_format.is_a?(Symbol) || x_value_format.is_a?(String))
|
546
588
|
x_value.send(x_value_format)
|
547
589
|
else
|
@@ -549,11 +591,13 @@ module Glimmer
|
|
549
591
|
end
|
550
592
|
end
|
551
593
|
|
552
|
-
def calculated_x_value(x_value_index)
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
594
|
+
def calculated_x_value(x_value_index, closest_points = nil)
|
595
|
+
if x_value_index == :absolute # absolute mode
|
596
|
+
closest_points.first[:x_value]
|
597
|
+
else # relative mode
|
598
|
+
graph_line = lines[0]
|
599
|
+
graph_line[:x_value_start] - (graph_line[:x_interval_in_seconds] * x_value_index)
|
600
|
+
end
|
557
601
|
end
|
558
602
|
|
559
603
|
def estimate_width_of_text(text_string, font_properties)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-libui-cc-graphs_and_charts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer-dsl-libui
|
@@ -90,6 +90,8 @@ files:
|
|
90
90
|
- examples/graphs_and_charts/basic_bubble_chart.rb
|
91
91
|
- examples/graphs_and_charts/basic_line_graph.rb
|
92
92
|
- examples/graphs_and_charts/basic_line_graph_relative.rb
|
93
|
+
- examples/graphs_and_charts/basic_line_graph_relative_reverse_x.rb
|
94
|
+
- examples/graphs_and_charts/basic_line_graph_reverse_x.rb
|
93
95
|
- glimmer-libui-cc-graphs_and_charts.gemspec
|
94
96
|
- lib/glimmer-libui-cc-graphs_and_charts.rb
|
95
97
|
- lib/glimmer/view/bar_chart.rb
|