begin process at 2012 02 17 05:09:24
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Graphique

 > COURBE 2D SANS MSCHART

COURBE 2D SANS MSCHART


 Information sur la source

Note :
8,23 / 10 - par 13 personnes
8,23 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Graphique Source .NET ( DotNet ) Classé sous :chart, courbe, mschart, graphique, usercontrol Niveau :Débutant Date de création :11/01/2006 Date de mise à jour :13/01/2006 00:28:55 Vu / téléchargé :17 438 / 3 264

Auteur : nicolas99

Ecrire un message privé
Commentaire sur cette source (20)
Ajouter un commentaire et/ou une note

 Description

Cliquez pour voir la capture en taille normale
Bonjour à tous,
c'est la premiére fois que pose une source, elle est très peu commentée(ou pas du tout).
Ce code permet de faire une représentation graphique de tableau.

Mettez une note svp.


 Conclusion

Amélioration de l'aspect

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Historique

12 janvier 2006 14:52:46 :
Amélioration de l'aspect
12 janvier 2006 18:08:36 :
ajout représentation en barre
12 janvier 2006 18:14:00 :
nettoyage du zip
13 janvier 2006 00:28:55 :
ajout des valeurs moyennes ajout sauvegarde image du graphique

 Sources du même auteur

Source avec Zip Source avec une capture Source .NET (Dotnet) ENCORE UNE FORM AEROGLASS SANS API AVEC EFFET FLOU
Source avec Zip Source .NET (Dotnet) UNE FENÊTRE PARENT POUR GIMP2-2

 Sources de la même categorie

Source avec Zip Source avec une capture Source .NET (Dotnet) VB10 - CRÉER VOS PROPRES CALQUES SUR UNE IMAGE par Duke49
Source avec Zip Source avec une capture Source .NET (Dotnet) CREER UN GIF ANIMÉ par Le Pivert
Source avec une capture GRAPH PHP COURBE DE CHARGE par s.defaye
Source avec Zip Source avec une capture BOULE DE CRISTAL par BLUEBIBUBBLE
VB6 - DÉPLACEMENT D'UN CONTRÔLE SUR UN SEGMENT DE DROITE DÉL... par ucfoutu

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture Source .NET (Dotnet) GÉNÉRATEUR DE GRAPHIQUE par pascamau
Source avec une capture Source .NET (Dotnet) USER CONTROL POUR UN HISTOGRAMME À BARRES VERTICALES par tchconst
Source avec Zip Source avec une capture Source .NET (Dotnet) USER CONTROL GRAPHIQUE VB 2005 par lapix
Source avec Zip GRAPHIQUE 1 À 4 COURBES AVEC MSCHART par mertronic
GRAPHIQUE AVEC MSCHART par aurbadguy

Commentaires et avis

Commentaire de clementpat le 12/01/2006 17:10:18

Rien qu'a voir le nombre de fichier ,pour un petit truc comme cela ..............

j'ai vraiment pas envie de me mettre a VB Net

Commentaire de seakleng le 20/02/2006 18:00:33

Le programme est bien fait pour illustrer la représentation 2D en courbe ainsi que la gestion de couleurs et de caractères associés, en plus on peut sauvegarder l'image en fichier PNG.

Commentaire de stab le 26/04/2006 12:53:44

Super code ! Merci beaucoup !
Dommage que les variables ne soient pas plus explicite :)

Commentaire de tipoune94 le 29/05/2006 21:34:07

enfin un exemple de graphique sans MSChart! Merci!

Commentaire de piloulr le 28/07/2006 11:12:29

MERCI, MERCI !!!

J'avais besoin d'afficher des graphiques dans mon application.

L'intégration de ton code dans le mien à était immédiat.

Le résultat en terme de design et de fonctionnalité fait l'approbation des utilisateurs.

PS : Ton code est peut être compliqué pour certain, mais avec la contrainte de ne pas utiliser de biblio Office ou MSChart par exemple, c'est le plus simple et le plus costaud.

PS : A quand les cammenbert ????

Commentaire de ooztari le 17/11/2006 18:53:40

good

Commentaire de Avenger01 le 11/12/2006 13:41:40

Très bon boulot !

Commentaire de doudouallemand le 09/01/2007 15:18:02

Super code.

Par contre, j'aurai besoin de mettre la valeur des barres dans chacunes d'entre elle mais je ne trouve pas comment faire... quelqu'un saurait SVP ???
Et aussi, est-il possible de faire des barres qui ont une hauteur fixe mais une largeur variable (en clair, c'est l'horizontal qui devient vertical) ??
merci d'avance

Commentaire de gui4242 le 01/05/2007 10:54:52

bravo !

Commentaire de frjoachp le 28/08/2007 15:27:00

Super code, Le graphisme est excellent.
Par contre quand je veux afficher des valeurs négatives, les points se retrouvent en dehors du graph. Quelqu'un a une parade ?

Merci

Commentaire de dedebatou le 13/09/2007 14:58:01

Voici le module Graph.vb corrigé pour accepter les valeurs négatives:

Imports System.Drawing
Imports System.Drawing.Drawing2D

Public Class graph
    Public chartdata(0, 0) As Object
    Public CourbeVisible(100) As Boolean
    Public barVisible(100) As Boolean
    Public CurseurVisible(100) As Boolean
    Public ValeurMoyenne(100) As Boolean
    Public PenCourbe(100) As Pen
    Public Image As Bitmap

    Private PenAxe As New Pen(Color.Black, 2)
    Private PenGrill As New Pen(Color.Gray, 0)
    Private BrushTitre As Brush = Brushes.Black
    Private Bcolor As Color = Color.White
    Private ombre As Color = Color.LightGray
    Private ovisible As Boolean = True
    Private Penombre As New Pen(Color.LightGray, 2)
    Private colorgrill As Color = Color.Gray
    Private colortitre As Color = Color.Black
    Private coloraxe As Color = Color.Black
    Private BcolorGrill As Color = Color.White
    Private FontY As Font = New System.Drawing.Font("MicrosoFontTitre Sans Serif", 8.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Private FontX As Font = New System.Drawing.Font("MicrosoFontTitre Sans Serif", 8.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Private FTitre As Font = New System.Drawing.Font("MicrosoFontTitre Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Private titre As String = "Titre"
    Private naxex As String = ""
    Private naxey As String = ""
    Private mb As Integer = 100
    Private mh As Integer = 40
    Private ml As Integer = 50
    Private ex As Integer
    Private ey As Integer
    Private ny As Integer
    Private gg As Graphics
    Private orientX As Boolean
    Private nbc As Integer = 2
    Private nbe As Integer = 1000
    Private rcontrole As Rectangle
    Private rgraph As Rectangle
    Private pvisible As Boolean = True
    Private zoom As Boolean
    Private ccontour As Color = Color.Black
    Private cvisible As Boolean
    Private moy(100) As Double
    Private vmin As Integer

    Public ReadOnly Property Moyenne(ByVal n As Integer) As Double
        Get
            Return moy(n)
        End Get
    End Property
    Public Property CouleurContour() As Color
        Get
            Return ccontour
        End Get
        Set(ByVal value As Color)
            ccontour = value
            Me.Refresh()
        End Set
    End Property
    Public Property ContourVisible() As Boolean
        Get
            Return cvisible
        End Get
        Set(ByVal value As Boolean)
            cvisible = value
            Me.Refresh()
        End Set
    End Property
    Public Property ZoomActif() As Boolean
        Get
            Return zoom
        End Get
        Set(ByVal value As Boolean)
            zoom = value
        End Set
    End Property
    Public Property NomAxeX() As String
        Get
            Return naxex
        End Get
        Set(ByVal value As String)
            naxex = value
        End Set
    End Property
    Public Property NomAxeY() As String
        Get
            Return naxey
        End Get
        Set(ByVal value As String)
            naxey = value
        End Set
    End Property
    Public Property FontAxeX() As Font
        Get
            Return FontX
        End Get
        Set(ByVal value As Font)
            FontX = value
            Me.Refresh()
        End Set
    End Property
    Public Property FontAxeY() As Font
        Get
            Return FontY
        End Get
        Set(ByVal value As Font)
            FontY = value
            Me.Refresh()
        End Set
    End Property
    Public Property FontTitre() As Font
        Get
            Return FTitre
        End Get
        Set(ByVal value As Font)
            FTitre = value
            Me.Refresh()
        End Set
    End Property
    Public Property CouleurAxe() As Color
        Get
            Return coloraxe
        End Get
        Set(ByVal value As Color)
            coloraxe = value
            PenAxe = New Pen(colortitre, 2)
            Me.Refresh()
        End Set
    End Property
    Public Property CouleurTitre() As Color
        Get
            Return colortitre
        End Get
        Set(ByVal value As Color)
            colortitre = value
            BrushTitre = New Pen(colortitre).Brush
            Me.Refresh()
        End Set
    End Property
    Public Property NomTitre() As String
        Get
            Return titre
        End Get
        Set(ByVal value As String)
            titre = value
        End Set
    End Property
    Public Property OmbreCourbe() As Boolean
        Get
            Return ovisible
        End Get
        Set(ByVal value As Boolean)
            ovisible = value
            Me.Refresh()
        End Set
    End Property
    Public Property CouleurFond() As Color
        Get
            Return Bcolor
        End Get
        Set(ByVal value As Color)
            Bcolor = value
            Me.Refresh()
        End Set
    End Property
    Public Property CouleurFondGrille() As Color
        Get
            Return BcolorGrill
        End Get
        Set(ByVal value As Color)
            BcolorGrill = value
            Me.Refresh()
        End Set
    End Property
    Public Property CouleurGrille() As Color
        Get
            Return colorGrill
        End Get
        Set(ByVal value As Color)
            colorGrill = value
            Me.Refresh()
        End Set
    End Property
    Public Property NbCourbe() As Integer
        Get
            Return nbc
        End Get
        Set(ByVal value As Integer)
            nbc = value
            ReDim chartdata(nbe, value)
            ReDim CourbeVisible(value)
            ReDim PenCourbe(value)
        End Set
    End Property
    Public Property NbElement() As Integer
        Get
            Return nbe
        End Get
        Set(ByVal value As Integer)
            nbe = value + 1
            ReDim chartdata(value, nbc)
        End Set
    End Property
    Public Property PointVisible() As Boolean
        Get
            Return pvisible
        End Get
        Set(ByVal value As Boolean)
            pvisible = value
            Me.Refresh()
        End Set
    End Property
    Private Function maxX() As Integer
        Try
            maxX = 1
            If chartdata.GetLength(0) = 100 Then Exit Function
            Dim i As Integer
            For i = 1 To chartdata.GetLength(1) - 1
                If Len(chartdata(i, 0)) > maxX Then maxX = Len(chartdata(i, 0))
            Next

        Catch ex As Exception

        End Try
    End Function
    Private Function maxval() As Integer
        Try
            maxval = 0
            If chartdata.GetLength(0) = 100 Then Exit Function
            Dim i As Integer, j As Integer
            For i = 1 To chartdata.GetLength(1) - 1
                For j = 0 To chartdata.GetLength(0) - 1
                    If Val(chartdata(j, i)) > maxval And CourbeVisible(i) = True Then maxval = Math.Ceiling(Val(chartdata(j, i)))
                    If Val(chartdata(j, i)) > maxval And barVisible(i) = True Then maxval = Math.Ceiling(Val(chartdata(j, i)))
                    If Val(chartdata(j, i)) > maxval And CurseurVisible(i) = True Then maxval = Math.Ceiling(Val(chartdata(j, i)))
                Next
            Next

        Catch ex As Exception

        End Try
    End Function

    Private Function minval() As Integer
        Try
            minval = 0
            If chartdata.GetLength(0) = 100 Then Exit Function
            Dim i As Integer, j As Integer
            For i = 1 To chartdata.GetLength(1) - 1
                For j = 0 To chartdata.GetLength(0) - 1
                    If Val(chartdata(j, i)) < minval And CourbeVisible(i) = True Then minval = Math.Ceiling(Val(chartdata(j, i)))
                    If Val(chartdata(j, i)) < minval And barVisible(i) = True Then minval = Math.Ceiling(Val(chartdata(j, i)))
                    If Val(chartdata(j, i)) < minval And CurseurVisible(i) = True Then minval = Math.Ceiling(Val(chartdata(j, i)))
                Next
            Next

        Catch ex As Exception

        End Try
    End Function

    Private Sub Fond_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Fond.Paint
        Image = New Bitmap(Fond.Width, Fond.Height)
        Dim g As Graphics = Graphics.FromImage(Image)
        Dim gf As Graphics = Fond.CreateGraphics
        g.SmoothingMode = SmoothingMode.AntiAlias
        Try
            'calcul la marge droite et gauche
            ml = (FontY.GetHeight * (1 + Len(CStr(maxval())))) * 1.6
            'calcule de la marge basse
            mb = (FontX.GetHeight + 10) * 2
            'calcule marge basse si ecriture verticale
            orientX = False
            If (Fond.Width - (2 * ml)) / chartdata.GetLength(0) < (FontX.GetHeight * maxX() * 0.6) Then
                mb = (maxX() * FontX.GetHeight * 0.5) + 10 + (FontX.GetHeight + 10)
                orientX = True
            End If
            'dessine fond du graph
            dessinefond(g)
            dessgrille(g)
            'dessine axe x
            dessineaxe(g)
            dessinebar(g)
            dessinecurseur(g)
            desscourbe(g)
            dessinemoyenne(g)

            gf.DrawImage(Image, 0, 0)
            g.Dispose()
            gf.Dispose()
        Catch ex As Exception

        End Try
    End Sub
    Private Sub dessineaxe(ByVal g As Graphics)
        Try
            PenAxe = New Pen(coloraxe, 2)
            g.DrawLine(PenAxe, ml - 5, Fond.Height - mb, Fond.Width - ml + 5, Fond.Height - mb)
            'dessine axe y
            g.DrawLine(PenAxe, ml, mh, ml, Fond.Height - (mb - 5))
            'g.DrawLine(PenAxe, Fond.Width - ml, mh, Fond.Width - ml, Fond.Height - (mb - 5))
            'affiche nom axe x
            g.DrawString(naxex, FontX, PenAxe.Brush, (Fond.Width - FontX.GetHeight * 0.5 * naxex.Length) / 2, Fond.Height - FontX.GetHeight - 10)
            'affiche nom axe y
            Dim sf As StringFormat = StringFormat.GenericTypographic
            sf.FormatFlags = StringFormatFlags.DirectionVertical
            g.DrawString(naxey, FontY, PenAxe.Brush, 10, (Fond.Height - mb - mh) / 2, sf)
            ' g.DrawString(naxey, FontY, PenAxe.Brush, Fond.Width - 10 - FontY.GetHeight, (Fond.Height - mb - mh) / 2, sf)

        Catch ex As Exception

        End Try
    End Sub
    Private Sub dessinefond(ByVal g As Graphics)
        Try
            rcontrole = New Rectangle(0, 0, Fond.Width, Fond.Height)
            rgraph = New Rectangle(ml, mh, Fond.Width - (2 * ml), Fond.Height - mh - mb)
            Dim lbrush As New LinearGradientBrush(rcontrole, Bcolor, Color.WhiteSmoke, LinearGradientMode.ForwardDiagonal)
            g.FillRectangle(lbrush, rcontrole)
            lbrush = New LinearGradientBrush(rgraph, BcolorGrill, Color.WhiteSmoke, LinearGradientMode.Horizontal)
            g.FillRectangle(lbrush, rgraph)

            Dim tp As New Pen(ccontour, 2)
            If cvisible = True Then
                g.DrawRectangle(tp, Math.Abs(Fond.Left), Fond.Top, Me.Width - 1, Me.Height - 1)
            End If

        Catch ex As Exception

        End Try
    End Sub
    Private Sub dessgrille(ByVal g As Graphics)
        Dim i As Integer, j As Integer, v As Integer, xx As Integer, yy As Integer, ec As Integer, it As Integer
        Try
            'affiche le titre
            PenAxe = New Pen(coloraxe, 2)
            ombre = Color.FromArgb(128, ombre.R, ombre.G, ombre.B)
            Penombre = New Pen(ombre, PenCourbe(i).Width)
            Penombre.StartCap = LineCap.Round
            If ovisible = True Then g.DrawString(titre, FontTitre, Penombre.Brush, (Fond.Width / 2 - (titre.Length * FontTitre.GetHeight) / 4) + 3, 8)
            g.DrawString(titre, FontTitre, BrushTitre, (Fond.Width / 2 - (titre.Length * FontTitre.GetHeight) / 4), 5)
            'trouve la valeur max de l'axe y
            v = maxval()
            vmin = minval()
            'calcule longeur des axe
            xx = Fond.Width - (2 * ml)
            yy = (Fond.Height - mb) - mh
            'calcule echelle y
            ec = ((yy) / (v - vmin))
            If ec = 0 Then ec = 1
            If ec < 20 Then
                i = Math.Ceiling(20 / ec)
                ec = ec * i
            End If
            it = Math.Ceiling((v - vmin) / (yy / ec))
            ey = it
            ny = ec
            j = vmin
            Dim lg As Integer
            PenGrill = New Pen(colorgrill, 1)
            PenGrill.DashStyle = DashStyle.Dash
            For i = 0 To yy Step ec
                lg = Len(CStr(j)) * (FontY.GetHeight * 0.5)
                g.DrawLine(PenGrill, ml - 5, Fond.Height - mb - i, Fond.Width - ml + 5, Fond.Height - mb - i)
                g.DrawString(CStr(j), FontY, PenAxe.Brush, ml - 10 - lg, Fond.Height - mb - i - (FontY.GetHeight / 2))
                'g.DrawString(CStr(j), FontY, PenAxe.Brush, Fond.Width - ml + 5, Fond.Height - mb - i - (FontY.GetHeight / 2))
                j = j + it
            Next
            'calcul echelle x
            ec = Fix((xx * 100) / (chartdata.GetLength(0)))
            j = 0
            ex = ec
            Dim mx As Integer = -1
            Dim ii As Integer
            For i = 0 To (xx * 100) - ec Step ec
                ii = i / 100
                g.DrawLine(PenGrill, ml + ii, Fond.Height - mb + 5, ml + ii, mh)
                If orientX = True Then
                    Dim sf As StringFormat = StringFormat.GenericTypographic
                    sf.FormatFlags = StringFormatFlags.DirectionVertical
                    If ii > mx Then
                        g.DrawString(CStr(chartdata(j, 0)), FontX, PenAxe.Brush, ml + ii + (ec / 200) - (FontX.GetHeight * 0.5), Fond.Height - mb + 5, sf)
                        mx = ii + FontX.GetHeight
                    End If
                Else
                    g.DrawString(CStr(chartdata(j, 0)), FontX, PenAxe.Brush, ml + ii + (ec / 200) - (FontX.GetHeight * 0.5 * (Len(chartdata(j, 0)) / 2)), Fond.Height - mb + 5)
                End If
                j = j + 1
            Next
            gg = g
        Catch ex As Exception

        End Try

    End Sub
    Private Sub desscourbe(ByVal g As Graphics)
        Dim i As Integer, j As Integer, xx As Integer, yy As Integer, xx0 As Integer, yy0 As Integer, tx As Integer, tx0 As Integer
        Try
            For i = 1 To chartdata.GetLength(1) - 1
                xx = ml * 100 + ex / 2
                yy = (Fond.Height - mb) - ((chartdata(0, i) - vmin) / ey) * ny
                PenCourbe(i).LineJoin = LineJoin.Round
                For j = 1 To chartdata.GetLength(0) - 1
                    xx0 = (xx + ex)
                    yy0 = (Fond.Height - mb) - ((chartdata(j, i) - vmin) / ey) * ny
                    tx = xx / 100
                    tx0 = xx0 / 100
                    If CourbeVisible(i) = True And ovisible = True Then g.DrawLine(Penombre, tx + 7, yy + 7, tx0 + 7, yy0 + 7)
                    If CourbeVisible(i) = True Then g.DrawLine(PenCourbe(i), tx, yy, tx0, yy0)
                    xx = xx0
                    yy = yy0
                Next
                xx = ml * 100 + ex / 2
                yy = (Fond.Height - mb) - ((chartdata(0, i) - vmin) / ey) * ny
                If pvisible = True Then
                    For j = 1 To chartdata.GetLength(0) - 1
                        xx0 = (xx + ex)
                        yy0 = (Fond.Height - mb) - ((chartdata(j, i) - vmin) / ey) * ny
                        tx = xx / 100
                        tx0 = xx0 / 100
                        Dim bo As Brush = Brushes.LightGray

                        If CourbeVisible(i) = True And ovisible = True Then g.FillPie(Penombre.Brush, tx - (PenCourbe(i).Width * 2) + 7, yy - (PenCourbe(i).Width * 2) + 7, PenCourbe(i).Width * 4, PenCourbe(i).Width * 4, 0, 360)
                        If CourbeVisible(i) = True Then g.FillPie(PenCourbe(i).Brush, tx - (PenCourbe(i).Width * 2), yy - (PenCourbe(i).Width * 2), PenCourbe(i).Width * 4, PenCourbe(i).Width * 4, 0, 360)
                        xx = xx0
                        yy = yy0
                    Next
                    tx = xx / 100
                    If CourbeVisible(i) = True And ovisible = True Then g.FillPie(Penombre.Brush, tx - (PenCourbe(i).Width * 2) + 7, yy - (PenCourbe(i).Width * 2) + 7, PenCourbe(i).Width * 4, PenCourbe(i).Width * 4, 0, 360)
                    If CourbeVisible(i) = True Then g.FillPie(PenCourbe(i).Brush, tx - (PenCourbe(i).Width * 2), yy - (PenCourbe(i).Width * 2), PenCourbe(i).Width * 4, PenCourbe(i).Width * 4, 0, 360)

                End If
            Next
        Catch ex As Exception

        End Try
    End Sub
    Private Sub dessinebar(ByVal g As Graphics)
        Dim i As Integer, j As Integer, v As Integer, xx As Integer, yy As Integer, tx As Integer, lb As Integer
        Try
            'calcule largeur bar
            j = 0
            For i = 1 To chartdata.GetLength(1) - 1
                If barVisible(i) = True Then j = j + 1
            Next
            lb = ex / j
            lb = lb / 100
            'dessine bar
            v = 0
            For i = 1 To chartdata.GetLength(1) - 1
                xx = ml * 100 + (lb * 100) * v
                If barVisible(i) = True Then v = v + 1
                ombre = Color.FromArgb(128, ombre.R, ombre.G, ombre.B)
                Penombre = New Pen(ombre, PenCourbe(i).Width)
                Penombre.StartCap = LineCap.Round
                Dim rbar As Rectangle
                For j = 0 To chartdata.GetLength(0) - 1
                    yy = (Fond.Height - mb) - (((chartdata(j, i) - vmin) / ey) * ny + 1)
                    tx = (xx / 100)
                    rbar = New Rectangle(tx, yy, lb / 2, Fond.Height - (yy + mb))
                    Dim tmpcolor As Color
                    tmpcolor = Color.FromArgb(64, PenCourbe(i).Color.R, PenCourbe(i).Color.G, PenCourbe(i).Color.B)
                    Dim tmpbrush = New LinearGradientBrush(rbar, PenCourbe(i).Color, tmpcolor, LinearGradientMode.Horizontal)
                    tmpbrush.WrapMode = 3
                    If barVisible(i) = True Then g.FillRectangle(tmpbrush, tx, yy, lb, Fond.Height - (yy + mb))
                    xx = xx + ex
                Next
            Next
        Catch ex As Exception

        End Try
    End Sub
    Private Sub dessinecurseur(ByVal g As Graphics)
        Dim i As Integer, j As Integer, xx As Integer, yy As Integer, xx0 As Integer, yy1 As Integer, tx As Integer, tx1 As Integer, xx1 As Integer
        Try
            'dessine curseur
            For i = 1 To chartdata.GetLength(1) - 1
                xx = ml * 100
                Dim rbar As Rectangle
                For j = 0 To chartdata.GetLength(0) - 1
                    yy = (Fond.Height - mb) - (((chartdata(j, i) - vmin) / ey) * ny + 1)
                    tx = (xx / 100)
                    xx0 = ex / 100
                    rbar = New Rectangle(tx, yy, xx0 / 2, 2)
                    Dim tmpcolor As Color
                    tmpcolor = Color.FromArgb(0, PenCourbe(i).Color.R, PenCourbe(i).Color.G, PenCourbe(i).Color.B)
                    Dim tmpbrush = New LinearGradientBrush(rbar, tmpcolor, PenCourbe(i).Color, LinearGradientMode.Horizontal)
                    tmpbrush.WrapMode = 3

                    If curseurVisible(i) = True Then g.FillRectangle(tmpbrush, tx, yy, xx0, 2)
                    rbar = New Rectangle(tx, yy, xx0 / 4, 2)
                    tmpbrush = New LinearGradientBrush(rbar, PenCourbe(i).Color, tmpcolor, LinearGradientMode.Horizontal)
                    tmpbrush.WrapMode = 3
                    xx1 = xx0 / 2
                    tx1 = tx + (xx0 / 4)
                    yy1 = yy - 1
                    tx = tx + (xx0 / 2)
                    If curseurVisible(i) = True Then g.FillRectangle(tmpbrush, tx1, yy1, xx1, 4)
                    If curseurVisible(i) = True And pvisible = True Then g.FillPie(PenCourbe(i).Brush, tx - 6, yy1 - 5, 12, 12, 0, 360)
                    xx = xx + ex
                Next
            Next
        Catch ex As Exception

        End Try
    End Sub
    Private Sub dessinemoyenne(ByVal g As Graphics)
        Dim i As Integer, j As Integer, yy As Integer, v As Integer, m As Double
        Try
            'dessine moyenne
            For i = 1 To chartdata.GetLength(1) - 1
                v = 0
                For j = 0 To chartdata.GetLength(0) - 1
                    v = v + (chartdata(j, i) - vmin)
                Next
                m = (v / chartdata.GetLength(0)) * 100
                moy(i) = m / 100
                yy = Fond.Height - ((m / ey) * ny / 100) - mb
                Dim tp As New Pen(Color.AliceBlue, 2)
                tp.Color = PenCourbe(i).Color
                tp.DashStyle = DashStyle.Dash
                If ValeurMoyenne(i) = True Then g.DrawLine(tp, ml, yy, Fond.Width - (ml), yy)
                tp.Dispose()
            Next
        Catch ex As Exception

        End Try
    End Sub

    Private Sub graph_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim i As Integer
        Try
            Fond.Top = 0
            Fond.Left = 0
            Fond.Height = Me.Height
            Fond.Width = Me.Width
            For i = 0 To 2
                PenCourbe(i) = New Pen(Color.Red, 3)
            Next
            Me.SetStyle(Windows.Forms.ControlStyles.ResizeRedraw, True)
        Catch ex As Exception

        End Try
    End Sub
    Private Sub Panel1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Fond.MouseDown
        Try
            If zoom = False Then Exit Sub
            If e.Button = Windows.Forms.MouseButtons.Left Then
                If Fond.Width > 4000 Then Exit Sub
                Fond.Dock = Windows.Forms.DockStyle.None
                Fond.Left = -(Math.Abs(Fond.Left) + e.X)
                Fond.Width = Fond.Width * 2
                If Fond.Width <= Me.Width Then Fond.Left = 0

            End If
            If e.Button = Windows.Forms.MouseButtons.Right Then
                If Fond.Width = Me.Width Then Exit Sub
                Fond.Dock = Windows.Forms.DockStyle.None
                Fond.Left = -(Math.Abs(Fond.Left) - e.X / 2)
                Fond.Width = Fond.Width / 2
                If Fond.Width <= Me.Width Then
                    Fond.Left = 0
                    Fond.Width = Me.Width
                End If
            End If
        Catch ex As Exception

        End Try
    End Sub

    Private Sub graph_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        Try
            Fond.Top = 0
            Fond.Left = 0
            Fond.Height = Me.Height
            Fond.Width = Me.Width
            Me.Refresh()
        Catch ex As Exception

        End Try

    End Sub

End Class

Commentaire de Adn56 le 19/09/2007 11:25:48

sympa comme tout ! bravo, tres simple à utiliser et à comprendre.

Juste une info, peux tu expliquer ceci :
graph1.nbcourbe = 2 dans le load de la form bloque l'affichage des courbes -_-', de plus à quoi sers le graph1.nbelement ? je ne suis pas assez doué pour lire dans le code de la dll :(

merci et @+ pou du 9

Commentaire de xdjbobo le 04/10/2007 15:36:57 9/10

Salut,
bravo! un source trés utile. Merci pour la correction pour afficher les valeurs négatives.
il manque un petit truc qui pourait être sympas, c'est l'affichage des valeurs quand on passe la souris sur les points du graph.
je vais essayer de mon côté, mais si tu as une solution...

Commentaire de xdjbobo le 04/10/2007 16:24:00

voici une petite modif de ton code pour afficher les valeurs Y des points. pour l'instant ce n'est pas paramètrable, mais ça va venir! J'ai donc repris la procédure dessinecourbe:

Private Sub desscourbe(ByVal g As Graphics)
        Dim i As Integer, j As Integer, xx As Integer, yy As Integer, xx0 As Integer, yy0 As Integer, tx As Integer, tx0 As Integer
        Try
            For i = 1 To chartdata.GetLength(1) - 1
                xx = ml * 100 + ex / 2
                yy = (Fond.Height - mb) - ((chartdata(0, i) - vmin) / ey) * ny
                PenCourbe(i).LineJoin = LineJoin.Round
                For j = 1 To chartdata.GetLength(0) - 1
                    xx0 = (xx + ex)
                    yy0 = (Fond.Height - mb) - ((chartdata(j, i) - vmin) / ey) * ny
                    tx = xx / 100
                    tx0 = xx0 / 100
                    If CourbeVisible(i) = True And ovisible = True Then g.DrawLine(Penombre, tx + 7, yy + 7, tx0 + 7, yy0 + 7)
                    If CourbeVisible(i) = True Then

                        g.DrawLine(PenCourbe(i), tx, yy, tx0, yy0)
'zone de modif
'**
'affichage des valeurs y des point sur le graphique
                        g.DrawString(chartdata(j - 1, i), FontX, Brushes.Black, tx - 5, yy - 10)
                    End If
'pour ne pas oublier le dernier point
                    g.DrawString(chartdata(j, i), FontX, Brushes.Black, tx0 - 5, yy0 - 10)
'**
'fin de zone de modif
                    xx = xx0
                    yy = yy0
                Next
                xx = ml * 100 + ex / 2
                yy = (Fond.Height - mb) - ((chartdata(0, i) - vmin) / ey) * ny
                If pvisible = True Then
                    For j = 1 To chartdata.GetLength(0) - 1
                        xx0 = (xx + ex)
                        yy0 = (Fond.Height - mb) - ((chartdata(j, i) - vmin) / ey) * ny
                        tx = xx / 100
                        tx0 = xx0 / 100
                        Dim bo As Brush = Brushes.LightGray

                        If CourbeVisible(i) = True And ovisible = True Then g.FillPie(Penombre.Brush, tx - (PenCourbe(i).Width * 2) + 7, yy - (PenCourbe(i).Width * 2) + 7, PenCourbe(i).Width * 4, PenCourbe(i).Width * 4, 0, 360)
                        If CourbeVisible(i) = True Then g.FillPie(PenCourbe(i).Brush, tx - (PenCourbe(i).Width * 2), yy - (PenCourbe(i).Width * 2), PenCourbe(i).Width * 4, PenCourbe(i).Width * 4, 0, 360)
                        xx = xx0
                        yy = yy0
                    Next
                    tx = xx / 100
                    If CourbeVisible(i) = True And ovisible = True Then g.FillPie(Penombre.Brush, tx - (PenCourbe(i).Width * 2) + 7, yy - (PenCourbe(i).Width * 2) + 7, PenCourbe(i).Width * 4, PenCourbe(i).Width * 4, 0, 360)
                    If CourbeVisible(i) = True Then g.FillPie(PenCourbe(i).Brush, tx - (PenCourbe(i).Width * 2), yy - (PenCourbe(i).Width * 2), PenCourbe(i).Width * 4, PenCourbe(i).Width * 4, 0, 360)

                End If
            Next
        Catch ex As Exception

        End Try
    End Sub

Commentaire de teamtiti le 19/03/2008 19:06:01

salut a tous moi j'ai cette erreure la :

Type 'Graph.graph' introuvable. Assurez-vous que l'assembly qui contient ce type est référencé. Si ce type est un composant de votre projet de développement, assurez-vous que le projet a été créé comme il se doit.  


La variable 'Graph1' n'est pas déclarée ou n'a jamais été assignée.

et comment faut il faire pour changer les points via des NumericUpDown ?
Merci d'avance

Commentaire de Flyman81 le 27/05/2008 15:25:55

Le zip a t'il été mis à jour depuis les modifs postés en commentaire ou faut-il les inclure à la main ?

Merci pour l'info et bravo pour cette source ! :)

Commentaire de ptibuc le 03/09/2008 15:19:57 10/10

Superbe, magnifique, je dirais même presque magique !

Superbe source qui m'a énormément aidée, vraiment un grand merci !

10/10 sans hésiter (comme on ne peut pas mettre plus..)

Commentaire de souhailsou le 23/02/2009 11:49:32

bonjour, superbe code
j'ai intégré cette solution dans mon projet
donc g ajouté graph comme étant un composant dans mon formulaire
mais lorsque je veux afficher une courbe dans le graphe (l'échelle), j'arrive pas
puisque déjà cette commande ça marche pas en c#

Graph1.PenCourbe(2) = New Pen(Button4.BackColor, 3);

est ce quelqu'un a une idée de quoi il s'agit et merci pour vous.

Commentaire de souhailsou le 08/03/2009 22:33:02

bravo! une source très utile.
mais le problème est que, je peux pas ajouter une méthode qui dessine une ligne.
en faite mon but est dès que je clique sur le graph (Graph.graph)il m'affiche une ligne où g cliqué
donc je voudrais savoir qu'est ce que j'ajoute au niveau code et au niveau quel partie

s.v.p est ce quelqu'un a un idée comment procéder. si quelqu'un a le moindre idée de quoi il s'agit alors s.v.p aidez moi et merci d'avance.  

Commentaire de mfulgore le 03/04/2010 21:15:02

bravo! pour le code
je souhaite l'améliorer en faisant apparaitre une legende
est ce quel qu'un pourrait m'aider? merci

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

Eliminer un point d'une courbe (MSCHART) [ par Baddack ] Attention ce message s'adresse à un dieu du VB.Je dois afficher une courbe avec un MsChart.Jusque là rien de méchant.Puis si l'utilisateur trouve un MS Chart [ par briwax ] Salut tt le monde,je vous expose mon probl&#232;me rapidement : j'aimerais r&#233;aliser un graphique en courbe avec en entr&#233;e des coordonn&#233; ne pas afficher toutes la courbe d'un mschart [ par snake57 ] Bonjour,Je travail actuellement sur un graphique en VB6. Ce graphique est créer a l'aide de mschart. Les valeurs de ce graphiques sont des température mschart [ par S4ngo ] Bonsoir, J'ai r&#233;alis&#233; un graphique tir&#233; d'excel &#224; l'aide du MSCHART de vb6. Jai du cr&#233;er un&nbsp; bouton, &#224; l'aide du qu tracer de courbe graphique [ par luckyluke33 ] Bonjours à tous,J'aimerai un petit coup de main. Je cherche le moyen de tracer un graphique sous forme d'une courbe à l'aide de coordonnée de points q MS chart sur VB5 [ par rsbill ] Bonjour. Je fais du d&#233;veloppement sous VB5! J'aimerais utiliser le Contr&#244;le Mschart. Malheuresement lorsque je cherche la r&#233;f&#233;renc Graphique avec mschart ou autre?? [ par supertet ] Bonjour tout le monde,J'ai réalisé un programme qui après l'appui sur un bouton effectue la lecture de 2 variables x,y entre 2 bornes min et max.exemp Graphique a courbes [ par orditosh ] Bonjour, j'aimerais faire un graphique qui à 2 courbes : une "moyenne" et, une avec le résultat :la courbe de graphique "moyenne" se connectera à une OleObject et chart [ par elodie P ] bonjour à toussous VBA excel j'ai créé un graphique et j'aimerais y intégrer un bouton de commande. si on clique sur le bouton je voudrais faire appar graphique en VB [ par jarima ] J'ai un programme dans lequel je génère des calculs que je sauvegarde dans un tableau. Je voudrais récupérer les données du tableau pour tracer des co


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,374 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales