Програмування. Java, PHP, JFreeChart, SEO, блог, бази даних, інформаційні технології, ІТ
seen from Germany

seen from Canada
seen from China
seen from United States
seen from United States

seen from Netherlands

seen from Spain
seen from New Zealand
seen from New Zealand

seen from United States

seen from Kazakhstan
seen from United States

seen from France

seen from United States
seen from Spain
seen from Germany
seen from Russia
seen from India
seen from China

seen from United States
Програмування. Java, PHP, JFreeChart, SEO, блог, бази даних, інформаційні технології, ІТ
Eine kleine Oracle Java Anwendung welche die Daten eines DHT11 Sensors in einem Diagramm anzeigt. #wemosd1mini #dht11 #oracle #java #jfreechart #maker #electronic #components #diy #tech #techy #technology #DraegerIT (hier: Stefan Draeger Software) https://www.instagram.com/p/B91xhaIo2CR/?igshid=1cenq6y9ql8qz
In this JFreeChart tutorial, we will go through JFreeChart download and 3 JFreeChart examples (JFreeChart pie chart, JFreeChart bar chart and JFreeChart timeseries chart).
JFreeChart Image Map Sample
Using JFreeChart to draw a chart is simple, but what if we want more. Besides getting an image, an image map is also available to make user interact and watch some summary information.
It is supported well in JFreeChart, and the point is setting url-generator, tooltip-generator and using ChartRenderingInfo object.
How to set url-generator and tooltip-generator?
JFreeChart object has a Plot object, Plot object can set a Renderer object. Renderer object can set url-generator and tooltip-generator, and they are all associated. Sample code is as follow:
final XYPlot plot = chart.getXYPlot(); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setURLGenerator(new StandardXYURLGenerator("URLSample")); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(renderer);
After we can get the Chart, you draw the chart using ChartUtilities or ServletUtilities, passing an new empty ChartRenderingInfo object in the draw chart method.
For example,
ServletUtilities.saveChartAsJPEG(chart, 640, 400, info, req.getSession());
Then the ChartRenderingInfo object has the map information in it.
Finally, you can use
String tooltip = ChartUtilities.getImageMap("tooltip", info);
to get the map String object.
And your chart can show tooltip and URL for interaction.
Using JFreeChart with Seam
Graphic statistics in Seam with JFreeChart. [code lang="java"] package example.chartprocesser; @Name("chartprocesser") public class ChartProcesserBean { @In EntityManager em; // Entity Manager to access the database byte[] chart; // chart image (.png) as a byte array @Factory(value="chart") public void createChart() { DefaultCategoryDataset ds = this.getData; JFreeChart chart = ChartFactory.createLineChart( "TITLE", "Category Label", "Axis Lable", ds, PlotOrientation.HORIZONTAL, false, false, false ); try{ this.chart = ChartUtilities.encodeAsPNG(chart.createBufferedImage(400, 400)); } catch (IOException e){ e.printStackTrace(); } } private DefaultCategoryDataset getData(){ //get the data and put into DefaultCategoryDataset //Then return it. } } [/code] In your JSF page: [code lang="xml"] [/code]