File: 3_grouped_bars.rb

package info (click to toggle)
ruby-rubyvis 0.6.1%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 1,808 kB
  • ctags: 679
  • sloc: ruby: 11,114; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 663 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# = Using parent
# This example shows how to group bars on groups and use the parent property to identify and color them
$:.unshift(File.dirname(__FILE__)+"/../../lib")
require 'rubyvis'

vis = pv.Panel.new().width(200).height(150);

bar= vis.add(pv.Panel).data(["a","b","c","d"]).add(pv.Bar)
    .data([1,2])
    .width(20)
    .height(lambda {60+parent.index*20+index*5})
    .bottom(0)
    .left(lambda {|d,t| parent.index*60+index*25})
    
 bar.anchor("bottom").add(pv.Label).
   text(lambda {|d,t| "#{t}-#{d}"})
 bar.anchor("top").add(pv.Label).
   text(lambda {"#{parent.index}-#{index}"})
    
    
vis.render()
#puts vis.children_inspect
puts vis.to_svg