Support for legends

17 views
Skip to first unread message

Lucello

unread,
Mar 25, 2011, 1:42:39 PM3/25/11
to plotkit
I was reading through all the posts on legends and trying to make it
work, with no luck. The links to the blogspot article no longer work,
and importing the Legend.js page and adding in the javascript code
seems to do nothing. Anyone know how to make this work?

Any help would be greatly appreciated.

Per Cederberg

unread,
Apr 9, 2011, 6:40:38 AM4/9/11
to plo...@googlegroups.com, Lucello
Was in the same situation, so I added it to my chart-wrapping class:

LineChart.prototype.add = function (set, xval, yval) {
if (this.sets[set] == null) {
this.legend.push(set);
}
...
}

LineChart.prototype.renderLegend = function (container) {
var colorScheme = this.options.colorScheme;
var rows = [];
for (var i = 0; i < this.legend.length; i++) {
var name = this.legend[i];
var color = colorScheme[i % colorScheme.length];
var style = { float: "left", marginRight: "2px", width: "8px",
height: "8px", border: "1px solid white", background: color };
var span = MochiKit.DOM.DIV({ style: style });
rows.push(MochiKit.DOM.DIV({}, span, name));
}
MochiKit.DOM.replaceChildNodes(container, rows);
}

Cheers,

/Per

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

Reply all
Reply to author
Forward
0 new messages