Chart container isolates the physical medium for chart output. Chart container is required to create an interactive chart. By providing different containers, chart can be rendered in AWT, Swing or a custom component hierarchy.
No chart container is required for static charts, such as charts, generated by servlets.
The main types of containers:
| Class | Description |
|---|---|
| JChartPanel | This container is used for Swing applications |
| ChartCanvas | This container is used for AWT applications |
Table 5.3.1 Containers
Using JChartPanel:
1 | //... chart creation code... //................................................... LabeledChart topChart = new LabeledChart(chart); // .. topChart settings //................................................... JChartPanel m_chartPanel = new JChartPanel(topChart); // .. m_chartPanel settings //................................................... // adding m_chartPanel to JFrame add(m_chartPanel); |
Using ChartCanvas:
1 | //... chart creation code... //................................................... LabeledChart topChart = new LabeledChart(chart); // .. topChart settings //................................................... ChartCanvas panel = new ChartCanvas(topChart); // .. panel settings //................................................... // adding panel to Frame add(panel); |