glimmer-libui-cc-graphs_and_charts 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2a02d818ffec27e5d64eafa181c90e1362b62ea8f201018fe92705b0d95a664
4
- data.tar.gz: 6de4a548a1c74d91cc389663d9917311bd66523402ba984ac05a250d8cff5baa
3
+ metadata.gz: e5c81413f717dac087558fbed16937659603f9bb6a4a2b849cadf31bade1750c
4
+ data.tar.gz: c76f09ab3cff5d2486c45c59841ed1bacff95ad6d7b63033e01965318adef73e
5
5
  SHA512:
6
- metadata.gz: 738a36dedf90e91774876d7cc41f545edb00ac03d65cd6bf89eaf30eac5374b4abfa591d007d971476a02dd854ca14a262a7fcda34fdc24ac531b17509ee0dcf
7
- data.tar.gz: 2039bf32f7d8fb7930c24fda0eba1def6c30db968d452cb219a7ceab604bfed450b87b8d68ae061d75017ea59f6161d46b9fbebd8ab5581727116ebfd32fec82
6
+ metadata.gz: 82239ec1af1f0186761ac787f94d2f5756abc9cc17ea67dbaf5f38f9b27c35cc834c947f46df19309bee5f425d9a764a0ed335163bcc764a2e84b44d6ebf7b4a
7
+ data.tar.gz: 65c1a640f16352f4ec249bff010824872b4c7bea47d818d7264fc4c2b9c57ab40307f32fa0f22c449944d3d7ab51cd07d4ae513e12255d2a7da9de4cb6e46fe3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.1.8
4
+
5
+ - Fix the display of grid marker lines when passing `values` with non-Integer y-axis values (especially max y-axis value being non-Integer). It now shows highest grid marker having a non-Integer value while keeping smaller values as Integer (e.g. 1, 2, 3, 3.75).
6
+
3
7
  ## 0.1.7
4
8
 
5
9
  - Scale `y` axis when using `values` option to fill up the vertical graph height if all y-axis values are smaller than `1`
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Graphs and Charts 0.1.7 (Alpha)
1
+ # Graphs and Charts 0.1.8 (Alpha)
2
2
  ## [Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui) Custom Controls
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-libui-cc-graphs_and_charts.svg)](http://badge.fury.io/rb/glimmer-libui-cc-graphs_and_charts)
4
4
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -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.7'
15
+ gem 'glimmer-libui-cc-graphs_and_charts', '~> 0.1.8'
16
16
  ```
17
17
 
18
18
  Run:
@@ -183,7 +183,7 @@ BasicLineGraph.launch
183
183
  require 'glimmer-dsl-libui'
184
184
  require 'glimmer/view/line_graph'
185
185
 
186
- class BasicLineGraph
186
+ class BasicLineGraphRelative
187
187
  include Glimmer::LibUI::Application
188
188
 
189
189
  before_body do
@@ -191,7 +191,7 @@ class BasicLineGraph
191
191
  end
192
192
 
193
193
  body {
194
- window('Basic Line Graph', 900, 330) {
194
+ window('Basic Line Graph Relative', 900, 330) {
195
195
  line_graph(
196
196
  width: 900,
197
197
  height: 300,
@@ -220,7 +220,7 @@ class BasicLineGraph
220
220
  }
221
221
  end
222
222
 
223
- BasicLineGraph.launch
223
+ BasicLineGraphRelative.launch
224
224
  ```
225
225
 
226
226
  ![basic line graph relative](/screenshots/glimmer-libui-cc-graphs_and_charts-mac-basic-line-graph-relative.png)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.1.8
@@ -17,11 +17,11 @@ class BasicLineGraph
17
17
  name: 'Stock 1',
18
18
  stroke: [163, 40, 39, thickness: 2],
19
19
  values: {
20
- Time.new(2030, 12, 1) => 80,
21
- Time.new(2030, 12, 2) => 36,
22
- Time.new(2030, 12, 4) => 10,
23
- Time.new(2030, 12, 5) => 60,
24
- Time.new(2030, 12, 6) => 20,
20
+ Time.new(2030, 12, 1) => 2,
21
+ Time.new(2030, 12, 2) => 2.5,
22
+ Time.new(2030, 12, 4) => 1,
23
+ Time.new(2030, 12, 5) => 0,
24
+ Time.new(2030, 12, 6) => 2,
25
25
  },
26
26
  x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
27
27
  },
@@ -29,11 +29,11 @@ class BasicLineGraph
29
29
  name: 'Stock 2',
30
30
  stroke: [47, 109, 104, thickness: 2],
31
31
  values: {
32
- Time.new(2030, 12, 1) => 62,
32
+ Time.new(2030, 12, 1) => 2,
33
33
  Time.new(2030, 12, 2) => 0,
34
- Time.new(2030, 12, 3) => 90,
35
- Time.new(2030, 12, 5) => 0,
36
- Time.new(2030, 12, 7) => 17,
34
+ Time.new(2030, 12, 3) => 2.5,
35
+ Time.new(2030, 12, 5) => 1,
36
+ Time.new(2030, 12, 7) => 2,
37
37
  },
38
38
  x_value_format: -> (time) {time.strftime("%a %d %b %Y %T GMT")},
39
39
  },
@@ -4,7 +4,7 @@ $LOAD_PATH.prepend(File.expand_path(File.join(__dir__, '..', '..', 'lib'))) if F
4
4
  require 'glimmer-dsl-libui'
5
5
  require 'glimmer/view/line_graph'
6
6
 
7
- class BasicLineGraph
7
+ class BasicLineGraphRelative
8
8
  include Glimmer::LibUI::Application
9
9
 
10
10
  before_body do
@@ -12,7 +12,7 @@ class BasicLineGraph
12
12
  end
13
13
 
14
14
  body {
15
- window('Basic Line Graph', 900, 330) { |main_window|
15
+ window('Basic Line Graph Relative', 900, 330) { |main_window|
16
16
  @line_graph = line_graph(
17
17
  width: 900,
18
18
  height: 300,
@@ -46,4 +46,4 @@ class BasicLineGraph
46
46
  }
47
47
  end
48
48
 
49
- BasicLineGraph.launch
49
+ BasicLineGraphRelative.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.1.7 ruby lib
5
+ # stub: glimmer-libui-cc-graphs_and_charts 0.1.8 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.1.7".freeze
9
+ s.version = "0.1.8".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 = "2023-12-23"
14
+ s.date = "2023-12-26"
15
15
  s.description = "Graphs and Charts (Custom Controls) for Glimmer DSL for LibUI, like Line Graph.".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -189,13 +189,10 @@ module Glimmer
189
189
  @grid_marker_numbers ||= []
190
190
  @graph_stroke_marker_values ||= []
191
191
  @mod_values ||= []
192
- if lines && lines.all? {|line| line[:values]} && !y_value_max_for_all_lines.nil? && y_value_max_for_all_lines > 1
193
- return
194
- end
195
192
  grid_marker_points.each_with_index do |marker_point, index|
196
193
  @grid_marker_number_values[index] ||= begin
197
194
  value = (grid_marker_points.size - index).to_i
198
- value = y_value_max_for_all_lines if !y_value_max_for_all_lines.nil? && y_value_max_for_all_lines.to_i != y_value_max_for_all_lines && grid_marker_points.size == 1
195
+ value = y_value_max_for_all_lines if !y_value_max_for_all_lines.nil? && y_value_max_for_all_lines.to_i != y_value_max_for_all_lines && index == 0
199
196
  value
200
197
  end
201
198
  grid_marker_number_value = @grid_marker_number_values[index]
@@ -241,15 +238,31 @@ module Glimmer
241
238
 
242
239
  def grid_marker_points
243
240
  if @grid_marker_points.nil?
244
- graph_y_max = [y_value_max_for_all_lines, y_value_max_for_all_lines.between?(0, 1) ? y_value_max_for_all_lines : 1].max
245
- current_graph_height = (height - graph_padding_height * 2)
246
- division_height = current_graph_height / graph_y_max
247
- @grid_marker_points = graph_y_max.ceil.times.map do |marker_index|
248
- x = graph_padding_width
249
- y = graph_padding_height + marker_index * division_height
250
- {x: x, y: y}
241
+ if lines[0]&.[](:y_values)
242
+ graph_y_max = [y_value_max_for_all_lines, 1].max
243
+ current_graph_height = (height - graph_padding_height * 2)
244
+ division_height = current_graph_height / graph_y_max
245
+ @grid_marker_points = graph_y_max.to_i.times.map do |marker_index|
246
+ x = graph_padding_width
247
+ y = graph_padding_height + marker_index * division_height
248
+ {x: x, y: y}
249
+ end
250
+ else
251
+ graph_y_max = y_value_max_for_all_lines
252
+ y_value_count = graph_y_max.ceil
253
+ @grid_marker_points = y_value_count.times.map do |marker_index|
254
+ x = graph_padding_width
255
+ y_value = y_value_count - marker_index
256
+ if marker_index == 0 && graph_y_max.ceil != graph_y_max.to_i
257
+ y_value = graph_y_max
258
+ end
259
+ scaled_y_value = y_value.to_f * y_resolution.to_f
260
+ y = height - graph_padding_height - scaled_y_value
261
+ {x: x, y: y}
262
+ end
251
263
  end
252
264
  end
265
+
253
266
  @grid_marker_points
254
267
  end
255
268
 
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.7
4
+ version: 0.1.8
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-23 00:00:00.000000000 Z
11
+ date: 2023-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer-dsl-libui