$.getJSON('https://www.highcharts.com/samples/data/aapl-c.json', function(data) {
// Create the chart
Highcharts.stockChart('container', {
chart: {
events: {
load: function() {
// function which saves the new background color.
var chart = this;
// Select the save button of the popup and assign a click event
document.querySelectorAll('.highcharts-popup-annotations button')[0].addEventListener(
'click',
function() {
var color = document.querySelectorAll(
'.highcharts-popup-annotations input[name="stroke"]'
)[0].value;
// update the circle
chart.currentAnnotation.shapes[0].update({
fill: color
});
// close the container
chart.stockToolbar.annotationsPopupContainer.style.display = 'none';
}
)
}
}
},
navigation :{
bindingsClassName: 'tools-container'
},
stockTools: {
gui: {
enabled: false
},
events: {
// on selecting the annotation the showpopup is fired
showPopup: function(event) {
if (!this.annotationsPopupContainer) {
// Get the popup annotations container
this.annotationsPopupContainer = document
.getElementsByClassName('highcharts-popup-annotations')[0];
}
// Unhide the popup container, but not when we add the annotation.
if (event.formType === 'annotation-toolbar' && !this.chart.activeButton) {
this.chart.currentAnnotation = event.annotation;
this.annotationsPopupContainer.style.display = 'block';
}
},
// Hide the popup container, and reset currentAnnotation
closePopup: function() {
this.annotationsPopupContainer.style.display = 'none';
this.chart.currentAnnotation = null;
},
//...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.