diff --git a/src/Pie.js b/src/Pie.js index 239052b..f9865c1 100644 --- a/src/Pie.js +++ b/src/Pie.js @@ -128,12 +128,11 @@ class Pie { const legendItems = this.data.datasets[0].data .map((data, i) => ({ color: this.options.dataColors[i], text: this.data.labels[i] })); - // move legend down to prevent overlaping with title - const legendG = this.svgEl.append('g') - .attr('transform', 'translate(0, 30)'); - if (this.options.showLegend) { - addLegend(legendG, { + const legendItems = this.data.datasets + .map((data, i) => ({ color: this.options.dataColors[i], text: data.label || '' })); + + addLegend(this.svgEl, { items: legendItems, position: this.options.legendPosition, unxkcdify: this.options.unxkcdify, diff --git a/src/Radar.js b/src/Radar.js index 136c330..65c3be4 100644 --- a/src/Radar.js +++ b/src/Radar.js @@ -229,11 +229,7 @@ class Radar { const legendItems = this.data.datasets .map((data, i) => ({ color: this.options.dataColors[i], text: data.label || '' })); - // move legend down to prevent overlaping with title - const legendG = this.svgEl.append('g') - .attr('transform', 'translate(0, 30)'); - - addLegend(legendG, { + addLegend(this.svgEl, { items: legendItems, position: this.options.legendPosition, unxkcdify: this.options.unxkcdify,