Dashed and dotted lines

189 views
Skip to first unread message

Aureliano Calvo

unread,
Dec 4, 2009, 11:09:44 AM12/4/09
to prot...@googlegroups.com
I've been trying to make dashed and dotted lines using pv.Line marks but I can't make them. How should I do them?

Jamie Love

unread,
Dec 4, 2009, 10:58:44 PM12/4/09
to prot...@googlegroups.com
Hi there,

Protovis 3.1 doesn't come with the ability, but you can easily add it. Attached is Protovis-d3.1 with the addition of the three lines of code needed (search for "Added by Jamie Love").

Using this, you can do:


    vis.add (pv.Line)
        .data (futureData)
        .left (function(d) xscale(this.index))
        .bottom (function(d) yscale(d))
        .lineWidth(3)
        .strokeStyle("#aa0000")
        .strokeDasharray("9, 5, 3");

where the new function 'strokeDasharray()' allows you to define the dash approach you want (see http://oreilly.com/catalog/svgess/chapter/ch03.html for a little information - search for stroke-dasharray). For what is basically dots, you can do:

.strokeDasharray ("1, 2")


Cheers
Jamie

On Sat, Dec 5, 2009 at 5:09 AM, Aureliano Calvo <aurelia...@gmail.com> wrote:
I've been trying to make dashed and dotted lines using pv.Line marks but I can't make them. How should I do them?

--

You received this message because you are subscribed to the Google Groups "protovis" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protovis+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protovis?hl=en.

protovis-d3.1.js

Aureliano Calvo

unread,
Dec 4, 2009, 11:07:34 PM12/4/09
to prot...@googlegroups.com
Wow! Now I have a strokeDasharray enabled protovis and a very simple "how-to support other svg attributes" guide.

Thank you very much!
Reply all
Reply to author
Forward
0 new messages