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

Servlets/JSP Java Discussion :

image du graphique non visible


Sujet :

Servlets/JSP Java

  1. #1
    Membre averti Avatar de mouss4rs
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    884
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 884
    Points : 355
    Points
    355
    Par défaut image du graphique non visible
    Bonsoir,

    Voila, j'essaye de créer un histogramme en appelant ma jsp.
    Seulement, la photo de mon graphique n'y ai pas donc remplacer par la croix pour dire que le chemin n'ai pas bon.
    quand je deplace ma souris sur la photo, je constate que il ya les tooltips pour designer les barres qui apparaissent malgré que la photo n'est pas la.

    je suis sur que le graphique est construit mais je ne sais pas pkoi cela ne veut pas me l'afficher.
    Voici ma jsp:
    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
     
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <%@ page import = "Controlleur.Graph" %>
    <%@ page import = "java.io.PrintWriter" %>
    <%@ page import = "java.text.SimpleDateFormat" %>
    <%@ page import = "java.text.ParseException" %>
    <%@ page import = "java.util.ArrayList" %>
    <%@ page import = "java.util.Date" %>
    <%@ page import = "java.util.Iterator" %>
    <%@ page import = "java.util.Locale" %>
    <%
    Controlleur.Graph graf = new Graph();
    String filename = graf.generateBarChart(session, new PrintWriter(out));
            String graphURL = request.getContextPath()+"/*.gestcli?filename=" + filename;
    %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Suivi des produits fabriqués</title>
    </head>
    <body>
    hello <%= graphURL %><br>
    <%= filename %><br>
    <img src="<%= graphURL %>" width=500 height=300 border=0 usemap="#<%= filename %>">
    <h1>
     
    </h1>
     
    </body>
    </html>
    et voici ma classe qui s'occupe de construire le graphique:

    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
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
     
     
    package Controlleur;
     
    import java.io.PrintWriter;
    import java.text.SimpleDateFormat;
    import java.util.Locale;
     
    import javax.servlet.http.HttpSession;
     
    import org.jfree.chart.ChartRenderingInfo;
    import org.jfree.chart.ChartUtilities;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.axis.CategoryAxis;
    import org.jfree.chart.axis.NumberAxis;
    import org.jfree.chart.axis.ValueAxis;
    import org.jfree.chart.entity.StandardEntityCollection;
    import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
    import org.jfree.chart.plot.CategoryPlot;
    import org.jfree.chart.plot.Plot;
    import org.jfree.chart.renderer.category.BarRenderer;
    import org.jfree.chart.servlet.ServletUtilities;
    import org.jfree.data.category.DefaultCategoryDataset;
     
    import Modele.Produit;
    import Modele.ProduitFabriquer;
    import Outil.ADO;
     
    import com.db4o.foundation.NotSupportedException;
     
     
    public class Graph {
    	private ADO ado = new ADO();
    	static final int WIDTH = 450;
    	static final int HEIGHT = 320;
     
     
    	public String generateBarChart(HttpSession session, PrintWriter pw) {
    		String filename = null;
     
    		try {
     
    			String series1 = "";
    			String series2 = "";
    			String series3= "";
    				// column keys...
    				String category1 = "Produit Fabriqué";
    				// create the dataset...
    		        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
     
     
    		        ado.connexion();
    				for(Produit instance : ado.listefab()){
    					for(int i=1; i<ado.listefab().size(); i++){
    						// row keys...
    						if(i==1){
    						series1 = instance.getCode();
    						dataset.addValue(instance.getStock(), series1, category1);
    						}else if(i==2){
    				        series2 = instance.getCode();
    				        dataset.addValue(instance.getStock(), series2, category1);
    						}else if(i==3){
    							series3 = instance.getCode();
    							dataset.addValue(instance.getStock(), series3, category1);
    						}
     
    					}
    				}
    				ado.deconnexion();
     
    			//  Create the chart object
    			CategoryAxis categoryAxis = new CategoryAxis("");
    			ValueAxis valueAxis = new NumberAxis("");
    			BarRenderer renderer = new BarRenderer();
    			//renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator("xy_chart.jsp","series","section"));
                renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
     
    			Plot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    			JFreeChart chart = new JFreeChart("Quantité de produit en stock", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    			chart.setBackgroundPaint(java.awt.Color.blue);
     
    			//  Write the chart image to the temporary directory
    			ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    			filename = ServletUtilities.saveChartAsPNG(chart, 800, 500, info, session);
     
    			//  Write the image map to the PrintWriter
    			ChartUtilities.writeImageMap(pw, filename, info, false);
    			pw.flush();
     
    		} catch (NotSupportedException e) {
    			System.out.println(e.toString());
    			filename = "public_nodata_500x300.png";
    		} catch (Exception ex) {
    			System.out.println("Exception - " + ex.toString());
    			ex.printStackTrace(System.out);
    			filename = "public_error_500x300.png";
    		}
    		return filename;
     
    	}
    	public static void main(String[] args) {
    		try {
    			Graph graf = new Graph();
    			SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", Locale.UK);
    			PrintWriter pw = new PrintWriter(System.out);
    			String filename = graf.generateBarChart( null, pw);
    //			String filename = WebHitChart.generatePieChart(sdf.parse("01-Aug-2002"), null, pw);
    //			String filename = WebHitChart.generateXYChart("service", null, pw);
    			System.out.println("filename - " + filename);
     
    		} catch (Exception e) {
    			System.out.println("Exception - " + e.toString());
    			e.printStackTrace();
    		}
    		return;
    	}
     
    }
    Si quelqu'un peu m'aider merci.

    n.b: je pense que c'est une question d'appel d'image a partir de la jsp

    merci

  2. #2
    Futur Membre du Club
    Inscrit en
    Avril 2008
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 4
    Points : 5
    Points
    5
    Par défaut lien hypertexte + servlet
    slt tout le monde
    j'ai une page jsp qui contient plusieurs liens hypertextes vers la meme servlet
    je veux recuperer le nom du lien qui ma amener vers cette servlet .
    MERCE.......

  3. #3
    Membre averti Avatar de mouss4rs
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    884
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 884
    Points : 355
    Points
    355
    Par défaut
    salut,
    t'est sur mon poste là.

  4. #4
    Membre averti Avatar de mouss4rs
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    884
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 884
    Points : 355
    Points
    355
    Par défaut
    reponse: rajouté la servlet DisplayChart de la librairie JfreeChart et modifie en consequence le web.xml

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Image du corps HTML mail non visible
    Par drumtof dans le forum Balisage (X)HTML et validation W3C
    Réponses: 8
    Dernier message: 07/09/2009, 14h38
  2. Image non visible dans Infopath
    Par billout rm dans le forum InfoPath
    Réponses: 0
    Dernier message: 15/11/2007, 10h30
  3. Réponses: 1
    Dernier message: 03/10/2007, 13h24
  4. [image]Image non visible !
    Par nimois3O dans le forum Word
    Réponses: 9
    Dernier message: 24/06/2007, 14h42
  5. image non visible
    Par christi dans le forum ASP.NET
    Réponses: 16
    Dernier message: 14/02/2007, 10h37

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