DmitryBaranovskiy / g.raphael

Charts for Raphaël
http://g.raphaeljs.com/
1.51k stars 435 forks source link

is it possible to have discontinuous line graphs? #38

Open jessicah opened 14 years ago

jessicah commented 14 years ago

I'd like to use the line graphing for a sports tracker type web app, and when a workout has a break in it (e.g. paused at one spot, and resumed at another), i would like to represent the break as a discontinuity in the line graph, e.g. the two endpoints on either side of the 'break' as open circles joined by a straight dashed line, whereas the normal continuous line would be solid.

davidsonff commented 11 years ago

I am also wondering this... Frequently when graphing data it is useful to have a gap when data is not present. Right now I am looking at modifying the graphael source to see if I can change some of the path "L"s to "M"s, but it seems like a useful thing to add...

davidsonff commented 11 years ago

I changed line 193 of g.line.js to:

                path = path.concat([(j && (valuesy[i][j] !== null)) ? "L" : "M", X, Y]);

... and I'm testing it now.... If passed a null y value it skips that point (so far!)...

davidsonff commented 11 years ago

Changed it again to account for null x values:

                path = path.concat([(j && (valuesy[i][j] !== null) && ((valuesx[i] || valuesx[0])[j] !== null)) ? "L" : "M", X, Y]);
davidsonff commented 11 years ago

g.line.js v. 0.51 that is... Sorry to be leaving so many comments...

Fiendfyre commented 11 years ago

Line 193 should be this, so the line graph won't start from a y-datapoint which is null path = path.concat([(j && (valuesy[i][j] !== null && valuesy[i][j-1] !== null))? "L" : "M", X, Y]);

Adding if(valuesy[i][j] !=null) around this line : (Raphael.is(sym, "array") ? sym[j] : sym) && symset.push(paper[Raphael.is(sym, "array") ? sym[j] : sym](X, Y, (opts.width || 2) * 3).attr({ fill: colors[i], stroke: "none" })); would prevent symbol being created for y - datapoint with null

correct me, if i'm wrong