Autore Topic: gb.chart  (Letto 7218 volte)

Offline andy60

  • Senatore Gambero
  • ******
  • Post: 1.256
    • Mostra profilo
    • https://www.linkedin.com/in/andbertini
gb.chart
« il: 26 Settembre 2009, 10:00:24 »
Ho provato a creare un semplice programmetto di test del componente in questione, ma mi da' errore (null object error). Forse sono un po' arrugginito con gambas!
Il programma è composto da un bottone (che crea il grafico), una form , una drawing area.

Codice: [Seleziona]
' Gambas class file

PUBLIC SUB _new()

END

PUBLIC SUB Form_Open()

END

PUBLIC SUB Button1_Click()

  SetMyChart

END

SUB SetMyChart()
  DIM mychart AS Chart
  mychart.Headers = ["a", "b", "c"]
  mychart[0].Values = [1.0, 2.0, 3.0]
  mychart.Title = "Chart test"
  mychart.Legend.Visible = TRUE
  mychart.Legend.Title = "My legend"
  mychart.Type = ChartType.Lines
  mychart.Style = ChartStyle.Custom
  mychart.Colors.Values = [Color.Yellow, Color.Red, Color.Blue]
  mychart.Width = DrawingArea1.ClientHeight
  mychart.Height = DrawingArea1.ClientWidth
  mychart.Draw
END

Offline giulio

  • Maestro Gambero
  • ****
  • Post: 280
    • Mostra profilo
Re: gb.chart
« Risposta #1 il: 26 Settembre 2009, 13:00:06 »
Quell'errore è tipico di un oggetto non inizializzato:

prova:

DIM mychart AS NEW Chart

oppure verifica la DrawingArea.

Ciao.

Offline andy60

  • Senatore Gambero
  • ******
  • Post: 1.256
    • Mostra profilo
    • https://www.linkedin.com/in/andbertini
Re: gb.chart
« Risposta #2 il: 26 Settembre 2009, 13:36:49 »
non esce + quell'errore, ma mi dice che mychart.headers è readonly

Offline giulio

  • Maestro Gambero
  • ****
  • Post: 280
    • Mostra profilo
Re: gb.chart
« Risposta #3 il: 26 Settembre 2009, 15:07:58 »
Prova:

mychart.Headers.Add("a")
mychart.Headers.Add("b")
mychart.Headers.Add("c")

Bisogna segnalare a Benoit che non c'è documentazione per gb.chart!

Offline Ceskho

  • Amministratore
  • Senatore Gambero
  • *****
  • Post: 3.778
  • Vi Veri Veniversum Vivus Vici
    • Mostra profilo
    • Pagina Personale
Re: gb.chart
« Risposta #4 il: 26 Settembre 2009, 15:14:45 »
Il massimo che puoi trovare è questo: http://gambasdoc.org/help/howto/makechart

Comunque chiederei gentilmente ad Andy60 se una volta finito di testare il componente può scrivere, per favore, due righe sul nostro wiki a riguardo così ovviamo alla palese mancanza di materiale a riguardo.

Te ne saremmo tutti grati.

Offline andy60

  • Senatore Gambero
  • ******
  • Post: 1.256
    • Mostra profilo
    • https://www.linkedin.com/in/andbertini
Re: gb.chart
« Risposta #5 il: 26 Settembre 2009, 22:08:46 »
se riesco con grande piacere, grazie x le info

Offline andy60

  • Senatore Gambero
  • ******
  • Post: 1.256
    • Mostra profilo
    • https://www.linkedin.com/in/andbertini
Re: gb.chart
« Risposta #6 il: 27 Settembre 2009, 10:08:45 »
queste istruzioni mi danno errore all'istruzione draw: NO CURRENT DEVICE
gli errori iniziali non ci sono piu'...

Codice: [Seleziona]
PUBLIC SUB Button1_Click()
  DIM mychart AS NEW Chart
  mychart.Headers.Add("a")
  mychart.Headers.Add("b")
  mychart.Headers.Add("c")
  mychart[0].Values.Add(1.0)
  mychart[0].Values.Add(2.0)
  mychart[0].Values.Add(3.0)
  mychart.Title.Text = "Chart test"
  mychart.Legend.Visible = TRUE
  mychart.Legend.Title = "My legend"
  mychart.Type = ChartType.Lines
  mychart.Style = ChartStyle.Custom
  mychart.Colors.Values = [Color.Yellow, Color.Red, Color.Blue]
  mychart.Width = DrawingArea1.ClientHeight
  mychart.Height = DrawingArea1.ClientWidth
  mychart.Draw
END

Offline giulio

  • Maestro Gambero
  • ****
  • Post: 280
    • Mostra profilo
Re: gb.chart
« Risposta #7 il: 27 Settembre 2009, 10:28:03 »
Manca il draw.begin() e il draw.end()

Codice: [Seleziona]

PUBLIC SUB Button1_Click()
 
  DIM myChart AS NEW Chart
 
  mychart.Headers.Add("a")
  mychart.Headers.Add("b")
  mychart.Headers.Add("c")
  mychart[0].Values.Add(1.0)
  mychart[0].Values.Add(2.0)
  mychart[0].Values.Add(3.0)
  mychart.Title.Text = "Chart test"
  mychart.Legend.Visible = TRUE
  mychart.Legend.Title = "My legend"
  mychart.Type = ChartType.Lines
  mychart.Style = ChartStyle.Custom
  mychart.Colors.Values = [Color.Yellow, Color.Red, Color.Blue]
 
  Draw.Begin(DrawingArea1)    
 
  myChart.Width = DrawingArea1.ClientHeight
  myChart.Height = DrawingArea1.ClientWidth
  TRY myChart.Draw()
 
  Draw.End
 
END


NOTA: alla fine ho messo un TRY prima di mychart.draw, perché senza si blocca
con un errore 'division by zero'.

Offline andy60

  • Senatore Gambero
  • ******
  • Post: 1.256
    • Mostra profilo
    • https://www.linkedin.com/in/andbertini
Re: gb.chart
« Risposta #8 il: 27 Settembre 2009, 10:53:02 »
grazie, sperimento :2birre:

Offline andy60

  • Senatore Gambero
  • ******
  • Post: 1.256
    • Mostra profilo
    • https://www.linkedin.com/in/andbertini
Re: gb.chart
« Risposta #9 il: 29 Settembre 2009, 17:53:07 »
non riesco a fare grafici, ancora, qualcuno ha qualche demotest funzionante?

Offline Ceskho

  • Amministratore
  • Senatore Gambero
  • *****
  • Post: 3.778
  • Vi Veri Veniversum Vivus Vici
    • Mostra profilo
    • Pagina Personale
Re: gb.chart
« Risposta #10 il: 29 Settembre 2009, 18:01:24 »
Ciao andy,

tra gli esempi di gambas ce ne uno che si chiama BarChart ed è nello szione Disegno. Prova a dare un'occhiata perchè pare proprio faccia ciò che vuoi tu....

Offline fsurfing

  • Moderatore
  • Senatore Gambero
  • *****
  • Post: 2.484
    • Mostra profilo
Re: gb.chart
« Risposta #11 il: 29 Settembre 2009, 18:59:58 »
io ho sempre fatto i grafici tramite le funzioni di disegno (senza componente gb,chart) e mi son trovato benissimo,

se guardi meteomachine sono presenti grafici a torta , barre e linee

Offline andy60

  • Senatore Gambero
  • ******
  • Post: 1.256
    • Mostra profilo
    • https://www.linkedin.com/in/andbertini
Re: gb.chart
« Risposta #12 il: 29 Settembre 2009, 19:00:13 »
grazie...ti segnalo la pagina di gambas che interessa questo argomento, l'esempio che c'è scritto non va, a me non funziona. Dovremmo partire da la x fare un test:

http://gambasdoc.org/help/howto/makechart


IMHO la routine dei grafici dovrebbe funzionare perfettamente, se l'obiettivo è creare con il ns amato programma dei software gestionali, e non solo. Il mio programma "Diet & Sport" crea grafici 3d a torta dei nutrienti incamerati giornalmente, attingendo alle api Google, chiaramente mi piacerebbe fare lo stesso senza andare su google.

Offline andy60

  • Senatore Gambero
  • ******
  • Post: 1.256
    • Mostra profilo
    • https://www.linkedin.com/in/andbertini
Re: gb.chart
« Risposta #13 il: 29 Settembre 2009, 19:02:15 »
scusa l'ignoranza dove devo vedere meteomach...? hai sviluppato funzioni ad hoc? stanno nel wiki? grazie

Offline Ceskho

  • Amministratore
  • Senatore Gambero
  • *****
  • Post: 3.778
  • Vi Veri Veniversum Vivus Vici
    • Mostra profilo
    • Pagina Personale
Re: gb.chart
« Risposta #14 il: 29 Settembre 2009, 19:02:29 »
Allora penso che dovrai o abbandonare l'idea dei grafici a torta 3D e passare ad altro o rimanere con le API di google....

Per meteomachine puoi scaricare i sorgenti qui: http://www.altabrianza.org/meteomachinelinux/download.html