IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Bibliothèques et frameworks PHP Discussion :

[ImageGraph] Affichage de légende


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Membre averti
    Inscrit en
    Janvier 2004
    Messages
    533
    Détails du profil
    Informations forums :
    Inscription : Janvier 2004
    Messages : 533
    Points : 313
    Points
    313
    Par défaut [ImageGraph] Affichage de légende et position de graph
    Bonjour,

    J'utilise la bibliothèque Image_Graph et j'essaie de réaliser un graphique camembert comme celui-ci.

    Voici mon code actuel :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    <?php
    /**
     * Usage example for Image_Graph.
     * 
     * Main purpose: 
     * Demonstrate radial gradient fillings
     * 
     * Other: 
     * None specific
     * 
     * $Id: misc03.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
     * 
     * @package Image_Graph
     * @author Jesper Veggerby <pear.nosey@veggerby.dk>
     */
     
    require_once 'Image/Graph.php';
     
    // create the graph
    $Graph =& Image_Graph::factory('graph', array(400, 300));
     
    // add a TrueType font
    $Font =& $Graph->addNew('font', 'Verdana');
    // set the font size to 7 pixels
    $Font->setSize(7);
     
    $Graph->setFont($Font);
     
    // create the plotarea
    $Graph->add(
        Image_Graph::vertical(
            Image_Graph::factory('title', array('Structure par type de fonds', 12)),
            Image_Graph::horizontal(
                $Plotarea = Image_Graph::factory('plotarea'),
                $Legend = Image_Graph::factory('legend'),
                70
            ),
            5           
        )
    );
     
    $Legend->setPlotarea($Plotarea);
     
    // create the 1st dataset
    $Dataset1 =& Image_Graph::factory('dataset');
    $Dataset1->addPoint('Item 1', 905);
    $Dataset1->addPoint('Item 2', 95);
    $Dataset1->addPoint('Item 3', 15);
    /*$Dataset1->addPoint('Poultry', rand(1, 10));
    $Dataset1->addPoint('Camels', rand(1, 10));
    $Dataset1->addPoint('Other', rand(1, 10));*/
    // create the 1st plot as smoothed area chart using the 1st dataset
    $Plot =& $Plotarea->addNew('pie', array(&$Dataset1));
    $Plotarea->hideAxis();
     
    // create a Y data value marker
    $Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_PCT_Y_TOTAL);
    // create a pin-point marker type
    $PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(-40, &$Marker));
    // and use the marker on the 1st plot
    $Plot->setMarker($PointingMarker);    
    // format value marker labels as percentage values
    $Marker->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.1f%%'));
     
    $Plot->Radius = 2;
     
    $FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
    $Plot->setFillStyle($FillArray);
    /*$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'green'));
    $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'blue'));
    $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'yellow'));
    $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'red'));
    $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'orange'));*/
    $FillArray->addColor('blue@0.3', 'Color1');
    $FillArray->addColor('orange@0.6', 'Color2');
    $FillArray->addColor('green@0.6', 'Color3'); 
    $FillArray->addColor('yellow@0.6', 'Color4'); 
    $FillArray->addColor('black@0.6', 'Color5'); 
    $FillArray->addColor('ref@0.6', 'Color6'); 
     
    //$Plot->explode(5);
     
    $PointingMarker->setLineColor(false);
    $Marker->setBorderColor(false);
    $Marker->setFillColor(false);
     
    // output the Graph
    $Graph->done();
    ?>
    Mon problème est que la légende de droite n'apparaît pas (celle avec les couleurs et leurs significations).

    Quelqu'un pourrait-il m'aider ?
    Merci d'avance !
    @+
    N'oubliez pas le tag .
    Merci de ne pas envoyer de MP pour des problèmes techniques.

  2. #2
    Membre averti
    Inscrit en
    Janvier 2004
    Messages
    533
    Détails du profil
    Informations forums :
    Inscription : Janvier 2004
    Messages : 533
    Points : 313
    Points
    313
    Par défaut
    J'ai un peu avancé et voici le nouveau code actuel :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    <?php
    require_once 'Image/Graph.php';
     
     
    				// paramètres du graphique
    				$Canvas =& Image_Canvas::factory('png', array('width' => 400, 'height' => 300));      
    				$Graph =& Image_Graph::factory('graph', $Canvas); 
     
    				// définition du diagramme
    				$Plotarea =& $Graph->addNew('plotarea'); 
     
    				// définition des polices
    				$Font =& $Graph->addNew('ttf_font', 'Verdana');
    				$Font->setSize(7);
    				$Graph->setFont($Font);
     
    				// Titre du graphique
    				$Legend =& $Plotarea->addNew('legend');
    				//$Legend->setPlotarea($Plotarea);
    				$Legend->setAlignment(IMAGE_GRAPH_ALIGN_TOP);
    				//$titre = Image_Graph::factory('title', array("test", 11));
    				//$Graph->add($titre);
     
    // create the 1st dataset
    $Dataset1 =& Image_Graph::factory('dataset');
    $Dataset1->addPoint('Very Long Item 1', 905);
    $Dataset1->addPoint('Item 2', 85);
    $Dataset1->addPoint('Item 3', 15);
    $Dataset1->addPoint('Item 4', 10);
    /*$Dataset1->addPoint('Poultry', rand(1, 10));
    $Dataset1->addPoint('Camels', rand(1, 10));
    $Dataset1->addPoint('Other', rand(1, 10));*/
    // create the 1st plot as smoothed area chart using the 1st dataset
    $Plot =& $Plotarea->addNew('pie', array(&$Dataset1));
    $Plotarea->hideAxis();
     
    // create a Y data value marker
    $Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_PCT_Y_TOTAL);
    // create a pin-point marker type
    $PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(-40, &$Marker));
    // and use the marker on the 1st plot
    $Plot->setMarker($PointingMarker);    
    // format value marker labels as percentage values
    $Marker->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.1f%%'));
     
    $Plot->Radius = 2;
     
    $FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
    $Plot->setFillStyle($FillArray);
    /*$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'green'));
    $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'blue'));
    $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'yellow'));
    $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'red'));
    $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'orange'));*/
    $FillArray->addColor('blue@0.3', 'Color1');
    $FillArray->addColor('orange@0.6', 'Color2');
    $FillArray->addColor('green@0.6', 'Color3'); 
    $FillArray->addColor('yellow@0.6', 'Color4'); 
    //$FillArray->addColor('black@0.6', 'Color5'); 
    //$FillArray->addColor('ref@0.6', 'Color6'); 
     
    //$Plot->explode(5);
     
    $PointingMarker->setLineColor(false);
    $Marker->setBorderColor(false);
    $Marker->setFillColor(false);
     
    // output the Graph
    $Graph->done();
    ?>
    Or, j'aimerais que le graphique soit aligné à gauche et que la légende ne possède pas de cadre... Comment faire ?
    N'oubliez pas le tag .
    Merci de ne pas envoyer de MP pour des problèmes techniques.

  3. #3
    Membre averti
    Inscrit en
    Janvier 2004
    Messages
    533
    Détails du profil
    Informations forums :
    Inscription : Janvier 2004
    Messages : 533
    Points : 313
    Points
    313
    Par défaut
    J'ai trouvé comment enlever la bordure de la légende :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $Legend->setLineColor('');

    Il ne me reste plus qu'à positionner le graphique (camembert) en bas à gauche de l'image...
    Auriez-vous une idée svp ?
    N'oubliez pas le tag .
    Merci de ne pas envoyer de MP pour des problèmes techniques.

Discussions similaires

  1. Modifier l' affichage des légendes
    Par Gildas86 dans le forum Tableaux - Graphiques - Images - Flottants
    Réponses: 2
    Dernier message: 01/02/2012, 15h24
  2. [CR 2008] Bug d'affichage de légende
    Par hokidoki dans le forum SAP Crystal Reports
    Réponses: 2
    Dernier message: 28/03/2011, 16h00
  3. Problème d'affichage de légende
    Par nelfiti dans le forum Interfaces Graphiques
    Réponses: 3
    Dernier message: 27/05/2008, 21h16
  4. Affichage légende
    Par Ella68 dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 19/03/2008, 11h02
  5. Affichage des zéros d'une date dans une légende
    Par grutfruh dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 04/08/2007, 11h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo