Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [VB.NET 2010] Chart1 con 2 Series ds.Tables.Add(dt)

    Al grafico 3D, non avendo ricevuto risposte ne qui ne su altri forum, ci ho rinunciato, però ho un'altro problemino...

    Nello stesso Chart vorrei 2 elementi...

    codice:
        Private Sub Grafico2(ByVal Mese As String, ByVal Anno As String)
            cnn = New OleDb.OleDbConnection
            cnn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = " & Application.StartupPath & "\gestionale.mdb"
            If Not cnn.State Then
                cnn.Open()
            End If
            Dim ChartArea1 As ChartArea = New ChartArea()
            Dim Legend1 As Legend = New Legend()
            Dim Entrate As Series = New Series()
    
            Dim dt As New DataTable
            Dim ds As New DataSet
            ds.Tables.Add(dt)
    
            sql2 = "SELECT Data, Importo FROM entrate "
            If Mese <> "--Tutti--" And Anno <> "--Tutti--" Then
                sql2 = sql2 & "WHERE month(Data)=" & Mese & " and Year(Data) = " & Anno
            ElseIf Mese <> "--Tutti--" And Anno = "--Tutti--" Then
                sql2 = sql2 & "WHERE month(Data)=" & Mese
            ElseIf Mese = "--Tutti--" And Anno <> "--Tutti--" Then
                sql2 = sql2 & "WHERE Year(Data) = " & Anno
            End If
            sql2 = sql2 & " Order By ID ASC"
    
            Dim da As New OleDbDataAdapter(sql2, cnn)
            da.Fill(ds, "entrate")
    
            Entrate.Name = "Entrate"
            Chart2.Legends("Legend1").BackColor = Color.Transparent
            Chart2.Series("Entrate").IsValueShownAsLabel = True
            Chart2.Series("Entrate").XValueMember = "Data"
            Chart2.Series("Entrate").YValueMembers = "Importo"
            Chart2.DataSource = ds.Tables("entrate")
            cnn.Close()
    
    
            If Not cnn.State Then
                cnn.Open()
            End If
    
            Dim Uscite As Series = New Series()
    
            Dim dt1 As New DataTable
            Dim ds1 As New DataSet
            ds1.Tables.Add(dt1)
    
            sql3 = "SELECT Data, Importo FROM uscite "
            If Mese <> "--Tutti--" And Anno <> "--Tutti--" Then
                sql3 = sql3 & "WHERE month(Data)=" & Mese & " and Year(Data) = " & Anno
            ElseIf Mese <> "--Tutti--" And Anno = "--Tutti--" Then
                sql3 = sql3 & "WHERE month(Data)=" & Mese
            ElseIf Mese = "--Tutti--" And Anno <> "--Tutti--" Then
                sql3 = sql3 & "WHERE Year(Data) = " & Anno
            End If
            sql3 = sql3 & " Order By ID ASC"
    
            Dim da1 As New OleDbDataAdapter(sql3, cnn)
            da1.Fill(ds1, "uscite")
    
            Uscite.Name = "Uscite"
            Chart2.Series("Uscite").IsValueShownAsLabel = True
            Chart2.Series("Uscite").XValueMember = "Data"
            Chart2.Series("Uscite").YValueMembers = "Importo"
            Chart2.DataSource = ds1.Tables("uscite")
            cnn.Close()
    
        End Sub

    Il mio errore è qui...

    codice:
    Chart2.DataSource = ds.Tables("entrate")
    .
    .
    .
    .
    .
    .
    .
    .
    .
    
    Chart2.DataSource = ds1.Tables("uscite")
    Come risolvo?
    Powered by iMac 27"

  2. #2
    Allora, visto che non ho ancora ricevuto risposte... forse è il caso di riformulare il problema...


    Il codice scritto in questo modo, mi prende solo i valori di 1 Series, in questo caso l'ultimo....

    Come posso fare per avere entrambi nel grafico??

    Quando vado a scrivere questo codice:

    codice:
    Chart2.DataSource = ds.Tables("entrate")
    .
    .
    .
    .
    .
    .
    .
    .
    .
    
    Chart2.DataSource = ds1.Tables("uscite")
    Non me lo calcola tutto ma solo l'ultimo pezzo... Chart2.DataSource = ds1.Tables("uscite")
    come posso ovviare a questo problema????
    Powered by iMac 27"

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.