打开 Flash 图表需要帮助

发布于 2024-08-11 20:54:11 字数 822 浏览 8 评论 0原文

def reparto_de_ventas_por_marca

#obtener los montos de las ventas en el periodo comprendido y sumarlas


       @ventas = Venta.find(:all)
       @marcas = Marca.find(:all)



        title = Title.new("Ingresos de este mes: #{@total}")

           pie = Pie.new
           pie.start_angle = 35
           pie.animate = true
           pie.tooltip = '#val# de #total#<br>#percent# de 100%'
           pie.colours = ["#245a9c", "#fff"]

 pie.values  = [



    @marcas.each do |result|

     PieValue.new(result.ventas.count, result.name)


  end  



   ]
           chart = OpenFlashChart.new
           chart.title = title
           chart.add_element(pie)

           chart.x_axis = nil

           render :text => chart.to_s
end

它只是不起作用,我需要获取值来创建带有闪存图表的图表。

任何帮助将不胜感激。

def reparto_de_ventas_por_marca

#obtener los montos de las ventas en el periodo comprendido y sumarlas


       @ventas = Venta.find(:all)
       @marcas = Marca.find(:all)



        title = Title.new("Ingresos de este mes: #{@total}")

           pie = Pie.new
           pie.start_angle = 35
           pie.animate = true
           pie.tooltip = '#val# de #total#<br>#percent# de 100%'
           pie.colours = ["#245a9c", "#fff"]

 pie.values  = [



    @marcas.each do |result|

     PieValue.new(result.ventas.count, result.name)


  end  



   ]
           chart = OpenFlashChart.new
           chart.title = title
           chart.add_element(pie)

           chart.x_axis = nil

           render :text => chart.to_s
end

It just doesn't works i need to get the values to create a graph with flash chart.

any help will be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

送舟行 2024-08-18 20:54:11

尝试

pie.values  = @marcas.collect {|result| PieValue.new(result.ventas.count, result.name)}

Try

pie.values  = @marcas.collect {|result| PieValue.new(result.ventas.count, result.name)}
云仙小弟 2024-08-18 20:54:11

我不确定您使用的是哪个 Open Flash Chart 插件,但在我看来,它们都使用方法 #render,而不是 #to_s 来渲染图表。

以下是示例:http://pullmonkey.com/projects/open_flash_chart/view_source_code/pie http://rails-open- flash-chart-plugin.googlecode.com/svn/trunk/lib/open_flash_chart.rb

I'm not sure which Open Flash Chart plugin you're using, but it looks to me like they both use the method #render, not #to_s to render the chart.

Here are the examples: http://pullmonkey.com/projects/open_flash_chart/view_source_code/pie http://rails-open-flash-chart-plugin.googlecode.com/svn/trunk/lib/open_flash_chart.rb

窝囊感情。 2024-08-18 20:54:11

检查您的值是否为浮点数/小数。如果您的语言是西班牙语,则您的小数点分隔符可能是“逗号”,这会破坏 json 结构。
一种解决方案是将您的区域设置设置为英语。另一个灵魂是将你的值四舍五入为整数......
我希望它对你有帮助。

问候。

check if your values are floats/decimals. If your language is spanish, it is possible that your decimal separator is a 'comma', and that brokes the json structure.
One solution could be to set your locale to english. Another soultion is to round your values to integer...
I hope it helps you.

Regards.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文