Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
funny interaction between pv.Line and pv.Rule
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
OliverM  
View profile  
 More options Sep 8 2010, 6:51 am
From: OliverM <oliver.moo...@gmail.com>
Date: Wed, 8 Sep 2010 03:51:19 -0700 (PDT)
Local: Wed, Sep 8 2010 6:51 am
Subject: funny interaction between pv.Line and pv.Rule
Hi,

I'm new to protovis so amn't sure if I'm making a mistake or running
into a bug. I think the following code should show a line graph with a
horizontal rule at its base. Instead a vertical rule is added for
every point in the line. This is using protovis 3.2 on OS X in Safari
5 and Firefox 3.6. Strange behaviour is also seen when specifying
top(), left() or right(). If it is a bug I'll put it up on the
tracker.

Thanks,
Oliver.

var w = 150, h =150;
var tempScale = pv.Scale.linear(0, 12).range(0, h);
var tempVis = new pv.Panel()
                                        .width(w)
                                        .height(h)
                                        .add(pv.Line)
                                                .data([1, 1, 2, 3, 4, 2, 5, 7, 11])
                                                .left(function() this.index * w/9)
                                                .bottom(function(datum) tempScale(datum))
                                                ;
tempVis.add(pv.Rule)
                .bottom(0);

tempVis.render();


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Davies  
View profile  
 More options Sep 8 2010, 11:37 am
From: Jason Davies <ja...@jasondavies.com>
Date: Wed, 8 Sep 2010 16:37:10 +0100
Local: Wed, Sep 8 2010 11:37 am
Subject: Re: funny interaction between pv.Line and pv.Rule
Hi Oliver,

On 8 Sep 2010, at 11:51, OliverM wrote:

> var w = 150, h =150;
> var tempScale = pv.Scale.linear(0, 12).range(0, h);
> var tempVis = new pv.Panel()
>                                    .width(w)
>                                    .height(h)
>                                    .add(pv.Line)
>                                            .data([1, 1, 2, 3, 4, 2, 5, 7, 11])
>                                            .left(function() this.index * w/9)
>                                            .bottom(function(datum) tempScale(datum))
>                                            ;
> tempVis.add(pv.Rule)
>            .bottom(0);

> tempVis.render();

Note that tempVis refers to the pv.Line mark added to the panel, hence 'tempVis.add(pv.Rule)' will inherit the properties of the pv.Line mark, and so will inherit its 'data' property too and will show for every datum.  It also inherits the 'left' property, which is why vertical rules are showing rather than a horizontal one.  To fix this you probably want something like:

var tempVis = new pv.Panel()
                .width(w)
                .height(h);

tempVis.add(pv.Line)
                .data([1, 1, 2, 3, 4, 2, 5, 7, 11])
                .left(function() this.index * w/9)
                .bottom(function(datum) tempScale(datum));

tempVis.add(pv.Rule)
                .bottom(0);

tempVis.render();

--
Jason Davies

www.jasondavies.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
OliverM  
View profile  
 More options Sep 8 2010, 1:50 pm
From: OliverM <oliver.moo...@gmail.com>
Date: Wed, 8 Sep 2010 10:50:36 -0700 (PDT)
Local: Wed, Sep 8 2010 1:50 pm
Subject: Re: funny interaction between pv.Line and pv.Rule
Hi Jason,

Thanks for your post - I just had a lightbulb moment as a result! I'd
not properly grasped the how the property chaining mechanism returned
the final version as you pointed out. Thanks! Hopefully things will
click now.

Oliver.

On Sep 8, 4:37 pm, Jason Davies <ja...@jasondavies.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »