Scaleanchor doesn't seem to recognize x-axis

Hi! I’m trying to create a plot that shows a route, so I need the axes to be the same scale. I am trying to set the scaleanchor of the yaxis to “x”, but then it tells me that a string is not a valid type for this attribute. Does anyone have an idea of what I’m doing wrong, or how to fix this? Thanks in advance!

------------------------------------------------------- Code snippet----------------------------------------------------

let plot = <HTMLElement>document.getElementById('plot');
        let data = [{
            x: xdat,
            y: ydat
        }]
        let layout = {
            xaxis: {
                autotick: false,
                showgrid: true,
                showticklabels: false,
                zeroline: false,
                axisname: "x"
            },
            yaxis: {
                autotick: false,
                showgrid: true,
                showticklabels: false,
                zeroline: false,
                scaleanchor: "x"
            },
            margin: {
                t: 50,
                l: 50,
                r: 50,
                b: 50
            }
        }
        let config = {
            responsive: true
        }
        plotly.newPlot( plot, data, layout, config)

---------------------------------------------Error message------------------------------------------------------
TS2345: Argument of type ‘{ xaxis: { autotick: boolean; showgrid: boolean; showticklabels: boolean; zeroline: boolean; axisname: string; }; yaxis: { autotick: boolean; showgrid: boolean; showticklabels: boolean; zeroline: boolean; scaleanchor: string; }; margin: { …; }; }’ is not assignable to parameter of type ‘Partial’.
The types of ‘yaxis.scaleanchor’ are incompatible between these types.
Type ‘string’ is not assignable to type ‘AxisName | undefined’.
122 | responsive: true
123 | }

124 | plotly.newPlot( plot, data, layout, config)
| ^^^^^^
125 |
126 | }
127 | }

Hi @TheRedMain27 welcome to the forums.

Isn’t the error message referring to the axisname?

BTW, I have never seen axisname in a layout (which doesn’t mean anything, though :wink: )

Thank you!

I think the error message is telling me that I’m trying to set yaxis.scaleanchor to a string instead of an AxisName object, it just says in the documentation (the one you linked) that “x” should be a valid input. Is there maybe a way to define a name for an axis that I can then use to set scaleanchor? Or am I maybe just passing the x-axis in an incorrect way?

Not sure. Try not to set any name, e.g. delete this line of your code.

Ah of course! Sorry that line wasn’t supposed to be in there :0, just one of the quick fixes I tried. It still gives me the same error even without setting an axisname for xaxis.

When I ignore typescript in the line that throws the error the plot does what it is supposed to, so the problem isn’t in the plotly.js code, I think the type definitions that I installed from DefinitelyTyped are just not correct/out of date. Anyway thanks for your willingness to help!