Remarque: Il est également possible d'utiliser la version 5.0 du JDK. Cependant, vous devez ensuite supprimer @Override de chaque méthode de la bibliothèque qui remplace une méthode d'interface. Cela est dû à la modification du comportement de l'annotation @Override dans la version 6.0 du JDK.
Dépendances
La bibliothèque Java de la source de données contient les dépendances suivantes. La bibliothèque a été testée avec les versions répertoriées. D'autres versions peuvent être acceptables, mais elles n'ont pas été testées.
javacc version 4.2.
Cela n'est nécessaire que si vous avez l'intention de compiler les bibliothèques, par exemple lorsque vous les modifiez comme décrit ci-dessous.
opencsv version
1.8. Cette étape n'est requise que si vous prévoyez d'utiliser une source de données CSV.
Non inclus dans la source ou le téléchargement:
Pour utiliser la classe SqlDataSourceHelper avec une base de données MySQL, vous avez également besoin de mysql.jar dans votre environnement d'exécution. Pour en savoir plus et connaître les versions téléchargeables, consultez la page http://www.mysql.com/products/connector/j/.
Utiliser la bibliothèque telle qu'elle est fournie
Cette section explique comment utiliser la bibliothèque Java de visualisation si vous n'avez pas besoin de la modifier. Ce processus varie selon votre système de compilation:
Si vous utilisez Maven, configurez une dépendance à la bibliothèque de visualisation avec les paramètres suivants:
ID du groupe: com.google.visualization
ID de l'artefact: Visualization-datasource
Numéro de version: utilisez le dernier numéro de version indiqué sur la page du projet.
Si vous utilisez un autre système de compilation:
Téléchargez le fichier ZIP de la bibliothèque à partir de la page du projet, décompressez les fichiers et incluez-les dans votre projet selon les besoins de votre système de compilation.
Exécuter les exemples
Les fichiers d'exemple JAR sont inclus avec les fichiers JAR de la bibliothèque dans le fichier ZIP téléchargeable. Les instructions relatives à l'exécution des exemples sont fournies sur la page Premiers pas.
Modifier la bibliothèque
Si vous souhaitez modifier le code de la bibliothèque, vous devez télécharger le code source depuis le site d'hébergement Open Source et le compiler. Avant cela, consultez les informations de licence indiquées dans la section "Licence de code" de la page du projet pour savoir si votre cas d'utilisation est autorisé.
Voici les étapes à suivre pour télécharger et créer la bibliothèque:
Téléchargez le code source à l'aide de SVN, comme décrit dans l'onglet Source > Règlement de la page du projet Open Source.
Compilez votre code. Si vous compilez votre projet au format Maven, utilisez le fichier pom.xml fourni avec la source. Si vous effectuez la compilation avec Apache Ant, suivez les instructions ci-dessous. Notez que le code a été testé avec Ant version 1.7.0. Si vous disposez d'une version antérieure d'Ant, vous devrez peut-être effectuer une mise à niveau.
Instructions de fabrication avec fourmi
1. Modifiez les propriétés de compilation:
Accédez au sous-répertoire build-src du répertoire d'installation de votre choix.
À l'aide d'un éditeur de texte, ouvrez le fichier build.properties et apportez les modifications suivantes :
Modifiez la propriété servlet-api.jar pour qu'elle pointe vers votre fichier servlet-api.jar.
Par exemple, si vous avez installé Tomcat sur votre disque c: dans le répertoire tomcat_home, vous devez spécifier la propriété servlet-api.jar comme suit: servlet-api.jar=C:/tomcat_home/common/lib/servlet-api.jar
Remarque: Utilisez des barres obliques plutôt que des barres obliques inverses dans le chemin du fichier, même si vous utilisez Windows
Pour utiliser vos propres copies des dépendances décrites ci-dessus, modifiez les chemins d'accès dans le même fichier build.properties.
2. Créez la bibliothèque:
Accédez au sous-répertoire build-src du fichier et saisissez l'un des éléments suivants:
ant datasource : crée la bibliothèque de sources de données
ant example : crée les exemples
ant : crée une source de données et des exemples
ant test : crée et exécute les tests de la bibliothèque de sources de données.
Très utile lorsque vous modifiez la bibliothèque.
Contribuer au projet Open Source
Si vous souhaitez apporter des modifications au projet Open Source, vous devez obtenir des autorisations d'envoi pour ce projet. Envoyez un e-mail à google-visualization-api@googlegroups.com pour demander votre autorisation et obtenir des instructions sur la manière d'envoyer des modifications.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2024/07/10 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2024/07/10 (UTC)."],[[["\u003cp\u003eThis documentation guides you on utilizing and extending the Google Visualization Java library for incorporating interactive charts into your applications.\u003c/p\u003e\n"],["\u003cp\u003eIt outlines prerequisites, dependencies, and steps for utilizing the library directly or modifying it to suit your specific needs.\u003c/p\u003e\n"],["\u003cp\u003eInstructions are provided for building the library from source and running included examples for a hands-on understanding.\u003c/p\u003e\n"],["\u003cp\u003eFor those interested in contributing to the project, guidance is offered on seeking permissions and submitting changes to the open-source codebase.\u003c/p\u003e\n"]]],[],null,["# Installing the Data Source Java Library\n\nThis page describes how to use or modify the Google Visualization Java library,\nand how to contribute to the open source code for the project.\n\nContents\n--------\n\n1. [Requirements](#requirements)\n2. [Dependencies](#dependencies)\n3. [Using the Library as Provided](#usingthelibrary)\n4. [Running the Examples](#buildingexamples)\n5. [Modifying the Library](#build_self)\n6. [Contributing to the Open Source Project](#contributing)\n\nRequirements\n------------\n\nYou must have the following components in order to use the Google Visualization\nJava library:\n\n- A servlet container and the Servlet API version 2.4 or higher. One of the most commonly used servlet containers is Apache Tomcat, which includes the Servlet API. See \u003chttp://tomcat.apache.org/download-55.cgi\u003e to download the binary for version 5.5. You need install only the Core module. You also need Tomcat to complete the tutorial sections: [Getting\n Started](/chart/interactive/docs/dev/dsl_get_started), [Using an External Data Store](/chart/interactive/docs/dev/dsl_csv), and [Defining\n Capabilities and the Flow of Events](/chart/interactive/docs/dev/dsl_httpservlet).\n- The [Java Development Kit](http://java.sun.com/) version 6.0 or greater.\n\n **Note** : It is also possible to use the JDK\n version 5.0. However, you must then remove `@Override` from\n every method in the library that overrides an interface method. This is\n due to the change in the `@Override` annotation behavior in\n JDK version 6.0.\n\nDependencies\n------------\n\nThe data source Java library has the following dependencies. The library was\ntested with the versions listed; other versions might be acceptable, but have not\nbeen tested.\n\n**Included in the source or download:**\n\n- [icu4j](http://site.icu-project.org/) version 4.0.1.\n- [Jakarta commons lang](http://commons.apache.org/lang/) version 2.4.\n- [Jakarta commons logging](http://commons.apache.org/logging/) version 1.1.1.\n- [Google collections\n library](http://code.google.com/p/google-collections/) version 1.0.\n- [*javacc*](https://javacc.dev.java.net/) version 4.2. This is required only if you intend to compile the libraries, for example when modifying them as described [below](#build_self).\n- [*opencsv*](http://opencsv.sourceforge.net/) version 1.8. This is required only if you intend to use a CSV data source.\n\n**Not included in the source or download:**\n\n- To use the `SqlDataSourceHelper` class with a mySQL database, you also need `mysql.jar` in your runtime environment. See: \u003chttp://www.mysql.com/products/connector/j/\u003e for details and downloadable versions.\n\nUsing the Library as Provided\n-----------------------------\n\nThis section describes how to use the visualization Java library if you don't\nneed to modify it. This process varies with your build system:\n\n**If using [Maven](http://maven.apache.org/index.html),** set\nup a dependency on the visualization library with the following settings:\n\n- Group ID: com.google.visualization\n- Artifact ID: visualization-datasource\n- Version number: Use the latest version number listed on the [project\n page](http://code.google.com/p/google-visualization-java/).\n\n**If using any other build system**:\n\n- [Download\n the library ZIP file](http://code.google.com/p/google-visualization-java/) from the project page, unzip the files, and include them in your project as your build system requires.\n\nRunning the Examples\n--------------------\n\nThe JAR example files are included along with the library JARs in the [downloadable\nZIP file](http://code.google.com/p/google-visualization-java/). Instructions on running the examples are given on the [Getting\nStarted](/chart/interactive/docs/dev/dsl_get_started) page.\n\nModifying the Library\n---------------------\n\nIf you want to modify the library code, you'll have to download the source from\nthe open source hosting site and build it. Before doing this, read the licensing\ninformation linked to by the \"Code license\" section on the [project\npage](http://code.google.com/p/google-visualization-java/) to see whether your use case is allowed.\n\nHere are the steps for downloading and building the library:\n\n1. **Download the source code** using SVN, as described in on the **Source \\\u003e Checkout** tab on the [open\n source project page](http://code.google.com/p/google-visualization-java/source/checkout).\n2. **Build your code.** If building in Maven, use the pom.xml file provided with the source. If building with [Apache\n Ant](http://ant.apache.org/), follow the instructions given next (note that the code has been tested with Ant version 1.7.0; if you have an earlier version of Ant, you might need to upgrade)\n\n### Ant Build Instructions\n\n**1. Modify your build properties:**\n\n1. Navigate to the `build-src` subdirectory of your chosen installation directory.\n2. Using a text editor, open the `build.properties` file and make the following changes:\n - Edit the `servlet-api.jar` property to point to your `servlet-api.jar` file. For example, if you installed Tomcat to your `c:` drive in the `tomcat_home` directory, then you would specify the `servlet-api.jar` property as follows: \n `servlet-api.jar=C:/tomcat_home/common/lib/servlet-api.jar`\n\n **Note**: Use forward slashes rather than\n backslashes in the file path, even when using Windows\n - To use your own copies of the dependencies described above, edit the paths in the same build.properties file.\n\n**2. Build the library:**\n\nNavigate the `build-src` subdirectory in the file and type one of the\nfollowing:\n\n- `ant datasource` - Builds the data source library\n- `ant example` - Builds the examples\n- `ant` - Builds both data source and examples\n- `ant test` - Builds and runs the data source library tests. Very useful when you are modifying the library.\n\nContributing to the Open Source\nProject\n---------------------------------------\n\nIf you want to contribute changes to the open source project, you'll have to get\nsubmission permissions to the project. Send an email to [google-visualization-api@googlegroups.com](mailto:google-visualization-api@googlegroups.com) asking\nfor permission and instructions on how to submit changes."]]