Merge pull request #154 from TechMiX/fixGraphLegendBug

Fix graph legend bug on resize
This commit is contained in:
softsimon 2020-11-15 00:39:22 +07:00 committed by GitHub
commit 1e39daafb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -319,7 +319,11 @@ Chartist.plugins.legend = function (options: any) {
chart.on('created', function (data: any) {
if (isSelfUpdate)
const useLabels = chart instanceof Chartist.Pie && chart.data.labels && chart.data.labels.length;
const legendNames = getLegendNames(useLabels);
var dirtyChartData = (chart.data.series.length < legendNames.length);
if (isSelfUpdate || dirtyChartData)
return;
function removeLegendElement() {
@ -476,8 +480,6 @@ Chartist.plugins.legend = function (options: any) {
removeLegendElement();
const legendElement = createLegendElement();
const useLabels = chart instanceof Chartist.Pie && chart.data.labels && chart.data.labels.length;
const legendNames = getLegendNames(useLabels);
const seriesMetadata = initSeriesMetadata(useLabels);
const legends: any = [];