sfzorro
Posts: 4
Joined: Sun Feb 07, 2010 2:38 am

pie chart, scatter plot, and time series doesn't work Rails

pie chart, scatter plot, and time series doesn't work in my Rails app. I just start using highcharts, so copied the source code and put it in my Rails view, but it not working. several other charts work fine. (haven't change anything in the code)
e.g. here is a example of code in my view for pie chart:

Code: Select all

<%javascript_tag do%>
$(document).ready(function() {
var chart = new Highcharts.Chart({
   chart: {
      renderTo: 'chart-container',
      margin: [50, 200, 60, 170]
   },
   title: {
      text: 'Browser market shares at a specific website, 2008'
   },
   plotArea: {
      shadow: null,
      borderWidth: null,
      backgroundColor: null
   },
   tooltip: {
      formatter: function() {
         return '<b>'+ this.point.name +'</b>: '+ this.y +' %';
      }
   },
   plotOptions: {
      pie: {
         dataLabels: {
            enabled: true,
            formatter: function() {
               if (this.y > 5) return this.point.name;
            },
            color: themes[theme].dataLabelsColor || 'white',
            style: {
               font: '13px Trebuchet MS, Verdana, sans-serif'
            }
         }
      }
   },
legend: {
      layout: 'vertical',
      style: {
         left: 'auto',
         bottom: 'auto',
         right: '50px',
         top: '100px'
      }
   },
      series: [{
      type: 'pie',
      name: 'Browser share',
      data: [{
            name: 'Firefox',
            y: 44.2,
            sliced: false
         },
         ['IE7', 26.6],
         {
            name: 'IE6',
            y: 20,
            sliced: true
         },
         ['Chrome', 3.1],
         {
            name: 'Safari',
            y: 2.7,
            sliced: false
         },
         ['Opera', 2.3],
         ['Mozilla', 0.4]
      ]
//data: [3.40, 1.05, 2.90, 1.65, 1.35, 2.59, 1.39, 3.07, 2.82]
   }]
});
});
<%end%>

<div id="chart-container" style="margin:0 auto; width:90%; height:490px;"></div>
anyone know what's wrong?
sfzorro
Posts: 4
Joined: Sun Feb 07, 2010 2:38 am

Re: pie chart, scatter plot, and time series doesn't work Rails

I think I fixed the problem: seems like the library doesn't support couple of closure functions in the code. By comment them out the charts work fine now.
Besides time series, it displays, but the background color not right.
Any comments? or I'll fix it later...
torstein.honsi
Site Admin
Posts: 9215
Joined: Thu Nov 09, 2006 11:22 am
Location: Vik i Sogn, Norway

Re: pie chart, scatter plot, and time series doesn't work Rails

See http://www.highcharts.com/ref/#chart => backgroundColor.
Torstein Hønsi
CTO, Founder
Highsoft

Return to “Highcharts Usage”