glimmer-libui-cc-graphs_and_charts 0.1.0 → 0.1.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 +72 -12
- data/VERSION +1 -1
- data/examples/graphs_and_charts/basic_line_graph.rb +44 -0
- data/glimmer-libui-cc-graphs_and_charts.gemspec +44 -0
- data/lib/glimmer/view/line_graph.rb +5 -2
- data/lib/glimmer-libui-cc-graphs_and_charts.rb +1 -1
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dce47797358894afe69a91ad5a1187b2f989e75674cab2d421ce5e071df844bb
|
4
|
+
data.tar.gz: 25204f836b424b69d4c6209afc6365c31a3b400cb388cbe8bdf482a9023126f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 352e7f457e6b6c3d3889b58246bba79ea65597dc210a02b1ab472c0f26dddb6776324abcced746f7b7f8f685d3f81732779041bc395a95c6a1a2a51be5cd2857
|
7
|
+
data.tar.gz: 9f4080bf60e38a8f5914769717f492d32638b309504486ca7caed6e2263bdb222903693027206fbf9b7ad97f4e9f69b1d1aa9fbb1be2813f69151e99323b1067
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## 0.1.1
|
4
|
+
|
5
|
+
- Ensure that `line_graph` max `y_value` is taken into account in visible points only (excluding points outside the visible area)
|
6
|
+
- Support ability to load entire `'glimmer-libui-cc-graphs_and_charts'` library instead of individual graphs/charts if preferred
|
7
|
+
- New `examples/graphs_and_charts/basic_line_graph.rb`
|
8
|
+
|
9
|
+
## 0.1.0
|
10
|
+
|
11
|
+
- Initial implementation of `line_graph` custom control
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Graphs and Charts 0.1.
|
1
|
+
# Graphs and Charts 0.1.1
|
2
2
|
## [Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui) Custom Controls
|
3
|
-
[](http://badge.fury.io/rb/glimmer-
|
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
6
|
Graphs and Charts (Custom Controls) for [Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui)
|
@@ -12,7 +12,7 @@ Graphs and Charts (Custom Controls) for [Glimmer DSL for LibUI](https://github.c
|
|
12
12
|
Add this line to Bundler `Gemfile`:
|
13
13
|
|
14
14
|
```ruby
|
15
|
-
gem 'glimmer-libui-cc-graphs_and_charts', '~> 0.1.
|
15
|
+
gem 'glimmer-libui-cc-graphs_and_charts', '~> 0.1.1'
|
16
16
|
```
|
17
17
|
|
18
18
|
Run:
|
@@ -23,43 +23,103 @@ bundle
|
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
|
26
|
+
It is preferred that you only load the graphs/charts that you need to use as per the instructions in the sub-sections below to conserve memory and startup time.
|
27
|
+
|
28
|
+
However, if you prefer to load all graphs and charts, add this line to your Ruby file:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require 'glimmer-libui-cc-graphs_and_charts'
|
32
|
+
```
|
33
|
+
|
26
34
|
### Line Graph
|
27
35
|
|
28
|
-
|
36
|
+
To load the `line_graph` custom control, add this line to your Ruby file:
|
29
37
|
|
30
38
|
```ruby
|
31
39
|
require 'glimmer/view/line_graph'
|
32
40
|
```
|
33
41
|
|
34
|
-
|
42
|
+
This makes the `line_graph` [Glimmer DSL for LibUI Custom Control](https://github.com/AndyObtiva/glimmer-dsl-libui#custom-components) available in the Glimmer GUI DSL.
|
43
|
+
You can then nest `line_graph` under `window` or some container like `vertical_box`. By the way, `line_graph` is implemented on top of the [`area` Glimmer DSL for LibUI control](https://github.com/AndyObtiva/glimmer-dsl-libui#area-api).
|
35
44
|
|
36
45
|
```ruby
|
37
46
|
line_graph(
|
38
47
|
width: 900,
|
39
48
|
height: 300,
|
49
|
+
graph_point_distance: :width_divided_by_point_count,
|
40
50
|
lines: [
|
41
51
|
{
|
42
|
-
name: '
|
52
|
+
name: 'Feature A',
|
43
53
|
stroke: [163, 40, 39, thickness: 2],
|
44
54
|
x_value_start: Time.now,
|
45
|
-
x_interval_in_seconds:
|
55
|
+
x_interval_in_seconds: 8,
|
46
56
|
x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
|
47
|
-
y_values: [36,
|
57
|
+
y_values: [80, 36, 10, 60, 20, 110, 16, 5, 36, 1, 77, 15, 3, 34, 8, 63, 12, 17, 90, 28, 70]
|
48
58
|
},
|
49
59
|
{
|
50
|
-
name: '
|
60
|
+
name: 'Feature B',
|
51
61
|
stroke: [47, 109, 104, thickness: 2],
|
52
62
|
x_value_start: Time.now,
|
53
|
-
x_interval_in_seconds:
|
63
|
+
x_interval_in_seconds: 8,
|
54
64
|
x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
|
55
|
-
y_values: [62, 0, 90, 0, 0, 27, 0, 56, 0, 0]
|
65
|
+
y_values: [62, 0, 90, 0, 0, 27, 0, 56, 0, 0, 24, 0, 60, 0, 30, 0, 47, 0, 38, 90, 0]
|
56
66
|
},
|
57
67
|
],
|
58
68
|
display_attributes_on_hover: true,
|
59
69
|
)
|
60
70
|
```
|
61
71
|
|
62
|
-

|
72
|
+

|
73
|
+
|
74
|
+
Basic Line Graph Example:
|
75
|
+
|
76
|
+
[examples/graphs_and_charts/basic_line_graph.rb](/examples/graphs_and_charts/basic_line_graph.rb)
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
require 'glimmer-dsl-libui'
|
80
|
+
require 'glimmer/view/line_graph'
|
81
|
+
|
82
|
+
class BasicLineGraph
|
83
|
+
include Glimmer::LibUI::Application
|
84
|
+
|
85
|
+
before_body do
|
86
|
+
@start_time = Time.now
|
87
|
+
end
|
88
|
+
|
89
|
+
body {
|
90
|
+
window('Basic Line Graph', 900, 330) {
|
91
|
+
line_graph(
|
92
|
+
width: 900,
|
93
|
+
height: 300,
|
94
|
+
graph_point_distance: :width_divided_by_point_count,
|
95
|
+
lines: [
|
96
|
+
{
|
97
|
+
name: 'Feature A',
|
98
|
+
stroke: [163, 40, 39, thickness: 2],
|
99
|
+
x_value_start: @start_time,
|
100
|
+
x_interval_in_seconds: 8,
|
101
|
+
x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
|
102
|
+
y_values: [80, 36, 10, 60, 20, 110, 16, 5, 36, 1, 77, 15, 3, 34, 8, 63, 12, 17, 90, 28, 70]
|
103
|
+
},
|
104
|
+
{
|
105
|
+
name: 'Feature B',
|
106
|
+
stroke: [47, 109, 104, thickness: 2],
|
107
|
+
x_value_start: @start_time,
|
108
|
+
x_interval_in_seconds: 8,
|
109
|
+
x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
|
110
|
+
y_values: [62, 0, 90, 0, 0, 27, 0, 56, 0, 0, 24, 0, 60, 0, 30, 0, 47, 0, 38, 90, 0]
|
111
|
+
},
|
112
|
+
],
|
113
|
+
display_attributes_on_hover: true,
|
114
|
+
)
|
115
|
+
}
|
116
|
+
}
|
117
|
+
end
|
118
|
+
|
119
|
+
BasicLineGraph.launch
|
120
|
+
```
|
121
|
+
|
122
|
+

|
63
123
|
|
64
124
|
Contributing to glimmer-libui-cc-graphs_and_charts
|
65
125
|
------------------------------------------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -0,0 +1,44 @@
|
|
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
|
+
before_body do
|
11
|
+
@start_time = Time.now
|
12
|
+
end
|
13
|
+
|
14
|
+
body {
|
15
|
+
window('Basic Line Graph', 900, 330) {
|
16
|
+
line_graph(
|
17
|
+
width: 900,
|
18
|
+
height: 300,
|
19
|
+
graph_point_distance: :width_divided_by_point_count,
|
20
|
+
lines: [
|
21
|
+
{
|
22
|
+
name: 'Feature A',
|
23
|
+
stroke: [163, 40, 39, thickness: 2],
|
24
|
+
x_value_start: @start_time,
|
25
|
+
x_interval_in_seconds: 8,
|
26
|
+
x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
|
27
|
+
y_values: [80, 36, 10, 60, 20, 110, 16, 5, 36, 1, 77, 15, 3, 34, 8, 63, 12, 17, 90, 28, 70]
|
28
|
+
},
|
29
|
+
{
|
30
|
+
name: 'Feature B',
|
31
|
+
stroke: [47, 109, 104, thickness: 2],
|
32
|
+
x_value_start: @start_time,
|
33
|
+
x_interval_in_seconds: 8,
|
34
|
+
x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
|
35
|
+
y_values: [62, 0, 90, 0, 0, 27, 0, 56, 0, 0, 24, 0, 60, 0, 30, 0, 47, 0, 38, 90, 0]
|
36
|
+
},
|
37
|
+
],
|
38
|
+
display_attributes_on_hover: true,
|
39
|
+
)
|
40
|
+
}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
BasicLineGraph.launch
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Generated by juwelier
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: glimmer-libui-cc-graphs_and_charts 0.1.1 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "glimmer-libui-cc-graphs_and_charts".freeze
|
9
|
+
s.version = "0.1.1"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["Andy Maleh".freeze]
|
14
|
+
s.date = "2023-12-16"
|
15
|
+
s.description = "Graphs and Charts (Custom Controls) for Glimmer DSL for LibUI, like Line Graph.".freeze
|
16
|
+
s.email = "andy.am@gmail.com".freeze
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"CHANGELOG.md",
|
19
|
+
"LICENSE.txt",
|
20
|
+
"README.md"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
"CHANGELOG.md",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.md",
|
26
|
+
"VERSION",
|
27
|
+
"examples/graphs_and_charts/basic_line_graph.rb",
|
28
|
+
"glimmer-libui-cc-graphs_and_charts.gemspec",
|
29
|
+
"lib/glimmer-libui-cc-graphs_and_charts.rb",
|
30
|
+
"lib/glimmer/view/line_graph.rb"
|
31
|
+
]
|
32
|
+
s.homepage = "http://github.com/AndyObtiva/glimmer-libui-cc-graphs_and_charts".freeze
|
33
|
+
s.licenses = ["MIT".freeze]
|
34
|
+
s.rubygems_version = "3.4.6".freeze
|
35
|
+
s.summary = "Graphs and Charts - Glimmer DSL for LibUI Custom Controls".freeze
|
36
|
+
|
37
|
+
s.specification_version = 4
|
38
|
+
|
39
|
+
s.add_runtime_dependency(%q<glimmer-dsl-libui>.freeze, ["~> 0.11"])
|
40
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
41
|
+
s.add_development_dependency(%q<juwelier>.freeze, ["= 2.4.9"])
|
42
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
43
|
+
end
|
44
|
+
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'glimmer-dsl-libui'
|
2
|
+
|
1
3
|
module Glimmer
|
2
4
|
module View
|
3
5
|
# General-Purpose Line Graph Custom Control
|
@@ -236,8 +238,9 @@ module Glimmer
|
|
236
238
|
|
237
239
|
def y_value_max_for_all_lines
|
238
240
|
if @y_value_max_for_all_lines.nil?
|
239
|
-
|
240
|
-
|
241
|
+
line_visible_y_values = lines.map { |line| line[:y_values][0, max_visible_point_count(line)] }
|
242
|
+
all_visible_y_values = line_visible_y_values.reduce(:+)
|
243
|
+
@y_value_max_for_all_lines = all_visible_y_values.max.to_f
|
241
244
|
end
|
242
245
|
@y_value_max_for_all_lines
|
243
246
|
end
|
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.1.
|
4
|
+
version: 0.1.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: 2023-12-
|
11
|
+
date: 2023-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer-dsl-libui
|
@@ -66,17 +66,22 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description: Graphs
|
69
|
+
description: Graphs and Charts (Custom Controls) for Glimmer DSL for LibUI, like Line
|
70
|
+
Graph.
|
70
71
|
email: andy.am@gmail.com
|
71
72
|
executables: []
|
72
73
|
extensions: []
|
73
74
|
extra_rdoc_files:
|
75
|
+
- CHANGELOG.md
|
74
76
|
- LICENSE.txt
|
75
77
|
- README.md
|
76
78
|
files:
|
79
|
+
- CHANGELOG.md
|
77
80
|
- LICENSE.txt
|
78
81
|
- README.md
|
79
82
|
- VERSION
|
83
|
+
- examples/graphs_and_charts/basic_line_graph.rb
|
84
|
+
- glimmer-libui-cc-graphs_and_charts.gemspec
|
80
85
|
- lib/glimmer-libui-cc-graphs_and_charts.rb
|
81
86
|
- lib/glimmer/view/line_graph.rb
|
82
87
|
homepage: http://github.com/AndyObtiva/glimmer-libui-cc-graphs_and_charts
|
@@ -101,5 +106,5 @@ requirements: []
|
|
101
106
|
rubygems_version: 3.4.6
|
102
107
|
signing_key:
|
103
108
|
specification_version: 4
|
104
|
-
summary: Graphs
|
109
|
+
summary: Graphs and Charts - Glimmer DSL for LibUI Custom Controls
|
105
110
|
test_files: []
|