amcharts / amcharts5

The newest, fastest, and most advanced amCharts charting library for JavaScript and TypeScript apps.
Other
345 stars 92 forks source link

Disable PanY auto resetting for valueAxis amcharts Stock #1665

Closed xdajay closed 1 month ago

xdajay commented 1 month ago

Hi Team tried everything but maxDeviation setting not working for valueAxis/AxisRendererY for stocks chart. maxDeviation for dateAxis for fine, but for AxisRendererY PanY keep getting resetted to center, which bad UX, since user might need to center chart vertically and horizontally.

https://github.com/user-attachments/assets/e796fce9-3c1a-45cb-a6a4-292a58a96c05

code reference

       let valueAxis = mainPanel.yAxes.push(am5xy.ValueAxis.new(rootRef.current, {
            renderer: am5xy.AxisRendererY.new(rootRef.current, { pan: "zoom", maxDeviation: 1, panY: true }),
            tooltip: am5.Tooltip.new(rootRef.current, {
                getStrokeFromSprite: false,
            }),
            maxDeviation: 1,
            panY: true,
            strictMinMax: false,
            numberFormat: "#,###.00",
            extraTooltipPrecision: 2,
        }));

Thank you.

martynasma commented 1 month ago

Try setting autoZoom: false on your Y-axis.

xdajay commented 1 month ago

@martynasma it worked! you're amazing.

For better UX im keeping autoZoom: true, by defualt and only set valueAxis autoZoom to false, when users interacts with valueAxis and having a custom control button to toggle it.