Search code examples
scaleaxisamcharts

AmCharts - The same scale for both Axis


I have Graph with 2 lines, each one have axis (left and right). But Left axis depend of (for example) red data and has the max 100, Right depend of blue data and has max 10. Both lines looks like the same, but I want to have one scale for both lines. I mean if bigger max of them lines is 100, 100 should be max for both.

Sorry for my Eng.


Solution

  • The best way to sync both axes is to use synchronizeWith setting in your secondary axis.

    http://docs.amcharts.com/3/javascriptcharts/ValueAxis#synchronizeWith http://docs.amcharts.com/3/javascriptcharts/ValueAxis#synchronizationMultiplier

    Here's an example:

    "valueAxes": [{
            "id":"v1",
            "axisColor": "#FF6600",
            "axisThickness": 2,
            "gridAlpha": 0.2,
            "axisAlpha": 1,
            "position": "left"
        }, {
            "id":"v2",
            "axisColor": "#FCD202",
            "axisThickness": 2,
            "gridAlpha": 0,
            "axisAlpha": 1,
            "position": "right",
            "synchronizeWith": "v1",
            "synchronizationMultiplier": 1
        }],
    

    Please remember that you need to set synchronizationMultiplier to 1 if you want both axes to use exactly the same scale.