JFreeChart learning notes

zhaozj2021-02-16  106

JFreeChart learning notes

Author: Li Chun Kam Hangzhou University of Electronic Science and Technology

MSN: lichunjin@hotmail.com

The purpose of the research is to use JFreechar to develop a stock real-time trend chart of similar securities stars.

Specific address http://quote.stockstar.com/stock/external_quote.asp?code=shzs000001

At present, I have used Applet to implement similar functions, due to the limitations of applet

So further development, on this, the form of pictures should be used.

JFreechart

Hereinafter referred to as

Chart

,

One. Main application of Chart

In the drawing, including the Pie Charts, a Bar Charts, a Bar Charts, a Pie Chart, a graph, a time / value continuous map, including a Various Applet applet, and JSP / servlet on the Web program

two. CHART design

2.1 Chart uses a static factory model with a static factory model for a variety of charts.

2.2 Method for generating an example of a JFreeChart object: 1. Factory mode generates an instance of the needed drawing graphics, such as JFreechart Chart = ChartFactory.createtimeSerieschart ("Weekly Data", "Date", "Value", Dataset, True, True, False 2. 2. Direct New A Chart constructor jfreechart chart = new jfreechart (null, jfreechart.default_title_font, plot, true);

three. Time / value line continuous chart, the trend map for stock

3.1. How to place a series of data for time / value,

Chart uses the class XYSeriesCollection to place (x, y) data, corresponding objects are XYSERIES

Chart uses class TimeSeriesCollection to place data of time / value line, corresponding objects are TimeSeries

Visible XYSeriesCollection, TimeSeriesCollection Similar Collection Container Class

3.2.

Principle of stock map generation (one line)

Step 1: Generate an instance of the XYSeries object, add data to xyseries, and generate a parameter xyseriescollection

Step 2: Generate an instance of the StandardxyToolTipGenerator object, set the display format of the X-axis time

Step 3: Generate an instance of the StandardxyItemRenderer object, set the way the drawing graphics is a point-to-point painting,

Step 4: Generate an instance of the XYPLOT object, the data format is set to (x, y).

XYPLOT PLOT = New Xyplot (Data Collection, Time X axis, Value Y axis, method of drawing graphics);

The last step: No matter what graphics generated, an instance of the JFreechart object must be generated.

JFreeChart Chart = new jfreechart (title, font, plot, whether to generate a legend);

Servlet / JSP optional feature:

Generate a picture when requested, can be JPG and PNG format // Write the chart image to the temporary Directory

ChartRenderingInfo? Info = new? ChartrenderingInfo (New StandardentityCollection);

FileName = servletutilities.savechartaspng (Chart, 500, 300, Info, Session);

3.3. Limitations of trend diagrams applied to stocks

Since stock data is real-time, the line it exhibits is moving over time

However, Chart is currently only dynamically drawing the drawing according to the data read, and the timeline cannot be fixed.

This is a problem to be solved, this is also the purpose of this study, improvement!

3.4. Expected solution

Change the source code of the underlying Chart or new features

Four, go deep into Chart

4.1 Timed axis display:

Since the picture must be drawn as a reference line yesterday. So I painted the reference line until the end, so since

It can solve the problem of 3.3 for complete a day.

4.2 Data screening and display

Since the stock trading time is 9: 30-11: 30 ?? and 13: 00-15: 00. Therefore, on the one hand, it is necessary to remove the time axes.

On the other hand, the curve must be continuous and there is no overlap of data. I just started to filter out the time, but Chart is adjusted according to the number of time points of your data, so the time axis displayed is not very good. The presence of the stop time

(Specifically, the downtime: Timeline 9: 30, 15: 00 must be displayed, 11: 30 and 13:00 the same point, as long as one of the values)

I researched the Demo of Chart and found that segmenthighlowchartdemo.java demonstrated how to eliminate the time of rest day.

Related ChartAPI's Doc: SegmentTimeline sets the interval to exclude!

So the problem is solved

Five, summary

After learning and research, JFreeChart is really good in generating various data analysis pictures.

If your project uses such applications, you can learn! You can also talk about me,

Rough Chart works:

转载请注明原文地址:https://www.9cbs.com/read-10385.html

New Post(0)