RMChart question.

This forum is for eXpress++ general support.
Message
Author
skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

RMChart question.

#1 Post by skiman »

HI,

I want to change a chart dynamically. I was looking in the \samples\rmchart\dcchart.prg.

In region6, there is a sample with a BARGROUP and a LINEGROUP which is DcChartRegion oRegion6.

I want to change the chart, so the linegroup disappears. In the sample there is a button 'Apply new data'. This button has the following action:

Code: Select all

@ DCGUI_ROW, DCGUI_COL + 10 DCPUSHBUTTON CAPTION 'Apply New Data' SIZE 90,20 ;
   TOOLTIP 'Apply new RANDOM data to all graph regions' ;
   ACTION {||ApplyNewData1(oRMChart:regions[1]), ;
             ApplyNewData2(oRMChart:regions[2]), ;
             ApplyNewData4(oRMChart:regions[3]), ;
             ApplyNewData4(oRMChart:regions[4]), ;
             ApplyNewData6(oRMChart:regions[6]), ;
             oRMChart:draw()}
So I changed the function 'ApplyNewData6()' since this is for the 'Bar and Line sample'. I expected that I could delete the array for the linegroup, but I have no success.

Code: Select all

STATIC FUNCTION ApplyNewData6( oRegion , oChart )

Local aDataAxis

aDataAxis := oRegion:dataAxis		// put the dataaxis array in a new array, it contains 2 elements, 1 for the bargroup, 1 for the linegroup
asize(aDataAxis,1)
oRegion:dataAxis := aDataAxis		// contains now only one dataaxis, which is used by the BARGROUP

oRegion:lineGroup := nil 			// set linegroup array to nil
oRegion:haslinegroup := .f.		// set to false, so it should not be drawn anymore
oRegion:reset()

RETURN nil
The above isn't working. The line graph stays in the chart after the oRmChart:draw().

Am I missing something?
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: RMChart question.

#2 Post by rdonnay »

I don't see anything in the RmChart docs that shows how to remove a linegroup.

I was able to remove it by changing Applydata6() as show below, except I can't figure out how to remove the axis labels.

STATIC FUNCTION ApplyNewData6( oRegion )

LOCAL i, aBarData[0], aLineData[0]

FOR i := 1 TO 10
Sleep(2)
AAdd(aBarData,(DC_Random(255)*1000)+DC_Random(255))
NEXT

FOR i := 1 TO 10
Sleep(2)
AAdd(aLineData,(DC_Random(25)+(DC_Random(10)*.1)))
NEXT

aLineData := Array(10) // <<<<<<<
AFill(aLineData,0) // <<<<<<<
oRegion:lineGroup[1,DCRMCHART_LINESERIES_VALUELABELON] := RMC_VLABEL_NONE // <<<<<<<

oRegion:barGroup[1,DCRMCHART_BARSERIES_DATA] := aBarData
oRegion:dataAxis[1,DCRMCHART_DATAAXIS_MINVALUE] := 10000
oRegion:dataAxis[1,DCRMCHART_DATAAXIS_MAXVALUE] := 300000
oRegion:lineGroup[1,DCRMCHART_LINESERIES_DATA] := aLineData

oRegion:reset()

RETURN nil
The eXpress train is coming - and it has more cars.

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: RMChart question.

#3 Post by skiman »

Hi Roger,

Thanks for the sample. It seems as removing an element of an array isn't provided. Making it empty is the best way, as you shown.

With this in mind, I can 'remove' the dataaxis the following way.

Code: Select all

oRegion:DataAxis[2,DCRMCHART_DATAAXIS_ALIGNMENT] := 1
oRegion:DataAxis[2,DCRMCHART_DATAAXIS_AXISTEXT ] := chr(255)
oRegion:DataAxis[2,DCRMCHART_DATAAXIS_AXISUNIT] := ""
oRegion:DataAxis[2,DCRMCHART_DATAAXIS_DECIMALDIGITS] := 00
Still visible, but I can live with it. Important is that when you set the element for the text to "", it doesn't work. There must be something in it, chr(255) is working.
Best regards,

Chris.
www.aboservice.be

User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: RMChart question.

#4 Post by Tom »

If I want to create or refresh a RMChart (with new data), I do it this way:

1. DC_GetDestroy(<cChartId>) the chart object if already existing.
2. (Re-)Create the chart object and the complete chart (again) with DCChart..., DCREAD SAVE and DC_MergeGetLists.
3. Every chart comes with it's own context menu which allows to change the chart style and parameters using self-created functions like "SetChartStyle" or "SetChartLabels". They set the properties and call the oChart:Draw() method afterwards.

I tried almost everything to erase the flickering caused by 2., but whatever I used from LockUpdate up to TNT didn't work, so i live with it.

Edit: I'm working on removing all uses of RMChart, since I migrate all those dialogs to HTML step by step.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: RMChart question.

#5 Post by skiman »

Hi Tom,

Thanks for your answer. Modifying a chart (region) isn't easy and not well supported. I was thinking about a solution as you suggested. The creation of a chart is quite fast and this way every chart can created as needed.

I want a dialog with multiple buttons and a static for the chart. Each button will create another chart which I want to display on that static.

Will see if the flickering is annoying or not.
Best regards,

Chris.
www.aboservice.be

User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: RMChart question.

#6 Post by Tom »

Chris -

but setting something like the line style or the value labels is simple and works flowless at runtime:

Code: Select all

oRmChartObject:Region(1):LineSeries(<nCounter>):ValueLabelOn := IF(lValueLabelOn,1,0)
oRmChartObject:Draw()
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: RMChart question.

#7 Post by skiman »

Hi,

Meanwhile my system is working the way Tom suggested.

About the remark for the flickering. I solved this by using two statics. I'm using the statics 'alternating' for the graphics. This way I can build the graph, and show it once it is ready.

This is the principle.
nChart is a var to know which static is used at this moment, this is always 1 or 2..
oChart1 and oChart2 are my two 'parent' statics for the graph.
fCockpitGrafiek is the function that creates the graph. It sends the parent static as third parameter.
Below is the action of a button that creates and shows the graph.
When fCockpitGrafiek returns, the statics are switched with Hide / Show. This changes the static with the graph without 'flickering'.

Code: Select all

... ACTION {|| nChart:= if(nChart=2,1,2) , fCockpitGrafiek("1","B",Getlist,iif(nChart=1,oChart1,oChart2)),;
			iif(nChart=1,(oChart1:show(),oChart2:hide()),(oChart2:show(),oChart1:hide())) , dc_getrefresh(getlist) }
Best regards,

Chris.
www.aboservice.be

User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: RMChart question.

#8 Post by Tom »

Sounds good, Chris.
BTW, in some situations, DC_GetRefresh(GetList) is simply too much for what should be done. Remember that DC_GetRefresh also accepts objects or groups, so maybe a tabpage can be refreshed (re-read all data, evaluate when/hide/editprotect, repaint) by using DC_GetRefresh(oTab). Refreshing a browse contens should be done with oBrowse:RefreshAll(), and if DC_GetWhenOnBrowseItemMarked() is set to .T., all WHEN/HIDE/PROTECT blocks are evaluated if they are connected to the browse. If only drawing/painting routines (ownerdrawing, CustomDrawCell, but others aswell) should run again, use oParent:InvalidateRect() (for the dialog or a child), like if the parameters for a custom cell drawing changed, but the data are still the same. And so on. DC_GetRefresh(GetList) is some kind of all-in-one-solution, but in some/most of the cases, it does much too much, what may cost performance. Besides, DC_GetRefresh() restores some iVars, which may not be what you want to have.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: RMChart question.

#9 Post by skiman »

Hi Tom,
Remember that DC_GetRefresh also accepts objects or groups
Yes I know, and I'm using it in my application. I'm using GROUPS in my dialogs, so it is easy to implement it when needed.

I wasn't aware of DC_GetWhenOnBrowseItemMarked() . I have to check it if I can use it.
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: RMChart question.

#10 Post by rdonnay »

Edit: I'm working on removing all uses of RMChart, since I migrate all those dialogs to HTML step by step.
Tom - I'm interested in how you are drawing graphs in HTML. Are you using XbpHtmlWindow() ?
The eXpress train is coming - and it has more cars.

Post Reply