Sabira
Sabira

Reputation: 103

highcharts - render text with decimal 'x' and 'y'

I was trying to render text using svgRenderer and noticed that I can't set x and y to decimal. Am I missing something? Here's an example - https://jsfiddle.net/sabira/dxhz9qn8/1/

chart.renderer.text('Series 1', 140.5, 140)

enter image description here

Upvotes: 0

Views: 42

Answers (1)

ppotaczek
ppotaczek

Reputation: 39069

Values x and y are rounded in the text renderer method: https://github.com/highcharts/highcharts/blob/5e3927f5d3922c72c40d64a028dbc8a2e81bb34e/js/Core/Renderer/SVG/SVGRenderer.js#L1746

attribs.y = Math.round(y);

That operation is probably for text anti-aliasing. To prevent such behavior you can overwrite the text method: https://jsfiddle.net/BlackLabel/exvmq8p1/


Docs: https://www.highcharts.com/docs/extending-highcharts/extending-highcharts

Upvotes: 1

Related Questions