Page 1 of 1
Creating charts within existing groups
Posted: Fri Feb 27, 2009 4:09 pm
Here is another small suggestion, or perhaps you can help with the code needed?
We have a page with tabs that simply show and hide groups. Each group contains all the data relating to the tab so we can code the tabs to simply change the visible properties of the group to show the relevant information.
What I would like to be able to do is have the chartengine 'chartsCreateChart' let us optionally specify a group (for example we could specify a group name), or perhaps there is some simple code that could add the new chart group into the existing group after its been created.
Posted: Fri Feb 27, 2009 4:36 pm
chartsEngine can use any existing grop and turn it into a chart. You need to be careful though, the original content of the group will be deleted for refreshing. So to create a chart in an existing group you could first create an empty group inside of the existing group, then set its lockloc to true (this is important, otherwise the chart can not draw correctly) and set the dimensions of the newly created group to the desired dimension.
Code: Select all
--> all handlers
on mouseUp pMouseBtnNo
if there is a grp "myChart" of grp "myGroup" then delete grp "myChart" of grp "myGroup"
create grp "myChart" in grp "myGroup"
put it into tChart
set the rect of tChart to the rect of grp "myGroup"
set the lockloc of tChart to true
set the charts["data"] of tChart to "1,2,3"&cr&"2,1,3"&cr&"1,1,1"
send chartsRefresh to tChart
Do it in a testStack first and let me know if it works for you.
Posted: Fri Feb 27, 2009 5:23 pm
Thats 95% there, the main chart pops into the new group within the main group nicely, and I can now turn the visible of the main group on and off and all the controls, graphs etc all vanish and come back, great!
Just one little thing, im still working on charts a substack and the legend is not drawing (I understand this will be done in 1.1), but the engine is creating another new group on the card called 'myChart_Legend'. This other group is being created at the card level, and not within the main group.
I guess it should be the legend container, and as its an empty group it doesnt mess things up at the moment, but once the legends start to work on substacks will I need to add a container to make sure that new group also gets created within the main group?
Posted: Fri Feb 27, 2009 8:04 pm
drats I always forget about the legend it seems.
If you create a group for the legends in your master group, it should not create another one. The legend group is seperated from the charts group, as one might want to display the legend in an area ouside of the chartGroup container.
Hope that helps,
Posted: Fri Feb 27, 2009 11:33 pm
Thanks Malte, dont worry about it, I can figure it out when you have v1.1 out and the legends drawing on substacks correctly, at the moment its an empty group anyway so it doesnt mess up the interface.
Thanks for working on the chrtcontrol, even through there are a few issues they are very small and its saved me weeks of work already.
I hope it works out for you, and it grows and grows!