Creating charts within existing groups

Get help and support using chartsEngine for LiveCode.

Moderators: heatherlaine, BvG

Post Reply
andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Creating charts within existing groups

Post by andyh1234 » Fri Feb 27, 2009 4:09 pm

Hi Malte,

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.

Thanks

Andy

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Post by malte » Fri Feb 27, 2009 4:36 pm

Hi Andy,

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.

In code:

Code: Select all

--> all handlers

on mouseUp pMouseBtnNo
    local tChart
    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
end mouseUp
Do it in a testStack first and let me know if it works for you.

Cheers,

Malte

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Post by andyh1234 » Fri Feb 27, 2009 5:23 pm

Thanks Malte,

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?

Thanks

Andy

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Post by malte » Fri Feb 27, 2009 8:04 pm

Hi Andy,

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,

Malte

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Post by andyh1234 » 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!

Andy

Post Reply

Return to “chartsEngine”