';
// do the x-axis
for (i = 0; i < xaxis.ticks.length; ++i) {
@@ -774,79 +866,6 @@
target.append(html);
}
- function fillInSeriesOptions() {
- var i;
-
- // collect what we already got of colors
- var neededColors = series.length;
- var usedColors = [];
- var assignedColors = [];
- for (i = 0; i < series.length; ++i) {
- var sc = series[i].color;
- if (sc != null) {
- --neededColors;
- if (typeof sc == "number")
- assignedColors.push(sc);
- else
- usedColors.push(parseColor(series[i].color));
- }
- }
-
- // we might need to generate more colors if higher indices
- // are assigned
- for (i = 0; i < assignedColors.length; ++i) {
- neededColors = Math.max(neededColors, assignedColors[i] + 1);
- }
-
- // produce colors as needed
- var colors = [];
- var variation = 0;
- i = 0;
- while (colors.length < neededColors) {
- var c;
- if (options.colors.length == i) // check degenerate case
- c = new Color(100, 100, 100);
- else
- c = parseColor(options.colors[i]);
-
- // vary color if needed
- var sign = variation % 2 == 1 ? -1 : 1;
- var factor = 1 + sign * Math.ceil(variation / 2) * 0.2;
- c.scale(factor, factor, factor);
-
- // FIXME: if we're getting to close to something else,
- // we should probably skip this one
- colors.push(c);
-
- ++i;
- if (i >= options.colors.length) {
- i = 0;
- ++variation;
- }
- }
-
- // fill in the options
- var colori = 0;
- for (i = 0; i < series.length; ++i) {
- var s = series[i];
-
- // assign colors
- if (s.color == null) {
- s.color = colors[colori].toString();
- ++colori;
- }
- else if (typeof s.color == "number")
- s.color = colors[s.color].toString();
-
- // copy the rest
- s.lines = $.extend(true, {}, options.lines, s.lines);
- s.points = $.extend(true, {}, options.points, s.points);
- s.bars = $.extend(true, {}, options.bars, s.bars);
- if (s.shadowSize == null)
- s.shadowSize = options.shadowSize;
- }
- }
-
function drawSeries(series) {
if (series.lines.show || (!series.bars.show && !series.points.show))
drawSeriesLines(series);
@@ -1256,6 +1275,8 @@
}
function insertLegend() {
+ target.find(".legend").remove();
+
if (!options.legend.show)
return;
@@ -1298,7 +1319,7 @@
pos += 'right:' + (m + plotOffset.right) + 'px;';
else if (p.charAt(1) == "w")
pos += 'left:' + (m + plotOffset.bottom) + 'px;';
- var div = $('
' + table + '
').appendTo(target);
+ var legend = $('
' + table.replace('style="', 'style="position:absolute;' + pos +';') + '
').appendTo(target);
if (options.legend.backgroundOpacity != 0.0) {
// put in the transparent background
// separately to avoid blended labels and
@@ -1309,10 +1330,11 @@
if (options.grid.backgroundColor != null)
tmp = options.grid.backgroundColor;
else
- tmp = extractColor(div);
+ tmp = extractColor(legend);
c = parseColor(tmp).adjust(null, null, null, 1).toString();
}
- $('
').appendTo(target).css('opacity', options.legend.backgroundOpacity);
+ var div = legend.children();
+ $('
').prependTo(legend).css('opacity', options.legend.backgroundOpacity);
}
}