I’m using JFreeChart and with code tha creates dataset:
def createDataset
result = Chart::DefaultPieDataset.new
$p.each do |x|
result.setValue(x.name, x.length)
end
return result
end
I’m getting the following message:
C:\Documents and Settings\Marcin\Pulpit\Algosymulink\data>jruby main.rb
Exception in thread “AWT-EventQueue-0” p_piechart.rb:20:in createDataset': coul d not coerce Fixnum to class java.lang.Number (TypeError) from p_piechart.rb:19:ineach’
from p_piechart.rb:19:in createDataset' from p_piechart.rb:30:inupdateChart’
from p_dane.rb:493:in accept_data' from p_dane.rb:493:ineach’
from p_dane.rb:493:in accept_data' from p_dane.rb:395:intest_data’
from p_dane.rb:89:in `create_buttons’
from :1
…internal jruby stack elided…
from JPieChart3D.createDataset(p_piechart.rb:19)
from Array.each(p_piechart.rb:19)
from JPieChart3D.createDataset(p_piechart.rb:30)
from JPieChart3D.updateChart(p_dane.rb:493)
from DanePanel.accept_data(p_dane.rb:493)
from Array.each(p_dane.rb:493)
from DanePanel.accept_data(p_dane.rb:395)
from DanePanel.test_data(p_dane.rb:89)
from DanePanel.create_buttons(:1)
from (unknown).(unknown)(:1)
When I use jruby-complete-1.1.6 that error doesn’t show. With previous
1.1.5
release both “jruby main.rb” and “java -jar jruby-complete-1.1.5
main.rb”
worked fine.
try:
$p.each do |x|
result.setValue(x.name, new JavaLang::Integer(x.length)) #or result.setValue(x.name, new java.lang.Integer(x.length)) #or result.setValue(x.name, new java.lang.Double(x.length)) and so
on
end
kain wrote:
from p_piechart.rb:19:in `each'
from Array.each(p_piechart.rb:19)
1.1.5 release both “jruby main.rb” and “java -jar jruby-complete-1.1.5
main.rb” worked fine.
java.lang.Integer.new(x.length) solves the problem so there is no point in
bothering with that. I haven’t noticed that argument must be
java.lang.Number type - sorry my mistake.
I think you could file a bug anyway; seems like we could automatically
coerce numeric types to their nearest equivalent Number type. Good idea?
When I use jruby-complete-1.1.6 that error doesn’t show. With previous
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
java.lang.Integer.new(x.length) solves the problem so there is no point
in
bothering with that. I haven’t noticed that argument must be
java.lang.Number type - sorry my mistake.