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 | }