Having issues with drawing a rectangle and using links

2 views
Skip to first unread message

andy_c

unread,
Aug 18, 2009, 1:53:14 PM8/18/09
to ZiYa Plugin
Hello,

I am trying to draw a rectangle and use links on my web page but I
have so far been unsuccessful. I have to put the code in the
controller and not in a style sheet because the size of the rectangle
and the link area can change based upon the data that is being
processed. Basically, my question is what is the syntax for drawing a
rectangle and using links? Below is what I have tried so far:

def load_chart
# Chart will be rendered using the default look and feel
chart = Ziya::Charts::FloatingBar.new

...code...

# Draw rectangle, first try
chart.draw.rect.x = '100'
chart.draw.rect.y = '100'
etc...

# Draw rectangle, second try
chart.rect.x = '100'
chart.rect.y = '100'
etc...

# Create a link, first try
chart.link.area.x = '100'
chart.link.area.y = '100'
etc...

# Create a link, second try
chart.link.x = '100'
chart.link.y = '100'
etc...

# Create a link, thrid try
chart.area.x = '100'
chart.area.y = '100'
etc...

end

Any help or guidance would be greatly appreciated. Thanks.

Fernand Galiana

unread,
Aug 18, 2009, 10:58:08 PM8/18/09
to ziya-...@googlegroups.com
Hi Andy,

  You actually need to use the chart yml stylesheet to produce your links
  You can look at the sample galeria app for examples.

  Typically you would define a link componet with several area sub components
  describing a click area as follows:

  Note: Mind the yaml spacing which won't be correct in this email

  <%=comp :link %>
    areas:
      - <%=area :area_1 %>
          x:                    340
          y:                    225
          width:             20
          height:            15
          url:                  'www.cnn.com
          target:              _self
          tooltip:            Full Screen Mode
      - <%=area :area_2 %>
          ...

     Since the data is coming from your controller you can specify a user object to gather
     one or more area description and then iterate using the regular erb tags ie something like

     blee_controller.rb

    
     chart = Ziya::Charts::FloatingBar.new
     ....
     chart.add :user_data, :areas, { 'area_1' => { :x => 0, :y => 0, :width => 20, :height => 20, :url => 'xxx' } }

     floating_bar_chart.yml

     <%=comp :link %>
         areas:
             <% options[:areas].each_pair do |name, vector| %>
              - <%=area name %>
                  x: vector[:x]
                  y: vector[:y]
                  ...
              <% end %>
     
      Now if the linkable areas are regular charts element ie clicking on a bar in your floating bar chart you may
      want to take a look at linked_data component in the ziya galeria app as you'll get all the target area
      for free... NOTE: You will need a license to make the chart clickable in either cases...

-Fernand

andy_c

unread,
Aug 19, 2009, 11:20:12 AM8/19/09
to ZiYa Plugin
Thanks for the help. I would very much like to use the linked_data
component because I would get all the target area of the bars for
free, expect the linked_data component does not have a tooltip option
like the link component. What I am basically looking to do is have a
floating bar chart that when you mouse over the bars a tooltip pops up
and when you click on a bar it brings up another chart. At first I
was going to use the tooltip option in chart.add(:series
, [{:value => number, :label => text, :tooltip => tooltip_text}]), but
this only displays a tooltip at the ends of the bar. And I have not
tried the linked_data component because I have not purchased a license
yet and would not be able to confirm if I implemented it correctly.
Also I am unsure if the linked_data component would properly work with
a floating bar chart, and what I mean by this is will it actually give
me the entire target area of the bar or just the ends of the bars like
with the tooltip option. That is why I am trying to use the link
component because it does have a tooltip option and I was going to try
to match up the area covered by the link with the bars of the floating
bar chart. If you know of an easier and better way of doing this I
would appreciate the advice. Thanks.
> > Any help or guidance would be greatly appreciated.  Thanks.- Hide quoted text -
>
> - Show quoted text -

Fernand Galiana

unread,
Aug 20, 2009, 1:07:32 AM8/20/09
to ziya-...@googlegroups.com
Hi Andy,

  Either way you implement this you will need a license to enable the links. I am a bit
  confused here since the link_data should work just fine for what you are trying to accomplish
  If you ommit the label in your series definition and leave the tooltip then you should get the
  desired effect. The tooltip will apply for each bars in your chart.

-Fernand

andy_c

unread,
Aug 20, 2009, 12:04:16 PM8/20/09
to ZiYa Plugin
Hello Fernand,

I omitted the label in my series and it still appears to only show the
tooltip at the ends of the bars when using a floating bar chart. I
think this is inherent to the floating bar chart because you have to
specify two series in order to create one set of bars (high values and
low values). What I would like is a tooltip to appear if I mouse over
any part of the bar, not just the ends. And the only way I can think
of doing this is using the link component and try to cover the bar
with the link area. I would appreciate any comments, thoughts, or
other methods for doing this. Thanks.


On Aug 19, 11:07 pm, Fernand Galiana <fernand.gali...@gmail.com>
wrote:
> Hi Andy,
>
> > > - Show quoted text -- Hide quoted text -

andy_c

unread,
Aug 20, 2009, 5:52:19 PM8/20/09
to ZiYa Plugin
Hello again Fernand,

I implemented the linked data component and sent the code to a friend
who has a license, and he says the link only appears over the ends of
the bars in the floating bar chart. I think that this is just
inherent with a floating bar chart. I would really like to be able to
mouse over any part of the bar and a tooltip would appear and could
click on any part of the bar to activate the link, but it looks like
this may not be possible with a floating bar chart. Any thoughts or
comments? Thanks.

Fernand Galiana

unread,
Aug 21, 2009, 2:07:27 AM8/21/09
to ziya-...@googlegroups.com
Hi Andy,

   Thanks for the feedback !

   At first glance, I am getting the same results. I see what you are saying now but
   will need to investigate a bit more. This is certainly surprising as it does not behave
   like the other chart types once a link_data is specified....

-Fernand

Fernand Galiana

unread,
Aug 24, 2009, 1:53:45 PM8/24/09
to ziya-...@googlegroups.com
Hi Andy,

   Yes - you are correct. The floating bars only support tooltips on each end of the bars.
   That's lame imho. I've pinged the xml/swf guys and it looks like this is by design, which
   I think is a very bad usability feature ie behaves different from all the other charts.
  
   If you have a license you may want to ping them with that issue...

-Fernand
Reply all
Reply to author
Forward
0 new messages