Object Refinery The JFreeChart Class Library Developer Guide.v1.0.pdf

(6670 KB) Pobierz
15268566 UNPDF
TheJFreeChartClassLibrary
Version1.0.9
DeveloperGuide
WrittenbyDavidGilbert
January7,2008
c2000-2008,ObjectRefineryLimited.Allrightsreserved.
IMPORTANTNOTICE:
Weworkhardtomakethisdocumentasaccurateandinformativeaswecan,but
cannotguaranteethatitiserror-free.
Contents
1Introduction 16
1.1WhatisJFreeChart? .................................... 16
1.2ThisDocument ....................................... 18
1.3Acknowledgements ..................................... 18
1.4CommentsandSuggestions ................................ 18
2SampleCharts 19
2.1Introduction ......................................... 19
2.2PieCharts .......................................... 19
2.3BarCharts ......................................... 21
2.4LineChart ......................................... 23
2.5XYPlots .......................................... 24
2.6TimeSeriesCharts ..................................... 25
2.7Histograms ......................................... 26
2.8AreaCharts ......................................... 27
2.9DierenceChart ...................................... 27
2.10StepChart ......................................... 29
2.11GanttChart ......................................... 30
2.12MultipleAxisCharts .................................... 31
2.13CombinedandOverlaidCharts .............................. 32
2.14FutureDevelopment .................................... 33
3DownloadingandInstallingJFreeChart 34
3.1Introduction ......................................... 34
3.2Download .......................................... 34
3.3UnpackingtheFiles .................................... 34
3.4RunningtheDemonstrationApplications ........................ 35
3.5ConfiguringJFreeChartforuseinIDEs ......................... 36
3.6CompilingtheSource ................................... 36
3.7GeneratingtheJavadocDocumentation ......................... 36
4UsingJFreeChart 37
4.1Overview .......................................... 37
4.2CreatingYourFirstChart ................................. 37
5PieCharts 40
5.1Introduction ......................................... 40
5.2CreatingaSimplePieChart ................................ 40
5.3SectionColours ....................................... 40
5.4SectionOutlines ...................................... 41
5.5Null,ZeroandNegativeValues .............................. 41
5.6SectionandLegendLabels ................................. 42
5.7ExplodedSections ..................................... 42
1
CONTENTS
2
5.83DPieCharts ........................................ 43
5.9MultiplePieCharts .................................... 43
6BarCharts 45
6.1Introduction ......................................... 45
6.2ABarChart ........................................ 45
6.3TheChartFactoryClass .................................. 48
6.4SimpleChartCustomisation ................................ 48
6.5CustomisingtheRenderer ................................. 49
7LineCharts 51
7.1Introduction ......................................... 51
7.2ALineChartBasedOnACategoryDataset ...................... 51
7.3ALineChartBasedOnAnXYDataset ......................... 56
8TimeSeriesCharts 61
8.1Introduction ......................................... 61
8.2TimeSeriesCharts ..................................... 61
9CustomisingCharts 67
9.1Introduction ......................................... 67
9.2ChartAttributes ...................................... 67
9.3PlotAttributes ....................................... 69
9.4AxisAttributes ....................................... 70
10DynamicCharts 72
10.1Overview .......................................... 72
10.2Background ......................................... 72
10.3TheDemoApplication ................................... 73
11Tooltips 77
11.1Overview .......................................... 77
11.2GeneratingToolTips .................................... 77
11.3CollectingToolTips .................................... 78
11.4DisplayingToolTips .................................... 78
11.5DisablingToolTips .................................... 78
11.6CustomisingToolTips ................................... 78
12ItemLabels 79
12.1Introduction ......................................... 79
12.2DisplayingItemLabels ................................... 80
12.3ItemLabelAppearance .................................. 81
12.4ItemLabelPositioning ................................... 82
12.5CustomisingtheItemLabelText ............................. 83
12.6Example1-ValuesAboveaThreshold .......................... 84
12.7Example2-DisplayingPercentages ........................... 87
13MultipleAxesandDatasets 91
13.1Introduction ......................................... 91
13.2AnExample ......................................... 91
13.3HintsandTips ....................................... 93
CONTENTS
3
14CombinedCharts 94
14.1Introduction ......................................... 94
14.2CombinedDomainCategoryPlot ............................. 94
14.3CombinedRangeCategoryPlot .............................. 95
14.4CombinedDomainXYPlot ................................ 96
14.5CombinedRangeXYPlot ................................. 97
15DatasetsandJDBC 99
15.1Introduction ......................................... 99
15.2AboutJDBC ........................................ 99
15.3SampleData ........................................ 99
15.4PostgreSQL .........................................100
15.5TheJDBCDriver .....................................101
15.6TheDemoApplications ..................................102
16ExportingChartstoAcrobatPDF 103
16.1Introduction .........................................103
16.2WhatisAcrobatPDF? ..................................103
16.3iText .............................................103
16.4Graphics2D .........................................103
16.5GettingStarted .......................................104
16.6TheApplication ......................................104
16.7ViewingthePDFFile ...................................108
16.8UnicodeCharacters .....................................108
17ExportingChartstoSVGFormat 111
17.1Introduction .........................................111
17.2Background .........................................111
17.3ASampleApplication ...................................111
18Applets 114
18.1Introduction .........................................114
18.2Issues ............................................114
18.3ASampleApplet ......................................115
19Servlets 118
19.1Introduction .........................................118
19.2ASimpleServlet ......................................118
19.3CompilingtheServlet ...................................120
19.4DeployingtheServlet ...................................121
19.5EmbeddingChartsinHTMLPages ............................121
19.6SupportingFiles ......................................126
19.7DeployingServlets .....................................127
20Miscellaneous 129
20.1Introduction .........................................129
20.2X11/HeadlessJava ....................................129
20.3JavaServerPages ......................................129
20.4LoadingImages .......................................129
21Packages 130
21.1Overview ..........................................130
CONTENTS
4
22Package:org.jfree.chart 131
22.1Overview ..........................................131
22.2ChartColor .........................................131
22.3ChartFactory ........................................131
22.4ChartFrame .........................................134
22.5ChartMouseEvent .....................................135
22.6ChartMouseListener ....................................136
22.7ChartPanel .........................................136
22.8ChartRenderingInfo ....................................141
22.9ChartUtilities ........................................142
22.10ClipPath ...........................................144
22.11DrawableLegendItem ....................................144
22.12Eect3D ...........................................144
22.13HashUtilities ........................................145
22.14JFreeChart .........................................145
22.15LegendItem .........................................150
22.16LegendItemCollection ...................................152
22.17LegendItemSource .....................................153
22.18LegendRenderingOrder ...................................154
22.19PolarChartPanel ......................................154
23Package:org.jfree.chart.annotations 155
23.1Overview ..........................................155
23.2AbstractXYAnnotation ..................................155
23.3CategoryAnnotation ....................................157
23.4CategoryLineAnnotation ..................................157
23.5CategoryPointerAnnotation ................................159
23.6CategoryTextAnnotation ..................................161
23.7TextAnnotation .......................................162
23.8XYAnnotation .......................................164
23.9XYBoxAnnotation .....................................165
23.10XYDrawableAnnotation ..................................166
23.11XYImageAnnotation ....................................167
23.12XYLineAnnotation .....................................168
23.13XYPointerAnnotation ...................................169
23.14XYPolygonAnnotation ...................................171
23.15XYShapeAnnotation ....................................173
23.16XYTextAnnotation .....................................174
24Package:org.jfree.chart.axis 177
24.1Overview ..........................................177
24.2Axis .............................................177
24.3AxisCollection .......................................182
24.4AxisLocation ........................................182
24.5AxisSpace ..........................................183
24.6AxisState ..........................................183
24.7CategoryAnchor ......................................184
24.8CategoryAxis ........................................184
24.9CategoryAxis3D ......................................189
24.10CategoryLabelPosition ...................................190
24.11CategoryLabelPositions ..................................191
24.12CategoryLabelWidthType .................................191
24.13CategoryTick ........................................192
24.14ColorBar ..........................................192
24.15CompassFormat .......................................192
Zgłoś jeśli naruszono regulamin