diff --git a/src/ChartInternal/internals/text.ts b/src/ChartInternal/internals/text.ts index 49cf2d6af..f5de80001 100644 --- a/src/ChartInternal/internals/text.ts +++ b/src/ChartInternal/internals/text.ts @@ -208,7 +208,7 @@ export default { } value = $$.isTreemapType(d) ? $$.treemapDataLabelFormat(d)(node) : - $$.dataLabelFormat(d.id)(value, d.id, i, texts); + $$.dataLabelFormat(d.id)(value, d.id, d.index, texts); if (isNumber(value)) { this.textContent = value; diff --git a/test/internals/text-spec.ts b/test/internals/text-spec.ts index 161ef2151..805dc6b9c 100644 --- a/test/internals/text-spec.ts +++ b/test/internals/text-spec.ts @@ -561,6 +561,8 @@ describe("TEXT", () => { }); describe("as function", () => { + const temp: any = []; + before(() => { args = { data: { @@ -593,6 +595,29 @@ describe("TEXT", () => { expect(d3Select(this).text()).to.equal(""); }); }); + + it("set options", () => { + args = { + data: { + columns: [ + ["data1", 10, 100, null, 150, 200] + ], + labels: { + format: (value, seriesName, columnIndex) => { + if (seriesName) { + temp.push(columnIndex); + } + + return value; + } + } + } + } + }); + + it("index argument should count nullish value", () => { + expect(temp).to.be.deep.equal([0, 1, 3, 4]); + }); }); });