michelson/lazy_high_charts — Issue #34: Plot options added twice
Author: rudf0rd
Created: 2011-10-10 21:55:35+00:00
State: open

When trying to create a pie chart from a controller, I get plotOptions added twice in the config. It will randomly overwrite the config options I have. Thanks for an amazing plugin that saved me a bit of time.

Controller # # # # # # # #

@chart = LazyHighCharts::HighChart.new('pie') do |f|
f.chart({:defaultSeriesType => "pie", :marginLeft => 400, :backgroundColor => 'transparent'} )
series = {
:type => 'pie',
:name => 'Energy Sources',
:data => data
}
f.series(series)
f.colors(["#005496", "#59b8e0", "#aadae9", "#7fa42f", "#8dc641", "#9ecb3b", "#cbb778"])
f.title(
:text => "Energy Sources",
:verticalAlign => "top",
:align => "right",
:x => -45,
:y => 60,
:style => {
:font=>"34px BebasNeueRegular, Arial, sans-serif",
:width=>"200",
:lineHeight=>"34px",
:color=>"#efefef"
}
)
f.legend(
:layout => 'vertical',
:align => "right",
:verticalAlign => "top",
:x => -20,
:y => 100,
:borderWidth => 0,
:itemStyle => {
:fontWeight=>"bold",
:font=>"14px Arial, sans-serif",
:color=>"#efefef"
}
)
f.plot_options(
:pie =>{
:allowPointSelect => true,
:cursor => "pointer",
:dataLabels => {
:enabled => false
},
:showInLegend => true
}
)
end

Created code # # # # # # #

jQuery(function() {
var options = {
tooltip: {
"enabled": true
},
credits: {
"enabled": false
},
subtitle: {},
colors: ["#005496", "#59b8e0", "#aadae9", "#7fa42f", "#8dc641", "#9ecb3b", "#cbb778"],
plotOptions: {
"areaspline": {}
},
xAxis: {},
chart: {
"defaultSeriesType": "pie",
"marginLeft": 400,
"renderTo": "top_image",
"backgroundColor": "transparent"
},
title: {
"x": -45,
"y": 60,
"text": "Energy Sources",
"verticalAlign": "top",
"align": "right",
"style": {
"color": "#efefef",
"font": "34px BebasNeueRegular, Arial, sans-serif",
"lineHeight": "34px",
"width": "200"
}
},
plotOptions: {
"pie": {
"dataLabels": {
"enabled": false
},
"cursor": "pointer",
"allowPointSelect": true,
"showInLegend": true
}
},
yAxis: {
"title": {
"text": null
},
"labels": {}
},
legend: {
"layout": "vertical",
"x": -20,
"y": 100,
"borderWidth": 0,
"verticalAlign": "top",
"align": "right",
"itemStyle": {
"fontWeight": "bold",
"color": "#efefef",
"font": "14px Arial, sans-serif"
}
},
series: [{
"name": "Energy Sources",
"data": [["Wind", 7.0], ["Coal", 40.0], ["Hyrdoelectric", 8.0], ["Natural gas", 18.0], ["Nuclear", 23.0], ["Other", 6.0]],
"type": "pie"
}]
};
var chart = new Highcharts.Chart(options);
});