score:9
Just use:
$($('.highcharts-legend-item')[0]).click()
Where the 0
is the index of the series you wish to 'click'.
Update fiddle.
EDITS
highcharts-legend-item
is the class of each entry in the legend. I discovered this by inpecting the legend using chrome developer tools.- the
$('.highcharts-legend-item')
is a jquery selector to return an array of all elements of that class. I select the first one by index and the$()
it to convert it into a jquery object - The
.click
is this: http://api.jquery.com/click/
score:2
I think the answer with defining the click on
$('.highcharts-legend-item')[0])
is not the best one. It is very "expensive" since the DOM is probably heavy. My solution is generally based on CSS. You can set the position of highchart legend items right above the custom elements that you want to use and every item should have width&height same as the custom HTML element. Highchart elements should have opacity value 0 so they are not visible. So when you click on your element,in fact, you are clicking on the highchart legend item. If you want to set some CSS for your custom element you should define legendItemClick callback:
plotOptions: {
series: {
events: {
legendItemClick: function() {
var legenedItemIndex = this.index // index of highchart legend item
$("your html element:eq(" + legenedItemIndex + ")") //do something with your element
}
}
}
}
Source: stackoverflow.com
Related Query
- Highcharts - fire legendItemClick event
- Click event not fire in highcharts tooltip
- Highcharts : How do I keep the marker formatting and make the click event fire with a 5K+ point scatter plot?
- HighCharts Stock Chart fire event on chart redraw?
- Highcharts manually setting legendItemClick event
- highcharts from event LegendItemClick to event textItemClick and iconItemClick
- How to fire click event in moxie highcharts
- Highcharts legendItemClick event - Stop chart auto rendering
- Highcharts - manually trigger hover event on a point
- How do I add an event listener to a Highcharts object *AFTER* I've created it
- Highcharts - Double click event
- Highcharts chart click event fired on click of the reset zoom button (bug?)
- Highcharts : Chart with drilldown how to obtain click event of drill up button
- highcharts how to catch and insert logic in click reset zoom button event
- Append onload or redraw event functions dynamically in Highcharts
- programatically fire a click event for a point on highchart scatter plot
- How to pass custom data into Highcharts graph click event
- how to get chart object inside a point event function in Highcharts
- Add onclick event on chart made with the highcharts library
- Using PhantomJS to create HighCharts grahps server side for use in PDF creation (PHP) - results in exit code 11 from PHPs exec();
- Highcharts event on animation complete?
- Highcharts - Global configuration with common code and unique data & Headings
- HighStock HighCharts Setting Flag on Click Event
- How to hide Axes Crosshairs by onclick event in Highcharts
- Explanation of why I need to wrap a highcharts jquery event in an angular $timeout to access properties
- Fire click event on a highchart column drilldown chart on clicking x axis for drill down reports
- HighCharts Stock Chart error code 18
- How to attach click event function in Highcharts
- highcharts change rendered image source on click
- How to add series after click event in HighCharts
More Query from same tag
- Can Highcharter treemap show the percentage?
- Filling the data gaps with a gray area using Highcharts,
- angular-chartJs change chart background and highlight colors
- Find and fill intersection of line chart with plot line in highcharts
- Highcharts 2 groups of series
- How to make the full million value show up on y-axis and tooltip (Highcharts)
- Highcharts heatmap logarithmic colorAxis fails when 0
- Implementing High charts with PHP and Mysql
- Highcharts: How to disable piechart tooltip in combination chart example
- Highcharts: export image show wrong color and line width if user change the color and/or line width
- How can I display different text from a different div on mouse click?
- Loading JSON data in Ruby on rails to use HIGHCHARTS
- Highcharts line chart from a Google spreadsheet
- Highcharts prevent xAxis Labels hidden
- Attach arbitrary data to Highcharts data points
- Calling a function from highcharts upon clicking the piechart
- Generate image in a folder from Highchart in PHP
- Hightcharts chart not resizing to fill space
- Set max y axis point 10% greater than current max - Highcharts
- Toggle specific highcharts when checking/unchecking checkboxes
- breaking json for stacked highcharts
- Output query data in other format for chart to recognize
- Highcharts not creating correct amount of labels (steps) in xAxis only first and last labels
- Highcharts Scatter Plot Performance
- Highcharts unable to fit it to mobile screen size
- (jQuery Highchart) How to make this as Horizontal Bars?
- How to position rangeSelector buttons to the right Highstock/Highcharts
- Sort of series values for xAxis
- External JSON into Highcharts Line Graph - Date Parsing Issue
- highcharts pie monochrome: how to set the default color?