google charts event for when user zooms or right clicks to reset
google charts event for when user zooms or right clicks to reset
I have a google chart. I have enabled the user to drag and zoom by using the option below. var options = { explorer: { keepInBounds: true, actions: ['dragToZoom...
stackoverflow.com
google.charts.load('current', {
packages: ['corechart']
}).then(function () {
var data = google.visualization.arrayToDataTable([
[0, 6],
[1, 7],
[2, 8],
[3, 9],
[4, 5]
], true);
var options = {
pointSize: 4,
explorer: {
keepInBounds: true,
actions: ['dragToZoom', 'rightClickToReset']
}
};
var container = document.getElementById('chart_div');
var chart = new google.visualization.LineChart(container);
google.visualization.events.addListener(chart, 'ready', function () {
var zoomLast = getCoords();
var observer = new MutationObserver(function () {
var zoomCurrent = getCoords();
if (JSON.stringify(zoomLast) !== JSON.stringify(zoomCurrent)) {
zoomLast = getCoords();
console.log('zoom event');
}
});
observer.observe(container, {
childList: true,
subtree: true
});
});
function getCoords() {
var chartLayout = chart.getChartLayoutInterface();
var chartBounds = chartLayout.getChartAreaBoundingBox();
return {
x: {
min: chartLayout.getHAxisValue(chartBounds.left),
max: chartLayout.getHAxisValue(chartBounds.width + chartBounds.left)
},
y: {
min: chartLayout.getVAxisValue(chartBounds.top),
max: chartLayout.getVAxisValue(chartBounds.height + chartBounds.top)
}
};
}
chart.draw(data, options);
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
Detect zoom event for a Google Line chart?
Detect zoom event for a Google Line chart?
Is it possible to detect a zoom/rangechange event with Google Line Chart api? If I use a annotated timeline i can do it, but not with a LineChart. As you see i´m trying to synchronise two graphs....
stackoverflow.com
developers.google.com/chart/interactive/docs/events
구글 차트 이벤트관련 공식 레퍼런스
Handling Events | Charts | Google Developers
This page describes how to listen for and handle events fired by a chart. Contents Overview Google charts can fire events that you can listen for. Events can be triggered by user actions, such as when a user clicks on a chart. You can register a Javascript
developers.google.com
'[공부용]참고 사이트 모음 > [chart]' 카테고리의 다른 글
구글 차트 ChartRangeFilter 예시 코드 (0) | 2021.03.11 |
---|---|
구글 차트 라인 그려지는 애니메이션 효과 (0) | 2021.03.10 |
Draw a line on Google Charts ScatterChart 구글차트 점 선 같이 그리기 ComboChart (0) | 2021.03.09 |
Google Chart JSON 데이터 파싱 in JSP (0) | 2021.03.09 |
google chart drag to zoom 예시 코드 (0) | 2021.03.09 |