diff --git a/src/components/Graph.js b/src/components/Graph.js index b287f95..39499db 100644 --- a/src/components/Graph.js +++ b/src/components/Graph.js @@ -10,6 +10,7 @@ function Graph({ id, initialKeys, updateKeys, removeGraph }) { const [selectedOptions, setSelectedOptions] = useState([]); const [inputValue, setInputValue] = useState(""); const [data, setData] = useState([]); + const [exponentformat, setExponentformat] = useState('e'); useEffect(() => { getInitialData(); @@ -117,6 +118,7 @@ function Graph({ id, initialKeys, updateKeys, removeGraph }) { ) { plotData.autoScaleVerticalAxis(event); } + updateYAxisLayout(event); }; const handleInput = (value, event) => { @@ -153,6 +155,27 @@ function Graph({ id, initialKeys, updateKeys, removeGraph }) { return labels.includes(option.label); }; + const updateYAxisLayout = (event) => { + + const plot = document.getElementById(`plot-${id}`); + console.log(plot); + const range = plot.layout.yaxis.range; + console.log(plot.layout.yaxis.range); + + if(range.length>0){ + const yMax = Math.max(Math.abs(range[0]),Math.abs(range[1])); + console.log(yMax); + if(yMax<1000.){ + setExponentformat("none"); + } + else{ + setExponentformat("e"); + } + } + console.log(exponentformat); + } + + return (