Skip to main content

Dynamic data in a jMaki chart?

1 reply [Last post]
Joined: 2007-04-17


First of all I new to JMaki, so don't slaughter me if this is easy :)

I am using Netbeans 5.5 with the jMaki plugin installed.

I want to be able to display data from a database in a jMaki chart. However, every example I have found are hardcoded like so:

What I would like to do is to be able to make a String arays called 'labels' that has all lables for the x-axis and a 2-dimentional integer array called 'data' holding all the data to be drawn.

In my logic I would be able to do something like this:

String[] labels = { 'January', 'February', 'March', 'April', 'May', 'June','July', 'August', 'September', 'October', 'November', 'December' };
int data[][] = getDataFromDatabase() //this gets the data array from the DB

Is this at all possible?

Any help would be greatly appreciated!
On a side note, how can I put in variables in ajax tags? Is it possible? I mean something like in JSP:

//HTML code here

<% int ex =1; %>

Debug: <%= deb %>

//more HTML code

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-04-17

Ok, I've gotten halfway there myself. Sorry for posting prematurely :)

I found out that I could make a java bean with the properties, and then use ${} inside the ajax tag.

So if my bean is called data and let's say I want one value called 'value', the ajax would look like this:

args="{ xAxis : { title : 'Months',
labels : ['January', 'February', 'March', 'April', 'May',
'June','July', 'August', 'September', 'October',
'November', 'December']
yAxis : { title : 'Temperature',
tickCount : 3
value="{data : [{label : 'Red Series', color: 'red', values : [${data.value}, etc...] },

I'm starting to digg this :P