score:1
In broad strokes the way I have solved this in the past would be to use the mouseOver
event for a point to capture that points xAxis value. See this example. In addition to getting the value, I would call a custom function that goes through all charts and highlight the same xAxis value there (if it exists).
To make this easier I would make some global array or similar that has a reference to all charts on the page. This way you don't need to explicitly reference each chart from other charts. To make this look nice and be practical, all charts need to be able to call the same custom function to highlight a value, and have a similar function that removes the highlight on the mouseOut
event.
This is just one possible solution, there are many ways to achieve what you are after.
Here is a very basic implementation of what I wrote above
function sharedMouseOver() {
let currentX = this.x
charts = Highcharts.charts;
charts.forEach(function(chart, index) {
chart.series.forEach(function(series, seriesIndex) {
series.points.forEach(function(point, pointsIndex) {
if (point.x == currentX) {
point.setState('hover')
}
})
});
});
}
function sharedMouseOut() {
charts = Highcharts.charts;
charts.forEach(function(chart, index) {
chart.series.forEach(function(series, seriesIndex) {
series.points.forEach(function(point, pointsIndex) {
point.setState('')
});
});
});
}
And in each chart you can find this:
plotOptions: {
series: {
point: {
events: {
mouseOver: sharedMouseOver,
mouseOut: sharedMouseOut
}
},
...
}
Working example: https://jsfiddle.net/ewolden/tvgL8pnh/17/
function sharedMouseOver() {
let currentX = this.x
charts = Highcharts.charts;
charts.forEach(function(chart, index) {
chart.series.forEach(function(series, seriesIndex) {
series.points.forEach(function(point, pointsIndex) {
if (point.x == currentX) {
point.setState('hover')
}
})
});
});
}
function sharedMouseOut() {
charts = Highcharts.charts;
charts.forEach(function(chart, index) {
//if (chart.renderTo.id === chartsId) {
// chosenChart = chart;
//}
chart.series.forEach(function(series, seriesIndex) {
series.points.forEach(function(point, pointsIndex) {
point.setState('')
});
});
});
}
Highcharts.chart('container', {
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
plotOptions: {
series: {
point: {
events: {
mouseOver: sharedMouseOver,
mouseOut: sharedMouseOut
}
},
pointStart: 2010
}
},
series: [{
name: 'Installation',
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
}, {
name: 'Other',
data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111]
}],
});
Highcharts.chart('container2', {
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
plotOptions: {
series: {
point: {
events: {
mouseOver: sharedMouseOver,
mouseOut: sharedMouseOut
}
},
pointStart: 2010
}
},
series: [{
name: 'Manufacturing',
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434]
}],
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container"></div>
<div id="container2"></div>
Source: stackoverflow.com
Related Query
- Cannot display multiple Highcharts on a single page
- Multiple highcharts charts dynamically created in angular2 on one page
- Using multiple Highcharts in a single page
- How to generate single PDF of page that contained multiple highcharts in DIVs
- Multiple Highcharts in one page - only one chart displays
- Highcharts multiple charts on a single page using c# asp.net mvc3
- How to show multiple Highcharts graph on one page
- Getting Multiple drilldown highcharts on same page to work
- Multiple "Script src" on same page causing sorting functions not to work on HighCharts
- Multiple highcharts at same page based on clientId value?
- Highcharts - Multiple Charts On Mobile Page
- how to render multiple line charts - highcharts on same page using highcharts react wrapper - highcharts-react-offical
- Highcharts - how to display multiple graphs on one page using multiple xml files
- Highcharts - Same chart multiple times in same page
- How to have multiple highcharts with different series data in vuejs without repeating code
- Multiple dynamic Highcharts on one page with json
- Synchronizing multiple (Highcharts) on a page
- Behavior of multiple HighCharts on single page when removing one div
- Multiple Highcharts on a PDF page - SVG Page Layout
- multiple highcharts on same page
- Render Highcharts canvas as a PNG on the page
- highcharts pass multiple values to tooltip
- How can I force multiple y-axis in Highcharts to have a common zero
- Highcharts Error #16: charts not showing on the same page
- HighCharts is undefined because multiple Html pages in Javascript file
- How to export the whole page or html content with Highcharts not just the chart?
- Highcharts - drill down to multiple series
- Javascript Highcharts v3.0.5 - How to hide Y Axis Title when using multiple Y Axis
- Dynamic update of multiple series in highcharts
- Custom Highcharts Context Menu Button Appearing in Every Chart on Page
More Query from same tag
- How do you create a survey that will immediately display the results as a pie chart on a website?
- Spline graph not showing in highchart
- Combine bullet and line chart in highcharts
- Force Highcharts to show last x-axis label
- How to hardcode arbitrary Tick text labels on y axis in highcharts
- adding click event dynamically created highchart
- Highcharts - trying to start x-axis tickmark at a half hour point
- highcharts highmaps parsing json data to display world map with rich info
- Problems with connecting series
- Highcharts legend js error
- How to add categories' separation lines
- Highcharts with date and time for x axis (from a database with format YYYYMMDDHHMM)
- error with adjusting height of pie chart using highcharts
- ChartJS/High Charts Radar chart - Different radial axis labels for each category that appear on hover
- How to set the x axis dynamically in High Charts 2.3.5
- Highcharts: how do I call an external .js file in the <head> of my highcharts page
- How can I create a chart with stacked columns after drilldown?
- Background on the bar not getting removed from Highcharts
- Highcharts - Pie slices show up invisible until interaction
- Calling Highcharts export to jpeg but the source is https and exporting is http (security warnings issued by browser)
- Highchart tooltip & events from external function
- Highcharts blank chart with x and y axis
- Highcharts Export Server on AWS Lambda
- highchats heatmap how to show all categories on y-axis
- Which javascript graphs / chart library?
- How to display last data point value in a tag on Y Axis in line chart of highChartjs
- Highcharts -- how to change line width programmatically and prevent resetting line width?
- Highcharts min y-axis value
- Ordering the stacking in a highcharts bar chart in R
- Highcharts: how do I align data labels on the right in a bar chart?