From 1f935a22b91a9883db1af75f2654994c2f303c7e Mon Sep 17 00:00:00 2001 From: Miquel Torres Date: Tue, 1 Jun 2010 10:56:34 +0200 Subject: [PATCH] Move legend outside plot area when too many series present --- speedcenter/media/js/codespeed.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/speedcenter/media/js/codespeed.js b/speedcenter/media/js/codespeed.js index 07bf8e7c..804f0a08 100644 --- a/speedcenter/media/js/codespeed.js +++ b/speedcenter/media/js/codespeed.js @@ -249,6 +249,17 @@ function renderComparisonPlot(plotid, benchmarks, exes, enviros, baseline, chart } plotoptions.legend = {show: true, location: 'ne'}; plotoptions.series = series; + if (!horizontal && series.length > 5) { + var labels = new Array(); + for (l in series) { + labels.push(series[l]['label'].length) + } + + var offset = 55 + Math.max.apply( Math, labels ) * 5.4; + plotoptions.legend.xoffset = -offset; + $("#" + plotid).css("margin-right", offset + 10); + if (w + offset > plotwidth) { w = plotwidth - offset -20; } + } if (chart == "stacked bars") { plotoptions.stackSeries = true; }