From afecbda40555519fab54318e425aef45075c0718 Mon Sep 17 00:00:00 2001 From: Sugan G Date: Fri, 29 Mar 2024 10:24:21 +0530 Subject: [PATCH] add rotation during panning --- packages/carbon-graphs/src/js/helpers/axis.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/carbon-graphs/src/js/helpers/axis.js b/packages/carbon-graphs/src/js/helpers/axis.js index 4432aef06..0ed51e53e 100644 --- a/packages/carbon-graphs/src/js/helpers/axis.js +++ b/packages/carbon-graphs/src/js/helpers/axis.js @@ -1474,7 +1474,24 @@ const translateAxes = (axis, scale, config, canvasSVG) => { config, )})`, ) - .call(axis.x); + .call(axis.x) + .selectAll('text') + .style('text-anchor', () => { + if (!utils.isDefined(config.axis.x.ticks.tickLabelsRotation)) { + config.axis.x.ticks.tickLabelsRotation = 0; + return 'middle'; + } + const rotation = config.axis.x.ticks.tickLabelsRotation; + if (rotation === 0) { + return 'middle'; + } if (rotation !== 0) { + return 'end'; + } if (!utils.validTickLabelRotations.has(rotation)) { + return 'middle'; + } + return 'middle'; + }) + .attr('transform', () => `rotate(${config.axis.x.ticks.tickLabelsRotation})`); canvasSVG .select(`.${styles.axisY}`) .transition()