Jump to content

Variable number of Bar Charts


James.LeeDG3.com

Recommended Posts

I have a client that needs a stacked barchart that changes based on the age of the recipient.

 

Example:

Age 30 gets a bar chart displaying three bars: 35, 40, 50

 

Age 47 gets a bar chart displaying 1 bar: 50

 

The data contained in the actual bars is also variable. so the 30 year old will have different bar information at 50 than the 47 year old.

 

So the question is: Is there a way to write variable switch data into a chart in the same way you could vary the number of rows in a table?

Link to comment
Share on other sites

Sure, just like with rows in a table, you can define as many bars or lines of data as you want. You probably want something like this:

if (Field("age") < 35)
{
 chart = '<row type=header><cell>35<cell>40<cell>50';
 chart += '<row><cell>' + Field("data for 35");
 chart += '<cell>' + Field("data for 40");
 chart += '<cell>' + Field("data for 50");
}
else if (Field("age") < 40)
{
 chart = '<row type=header><cell>40<cell>50';
 chart += '<row><cell>' + Field("data for 40");
 chart += '<cell>' + Field("data for 50");
}
else
{
 chart = '<row type=header><cell>50';
 chart += '<row><cell>' + Field("data for 50");
}

I'm obviously making some guesses/assumptions about how you're filling in the data, and this logic could be more generalized, but I think you can get the idea.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...