PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → charts by programming
charts by programming
Iniciado por guest, 18,ene. 2016 10:01 - 3 respuestas
Publicado el 18,enero 2016 - 10:01
Hi,

I have some trouble with charts. I do not want to bind anything to the chart control . This is because I want to fill it by programming.

Ok the basic stuff goes fine when I want to generate a bar chart. I do have some problems with the placement of the leggent and I havenot added the colour of the specific bars but the rest seems to work as expected.

I want to be able to change the type of chart by programming. So user can slecet if he wants a bar chart or a pie chart. This doesnot work. The bar chart can handle the grAdd Data() but the pie charts only load one loop.

I looked at the example but there the graph is linked to a querie in the control. I cannot use that.

My code:

cyTotaalbedrag is currency
nTeller is int = 0

grDeleteSeries(CHART_NoName1)
grCreate(CHART_NoName1,grColumn) // this is for the barchart
grTitle(CHART_NoName1,"",grNone)
FOR ALL Dashboard_widget_instelregels WHERE Dashboard_widget_instellingenID = gnDashboardinstID

nTeller = nTeller+1
cyTotaalbedrag = 0
// QRY_voorsunburstOmzet_per_klant.ParamBeginDatum
// QRY_voorsunburstOmzet_per_klant.ParamEindDatum
// QRY_voorsunburstOmzet_per_klant.ParamGrootboekID
// QRY_voorsunburstOmzet_per_klant.ParamklantenID
IF Dashboard_widget_instelregels.Nivo3 <> 0 THEN
QRY_voorsunburstOmzet_per_klant.ParamBalansNivo2 = Dashboard_widget_instelregels.Nivo3
END
QRY_voorsunburstOmzet_per_klant.ParamBalansNivo1 = Dashboard_widget_instelregels.Nivo2
HExecuteQuery(QRY_voorsunburstOmzet_per_klant,hQueryDefault)

FOR ALL QRY_voorsunburstOmzet_per_klant
cyTotaalbedrag += QRY_voorsunburstOmzet_per_klant.Saldo
END
IF HReadSeekFirst(Dashboard_widget_instellingen,Dashboard_widget_instellingenID,gnDashboardinstID) THEN
IF Dashboard_widget_instellingen.Labelsopnemen = 1 THEN
grSeriesLabel(CHART_NoName1,nTeller,Dashboard_widget_instelregels.Reeks)
END
END
grAddData(CHART_NoName1,nTeller,cyTotaalbedrag)

END
IF HReadSeekFirst(Dashboard_widget_instellingen,Dashboard_widget_instellingenID,gnDashboardinstID) THEN
IF Dashboard_widget_instellingen.omschrijvingXAs <>"" THEN
grAxisTitle(CHART_NoName1,Dashboard_widget_instellingen.omschrijvingXAs,grXCoordinate)
END
IF Dashboard_widget_instellingen.omschrijvingYas <>"" THEN
grAxisTitle(CHART_NoName1,Dashboard_widget_instellingen.omschrijvingYas,grYCoordinate)
END

IF Dashboard_widget_instellingen.RasterXas = 1 THEN
grGridLines(CHART_NoName1,True,grXCoordinate)
ELSE
grGridLines(CHART_NoName1,False,grXCoordinate)
END
IF Dashboard_widget_instellingen.RasterYas = 1 THEN
grGridLines(CHART_NoName1,True,grYCoordinate)
ELSE
grGridLines(CHART_NoName1,False,grYCoordinate)
END


END
IF Dashboard_widget_instellingen.LegendaOpnemen = True THEN
SWITCH Dashboard_widget_instellingen.Legendaoptie
CASE 1
grLegend(CHART_NoName1,grAtBottom)
CASE 2
grLegend(CHART_NoName1,grAtTop)
CASE 3
grLegend(CHART_NoName1,grAtLeft)
CASE 4
grLegend(CHART_NoName1,grAtRight)
OTHER CASE
grLegend(CHART_NoName1,grNone)

END
ELSE
grLegend(CHART_NoName1,grNone)
END

grDraw(CHART_NoName1)



Anyone an Idea why this works wth bar chart and not with pie charts. ??

regards

Allard
Publicado el 19,enero 2016 - 01:16
Hi you all,

since quite a view of you all viewed this topic I guess I should post you my answer.
The simple mistake that I made is that a pie chart can only handle one dimension and a bar chart can handle more. So it is just logic the pie takes the first series.

To fillup a pie one has to specify the serie it uses . and ad stuff to that series

in this code :
grAddData(CHART_NoName1,nTeller,cyTotaalbedrag)

I add

grAddData(CHART_NoName1,1,nTeller,cyTotaalbedrag)

to specify that it is the first series.

So To get it working . Meaning it can accept both charts one has to code this if the pie or donot is used . The other code can be used for a bar chart.

Same goes for for instance the bubble chart . This takes even more diminsions.

So if you want to programm a super advanced dashboard where user can create widgets them selfes you have to keep this in mind. The excample is no good for this , it uses the control to add queries.

regards
Allard
Publicado el 19,enero 2016 - 01:53
Thanks for getting back to us on the answer Allard, appreciate it. We all benefit when a good solution is posted. :spos:
Publicado el 23,enero 2016 - 15:37
Hi you all

I ran into an odd problem whebn dynamicly adding the ledgent to a cart.

Important if you do dynamicly creating charts!!!

The chart control has to have all options on. If for instance you have told the chart control by the 7 tabs window that you donnot wnat to add a ledgend and by programming you try to add it it gets displayed over the chart in an odd way!

So The control uses thoose things!

Hope this helps if you are in the game of dynamuic chart stuff.It took my a view hours to finaly find this out.

regards
Allard