懒惰的高图表宝石和地理

时间:2015-07-01 11:57:17

标签: ruby-on-rails ruby charts highcharts

我使用lazy high charts gem来生成我在ruby轨道上的数据图表。当我尝试使用饼图,在控制器中生成数据并创建帮助程序以便调用我的pie_chart时,这没关系:

def pie_chart(data, options={})
  chart = LazyHighCharts::HighChart.new('pie') do |f|
    f.chart({:defaultSeriesType=>"pie", :backgroundColor=>"rgba(255, 255, 255, 0)"} )
    series = {
             :type=> 'pie',
             :name=> options[:name],
             :data=> data
    }
    f.series(series)
    f.options[:title][:text] = options[:title]
    f.legend(:layout=> 'horizontal')
    f.colors(["#f7941d", "#8dc73f", "#11a99d", "#6ac7ff","#ec217b", "#f03f37"])

    f.plot_options(:pie=>{
      :allowPointSelect=>true,
      :cursor=>"pointer" ,
      :dataLabels=>{
        :enabled=>false,
        :color=>"black",
        :style=>{
          :font=>"13px Trebuchet MS, Verdana, sans-serif"
        }
      },
      :showInLegend => true,
      :point => {
        :events => {
      }}
    })
  end

  html = high_chart(options[:id], chart) do
    if options[:show_absolutes].present?
      raw "
        options.legend.labelFormatter = function() {return '<b> '+ this.name +'</b>: '+ this.y + ' (' + this.percentage.toFixed(2) +' %)';};
        options.tooltip.formatter = function() {return '<b> '+ this.point.name +'</b>: '+ this.y + ' (' + this.percentage.toFixed(2) +' %)';};
      "
    else
     raw "
        options.legend.labelFormatter = function() {return '<b> '+ this.name +'</b>: '+ this.percentage.toFixed(2) +' %';};
        options.tooltip.formatter = function() {return '<b> '+ this.point.name +'</b>: '+ this.percentage.toFixed(2) +' %';};
      "
    end
  end

但是我需要创建一个geochart,在我的控制器中生成另一个数据。我试着用:

def maps_chart(data, options={})
  chart = LazyHighCharts::HighChart.new('map') do |f|
    f.chart({:defaultSeriesType=>"map"})
    series = {
             :type=> 'map',
             :name=> options[:name],
             :data=> data,
             :mapData => geojson
    }

  end

  high_stock(options[:id], chart) do
  end end

但在我看来打电话给我的助手时没有任何反应。怎么了?懒惰的高图表可以创建geocharts?因为在他的维基中没有找到任何其他的东西。

0 个答案:

没有答案
相关问题