@opendata-ai/openchart-vanilla 6.25.0 → 6.25.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/renderers/axes.ts +14 -8
package/dist/index.js
CHANGED
|
@@ -3632,7 +3632,11 @@ function renderAnnotations(parent, layout) {
|
|
|
3632
3632
|
}
|
|
3633
3633
|
|
|
3634
3634
|
// src/renderers/axes.ts
|
|
3635
|
-
import {
|
|
3635
|
+
import {
|
|
3636
|
+
estimateTextWidth as estimateTextWidth2,
|
|
3637
|
+
getAxisTitleOffset,
|
|
3638
|
+
TICK_LABEL_OFFSET
|
|
3639
|
+
} from "@opendata-ai/openchart-core";
|
|
3636
3640
|
function renderAxis(parent, axis, orientation, layout) {
|
|
3637
3641
|
const g = createSVGElement("g");
|
|
3638
3642
|
const isRight = orientation === "y" && axis.orient === "right";
|
|
@@ -3679,14 +3683,14 @@ function renderAxis(parent, axis, orientation, layout) {
|
|
|
3679
3683
|
const label = createSVGElement("text");
|
|
3680
3684
|
label.setAttribute("class", "oc-axis-tick");
|
|
3681
3685
|
setAttrs(label, {
|
|
3682
|
-
x: isRight ? area.x + area.width +
|
|
3686
|
+
x: isRight ? area.x + area.width + TICK_LABEL_OFFSET : area.x - TICK_LABEL_OFFSET,
|
|
3683
3687
|
y: tick.position,
|
|
3684
3688
|
"text-anchor": isRight ? "start" : "end",
|
|
3685
3689
|
"dominant-baseline": "central"
|
|
3686
3690
|
});
|
|
3687
3691
|
applyTextStyle(label, axis.tickLabelStyle);
|
|
3688
3692
|
if (!isRight) {
|
|
3689
|
-
const availableWidth = area.x -
|
|
3693
|
+
const availableWidth = area.x - TICK_LABEL_OFFSET;
|
|
3690
3694
|
const fontSize = axis.tickLabelStyle.fontSize;
|
|
3691
3695
|
const fontWeight = axis.tickLabelStyle.fontWeight;
|
|
3692
3696
|
const fullWidth = estimateTextWidth2(tick.label, fontSize, fontWeight);
|
|
@@ -3772,7 +3776,8 @@ function renderAxis(parent, axis, orientation, layout) {
|
|
|
3772
3776
|
"text-anchor": "middle"
|
|
3773
3777
|
});
|
|
3774
3778
|
} else if (isRight) {
|
|
3775
|
-
const
|
|
3779
|
+
const titleOffset = getAxisTitleOffset(layout.dimensions.width);
|
|
3780
|
+
const titleX = area.x + area.width + titleOffset;
|
|
3776
3781
|
setAttrs(axisLabel, {
|
|
3777
3782
|
x: titleX,
|
|
3778
3783
|
y: area.y + area.height / 2,
|
|
@@ -3780,11 +3785,12 @@ function renderAxis(parent, axis, orientation, layout) {
|
|
|
3780
3785
|
transform: `rotate(90, ${titleX}, ${area.y + area.height / 2})`
|
|
3781
3786
|
});
|
|
3782
3787
|
} else {
|
|
3788
|
+
const titleOffset = getAxisTitleOffset(layout.dimensions.width);
|
|
3783
3789
|
setAttrs(axisLabel, {
|
|
3784
|
-
x: area.x -
|
|
3790
|
+
x: area.x - titleOffset,
|
|
3785
3791
|
y: area.y + area.height / 2,
|
|
3786
3792
|
"text-anchor": "middle",
|
|
3787
|
-
transform: `rotate(-90, ${area.x -
|
|
3793
|
+
transform: `rotate(-90, ${area.x - titleOffset}, ${area.y + area.height / 2})`
|
|
3788
3794
|
});
|
|
3789
3795
|
}
|
|
3790
3796
|
g.appendChild(axisLabel);
|