I use highcharts to display charts on my page. It works fine, but some of the data on the graph is too "compressed", so I have to find a way to see a larger graph.
I read several posts over the Internet on this subject: - in general, they suggest using highslide, but I donβt want to, because my page is already repainted with scripts - someone is trying to pop up in a pop-up window, this may come in handy to me, but I failed - the only quasi-working example that suits me is as follows: (inside the options object, I add these properties).
exporting: { buttons: { popUpBtn: { symbol: 'square', _titleKey: 'FullScreenButtonTitle', x: -60, symbolSize:18, symbolFill: '#B5C9DF', hoverSymbolFill: '#779ABF', onclick: function () { var win=window.open('','','location=0,titlebar=0,status=0,width=780,height=350'); win.focus(); var divtag = win.document.createElement("div"); divtag.id = "div1"; win.document.body.appendChild(divtag); win.document.write('<script type="text/javascript" src="script/highcharts/js/highcharts.js"></script>\ <script type="text/javascript" src="script/highcharts/js/modules/exporting.js"></script>'); this.options.renderTo=divtag; var chart = new Highcharts.Chart(this.options); win.document.close(); } }, exportButton: { enabled: true }, printButton: { enabled: true } } }
However, it does not work, because the div tag is not inserted, and all I get is
<html> <head> <script type="text/javascript" src="script/highcharts/js/highcharts.js"> </script> <script type="text/javascript" src="script/highcharts/js/modules/exporting.js"></script> </head></html>
I can not understand the error. I know that this should be something simple, but I canβt get out alone.
- EDIT ---
Finally, I realized which one could be a working strategy: create the "chartpopup.html" page and pass it the parameters needed to create a copy of the displayed chart.
So now I have:
index.html
chartOptions = { series: [ { name: 'example', data: [83.6, 78.8, 98.5, 93.4, 106.0] }] //// CUT SOME CODE exporting: { buttons: { popUpBtn: { enabled:true, symbol: 'square', _titleKey: 'FullScreenButtonTitle', x: -60, symbolSize:18, symbolFill: '#B5C9DF', hoverSymbolFill: '#779ABF', onclick: function () { look this!--------> generalPurposeGlobalVar = this; var win=window.open('./chartpopup.html','Full Size Chart','location=0,titlebar=0,status=0,width=780,height=650'); } }, exportButton: { enabled: true }, printButton: { enabled: true } } } }; this.highChart=new Highcharts.Chart(this.chartOptions);
and chartpopup.html:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Chart full Size</title> <script type="text/javascript" src="script/jquery-1.7.1-min.js"></script> <script type="text/javascript" src="script/highcharts/js/highcharts.js"></script> <script type="text/javascript" src="script/highcharts/js/modules/exporting.js"> </script> </head> <body> <div id="container" style="min-width: 400px; height: 650; margin: 0 auto"></div> <script> var chart; $(document).ready(function() { var mychart=window.opener.generalPurposeGlobalVar; mychart.options.chart.renderTo= 'container'; chart = new Highcharts.Chart(mychart.options); }); </script> </body> </html>
These two pages actually work ONLY with the default schedule. If I change and redraw the graph, I cannot play it on the pop-up page!
The code I use to change the schedule is basically this:
this.chartOptions.series=[{name:field.split('_').join('\n')}]; this.highChart.destroy(); this.highChart=new Highcharts.Chart(this.chartOptions); this.highChart.xAxis[0].setCategories(_.isEmpty(mygroups) ? [] : mygroups); this.highChart.series[0].setData([]); this.highChart.setTitle({text: this.highChart.title.text},{text:(field.split('_').join(' ')), }); this.highChart.redraw();