Search code examples
highchartslazy-high-charts

HighCharts: Reduce size of chart


Does anyone know how to reduce the size of this pie chart? I am using Lazy High Charts gem.

return LazyHighCharts::HighChart.new('pie') do |f|
      f.chart({:defaultSeriesType=>"pie" , :margin=> [0, 0, 0, 0],  backgroundColor: "#F5F5F5", renderTo: "mediamix#{akid.to_s}"} )
      f.series({:type=> 'pie', :name=> "Count",:data=> data_val, borderWidth: 0})
      f.title({ :text=> nil})
      f.plot_options({:pie=>{:allowPointSelect=>true, :cursor=>"pointer" , dataLabels: {enabled: true}, showInLegend: false}})
    end

enter image description here


Solution

  • Highcharts renders the charts to fill the containing div that you specify in the renderTo option. In your case, you are specifying:

    renderTo:"mediamix#{akid.to_s}"
    

    I don't use Lazy Highcharts Gem, so I don't know what this refers to, but you need to look through your code for where this div is defined, and set it's height and width to the size you need.