打开 Flash 图表需要帮助
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试
Try
我不确定您使用的是哪个 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
检查您的值是否为浮点数/小数。如果您的语言是西班牙语,则您的小数点分隔符可能是“逗号”,这会破坏 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.