Skip to content

Commit b18719f

Browse files
committed
Merge branch 'fix/measurement-svg-text-color'
2 parents 3a64cd7 + 50a60f1 commit b18719f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/drawControllers/svg.drawController.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,17 @@ export class SvgDrawController implements DrawController {
211211
...options,
212212
};
213213

214+
let finalTextColor = textOptions.textColor;
215+
const lowerCaseTextColor = textOptions.textColor.toLowerCase();
216+
if (lowerCaseTextColor === '#fff' || lowerCaseTextColor === '#ffffff' || lowerCaseTextColor === 'white') {
217+
finalTextColor = '#000'; // Change to black if current color is white
218+
}
219+
// No need to handle black to white, as SVG background is white.
220+
// Other colors will remain as they are.
221+
214222
this.svgStrings.push(
215-
`<text x="${canvasBasePoint.x}" y="${canvasBasePoint.y}" fill="${textOptions.textColor}" font-size="${textOptions.fontSize}" font-family="${textOptions.fontFamily}">${label}</text>`
223+
// Use finalTextColor here
224+
`<text x="${canvasBasePoint.x}" y="${canvasBasePoint.y}" fill="${finalTextColor}" font-size="${textOptions.fontSize}" font-family="${textOptions.fontFamily}">${label}</text>`
216225
);
217226
}
218227

0 commit comments

Comments
 (0)