Closed canesen7 closed 8 months ago
Do I understand you correctly that the left part of the X axis should end at -600,000,000?
If so, you would need to set min
setting to 600000000 on the X axis:
https://www.amcharts.com/docs/v5/charts/xy-chart/axes/value-axis/#Restricting_to_exact_min_and_max_values
No, I need to know width between -200 000 000 to 0 and 0 to 600 000 000
I suppose you can do it in a two-step process:
1) Determine axis position of -200,000,000
, 0
, and 600,000,000
using axis method valueToPosition()
.
2) Then use axis renderer's method positionToCoordinate()
to convert it to a screen coordinates, do the math to calculate width of each segment.
Does that make sense?
Yeah, that make sense but I search the easy way to do it bc in every render, this method must run and calculate label's position by label font-size and current bar width.
What's the purpose of calculating those widths? Maybe there's a better approach.
I need these for calculate values on bar labels.
I'm a bit confused. There are no labels on bars in your screenshots. Are you going to have labels on bars as a bullets?
Yes like this
OK, so you actually need a width of the related bar, not the axis width?
No, I can reach related bar's width. I need to related bar's max width from -200 000 000 to 0 and 0 to 600 000 000. Chart has 2 yAxis (negative and positive) and one xAxis. I need each yAxis's maxWidth.
OK, so you can do something like this:
var fromPos = xAxis.valueToPosition(xAxis.getPrivate("min"));
var toPos = xAxis.valueToPosition(0);
var fromPoint = xAxis.get("renderer").positionToCoordinate(fromPos);
var toPoint = xAxis.get("renderer").positionToCoordinate(toPos);
console.log("Lenght:", toPoint - fromPoint);
Thanks, this method not solve my issue but gives me a idea that solve my issue.
Hi. I've a single bar chart like this.
As you can see, it has one xAxis and two series, first is opposite. When the values are different each other, they has different x axis width. And I need to each serie's max width.
(I need to each line's width.)
Thanks