Native option to zoom and center highmaps on nonempty regions
I have some usefull trick to center map on non empty (with some data) regions to avoid this case:
https://gyazo.com/35fd0d74d3e773f694790c5fc0c95ece
and now i can show only usefull part of highmap, by default:
https://gyazo.com/d7ca32d8ce8b1535bddd331a997c67b8
{code}
const points = this.chart.series[0];
let minX = Number.MAX_SAFE_INTEGER,
maxX = Number.MIN_SAFE_INTEGER,
minY = Number.MAX_SAFE_INTEGER,
maxY = Number.MIN_SAFE_INTEGER;
if (!points) return;
this.chart.series[0]
.getValidPoints()
.forEach(item => {
if (item['_minX'] && item['_maxX'] && item['_minY'] && item['_maxY']) {
minX = Math.min(minX, item['_minX']);
maxX = Math.max(maxX, item['_maxX']);
minY = Math.min(minY, item['_minY']);
maxY = Math.max(maxY, item['_maxY']);
}
});
this.chart.series[0].xAxis.setExtremes(minX, maxX, true);
this.chart.series[0].yAxis.setExtremes(minY, maxY, true);
this.chart.redraw();
{code}
1
vote
Nicholas
shared this idea
Thanks for your suggestion! There’s also functions like Chart.mapZoom and Point.zoomTo with similar functionality.
https://api.highcharts.com/class-reference/Highcharts.Chart#mapZoom
-
Nicholas commented
So, it will be nice to have native option to center map by default