Permalink
Browse files

Implementation of opts.rangecolors option for linechart.

This option allows you to specify a Javascript object with numbers as the key
and color strings as the value. If the value y value we're plotting is larger
than a key in opts.rangecolors, the fill symbol for that value will change to
the color specified.
  • Loading branch information...
1 parent 6143828 commit 4462be24cfa77c875cda083e04510b744f32b5b3 Matt Farmer committed Apr 4, 2012
Showing with 11 additions and 2 deletions.
  1. +11 −2 g.line.js
View
@@ -121,9 +121,11 @@
line;
for (i = 0, ii = valuesy.length; i < ii; i++) {
+ var fillcolor = colors[i];
+
if (!opts.nostroke) {
lines.push(line = paper.path().attr({
- stroke: colors[i],
+ stroke: fillcolor,
"stroke-width": opts.width || 2,
"stroke-linejoin": "round",
"stroke-linecap": "round",
@@ -140,7 +142,14 @@
var X = x + gutter + ((valuesx[i] || valuesx[0])[j] - minx) * kx,
Y = y + height - gutter - (valuesy[i][j] - miny) * ky;
- (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" }));
+ if (opts.rangecolors) {
+ for (rangeMinimum in opts.rangecolors) {
+ if (valuesy[i][j] > rangeMinimum)
+ fillcolor = opts.rangecolors[rangeMinimum];
+ }
+ }
+
+ (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: fillcolor, stroke: "none" }));
if (opts.smooth) {
if (j && j != jj - 1) {

0 comments on commit 4462be2

Please sign in to comment.