From 2abf246a85dabc3608439122cfa4990a2c989fd7 Mon Sep 17 00:00:00 2001 From: rozetko Date: Thu, 11 Jul 2024 18:26:15 +0300 Subject: [PATCH] right y-axis: render label --- src/index.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index dfb5abf..bcfc47a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -116,6 +116,7 @@ class ChartwerkPod { this.renderLegend(); this.renderYLabel(); + this.renderY1Label(); this.renderXLabel(); this.options.callbackRenderEnd(); @@ -509,8 +510,8 @@ class ChartwerkPod { return; } this.chartContainer.append('text') - .attr('y', 0 - this.margin.left) - .attr('x', 0 - (this.height / 2)) + .attr('y', -this.margin.left) + .attr('x', -(this.height / 2)) .attr('dy', '1em') .attr('class', 'y-axis-label') .attr('transform', 'rotate(-90)') @@ -520,6 +521,22 @@ class ChartwerkPod { .text(this.options.axis.y.label); } + protected renderY1Label(): void { + if(this.options.axis.y1?.label === undefined) { + return; + } + this.chartContainer.append('text') + .attr('y', -this.width - this.margin.right) + .attr('x', (this.height / 2)) + .attr('dy', '1em') + .attr('class', 'y-axis-label') + .attr('transform', 'rotate(90)') + .style('text-anchor', 'middle') + .style('font-size', '14px') + .style('fill', 'currentColor') + .text(this.options.axis.y1.label); + } + protected renderXLabel(): void { if(this.options.axis.x.label === undefined) { return;