Active
Project:
Highcharts
Version:
7.x-2.x-dev
Component:
API
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
1 Apr 2013 at 17:12 UTC
Updated:
9 Oct 2013 at 15:47 UTC
Jump to comment: Most recent
Currently, there is no wrapper function that I can find that does the equivilant of setting the default options for the Highcharts jQuery plugin. This is useful for things like language settings. Consider the following example:
$(function () {
Highcharts.setOptions({
lang: {
numericSymbols: [' thousands', ' millions']
}
});
$('#container').highcharts({
chart: {
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
type: 'logarithmic'
},
series: [{
data: [0.029, 71.5, 1.06, 1292, 14400, 1.760, 135, 1480, 0.0216, 0.194, 9.56, 54.4]
}]
});
});I can do everything from $.('container') down. But I have to add:
drupal_add_js("jQuery(document).ready( function() {
Highcharts.setOptions({
lang: {
numericSymbols: [' thousands', ' millions']
}
});
});", 'inline')
Any suggestions I'm overlooking? I'm pretty sure this is a feature Request.
Comments
Comment #1
scottrigby@generalredneck yes this is a feature request, but one I've been considering.
It's is actually the first request for this, and that may have something to do with the Highcharts library online documentation revamping since last year. While previously it focused almost entirely on the options object itself (the name of the documentation page "Highcharts Options Reference" still reflects this), there is now additional emphasis on global methods and properties.
Will need to look at this closer for the best way to add this. My initial thought is we might want to add another parameter to
highcharts_render()containing an array of these.For quick reference – In addition to the configuration options "for initial declarative chart setup", here are the documented additional methods and properties "for dynamically modifying the chart":
Comment #2
bessone commentedI also had to use setOptions to disable UTC and use the correct Drupal's timezone (http://api.highcharts.com/highcharts#global.useUTC).
The javascript workaround works, but a version in php would be perfect.
Comment #2.0
bessone commentedFixing code
Comment #3
kylesmith commentedDoes JavaScript code added with drupal_add_js() work when exporting the Highchart to a JPG or PNG?
I want to add an image to my Highchart.
I've added the following code, which adds the sun.png image to each chart on the page (I usually have 4 or 5 charts on a page).
The image shows on screen, but not when the Highchart is exported.
Comment #4
scottrigby@kylesmith this is a Highcharts API question. You can use the 'marker' option in the options object rather than your custom JS.
See it's use here: http://www.highcharts.com/demo/spline-symbols/gray
The API ref: http://api.highcharts.com/highcharts#series.data.marker
Comment #5
kylesmith commented@scottrigby thanks, but I'm not trying to replace markers with the image. What I want to do is add images as a header of my Highcharts graph. The code I posted above would add the sun.png to the top left corner.
I know Highcharts can do it. I have created a pure Highcharts example that adds three images to the top of my Highchart and includes them in the export image files (see my example at http://jsfiddle.net/BcN83/4/), so it is not a Highcharts API question, but a Drupal Highcharts question.
When I try to set this up with the Drupal Highcharts module, I can get the images to display on the website's charts, but they do not appear when I use the Highcharts exporter. I was wondering if it is because the code in the drupal_add_js() function is not called during the export.