From 0866234001c25ce81a4d7d25804b74e0a9e5d83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6khan=20=C3=96zen?= Date: Mon, 10 Aug 2015 17:07:48 +0200 Subject: [PATCH] show legend for gauges which have more than one arc --- src/core.js | 2 +- src/legend.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index 60ee0c5..3da0bda 100644 --- a/src/core.js +++ b/src/core.js @@ -221,7 +221,7 @@ c3_chart_internal_fn.initWithData = function (data) { } // when gauge, hide legend // TODO: fix - if ($$.hasType('gauge')) { + if ($$.hasType('gauge') && $$.config.data_columns.length <= 1) { config.legend_show = false; } diff --git a/src/legend.js b/src/legend.js index 158b503..a926b4e 100644 --- a/src/legend.js +++ b/src/legend.js @@ -307,7 +307,9 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { tiles = $$.legend.selectAll('line.' + CLASS.legendItemTile) .data(targetIds); (withTransition ? tiles.transition() : tiles) - .style('stroke', $$.color) + .style('stroke', $$.levelColor ? function(id) { + return $$.levelColor($$.cache[id].values[0].value); + } : $$.color) .attr('x1', x1ForLegendTile) .attr('y1', yForLegendTile) .attr('x2', x2ForLegendTile)