Polygons are used to display information in Area Charts. There are three different types:
Normal
[Java]
// Create a PDF Document
Document document = new Document();
// Create a Page and add it to the document
Page page = new Page();
document.getPages().add(page);
// Create a chart
Chart chart = new Chart(0, 0, 400, 230);
// Create a plot area
PlotArea plotArea = chart.getPrimaryPlotArea();
// Create header titles and add it to the chart
Title title1 = new Title("Website Visitors");
Title title2 = new Title("Year - 2007");
chart.getHeaderTitles().add(title1);
chart.getHeaderTitles().add(title2);
AutoGradient myAutogradient1 = new AutoGradient(90.0f, CmykColor.getRed(), CmykColor.getIndianRed())
// Create indexed area series and add values to it
IndexedAreaSeries areaSeries1 = new IndexedAreaSeries("Website A", , , myAutogradient1);
areaSeries1.getValues().add(new float[]{5, 7, 9, 6});
// Add indexed area series to the plot area
plotArea.getSeries().add(areaSeries1);
// Create a title and add it to the YAxis
Title lTitle = new Title("Visitors (in millions)");
areaSeries1.getYAxis().getTitles().add(lTitle);
//Adding AxisLabels to the XAxis
areaSeries1.getXAxis().getLabels().add(new IndexedXAxisLabel("Q1", 0));
areaSeries1.getXAxis().getLabels().add(new IndexedXAxisLabel("Q2", 1));
areaSeries1.getXAxis().getLabels().add(new IndexedXAxisLabel("Q3", 2));
areaSeries1.getXAxis().getLabels().add(new IndexedXAxisLabel("Q4", 3));
// Add the chart to the page
page.getElements().add(chart);
// Save the PDF
document.draw("[PhysicalPath]/MyDocument.pdf");
[Java]
// Create a PDF Document
Document document = new Document();
// Create a Page and add it to the document
Page page = new Page();
document.getPages().add(page);
// Create a chart
Chart chart = new Chart(0, 0, 400, 230);
// Create a plot area
PlotArea plotArea = chart.getPrimaryPlotArea();
// Create header titles and add it to the chart
Title title1 = new Title("Website Visitors");
Title title2 = new Title("Year - 2007");
chart.getHeaderTitles().add(title1);
chart.getHeaderTitles().add(title2);
AutoGradient myAutogradient1 = new AutoGradient(90.0f, CmykColor.getRed(), CmykColor.getIndianRed())
AutoGradient myAutogradient2 = new AutoGradient(90.0f, CmykColor.getGreen(), CmykColor.getYellowGreen())
AutoGradient myAutogradient3 = new AutoGradient(120.0f, CmykColor.getBlue(), CmykColor.getLightBlue()) // Create indexed stacked area series elements and add values to it IndexedStackedAreaSeriesElement seriesElement1 = new IndexedStackedAreaSeriesElement("Website A", myAutogradient1); seriesElement1.getValues().add(new float[] { 5, 7, 9, 6 }); IndexedStackedAreaSeriesElement seriesElement2 = new IndexedStackedAreaSeriesElement("Website B", myAutogradient2); seriesElement2.getValues().add(new float[] { 4, 2, 5, 8 }); IndexedStackedAreaSeriesElement seriesElement3 = new IndexedStackedAreaSeriesElement("Website C", myAutogradient3); seriesElement3.getValues().add(new float[] { 2, 4, 6, 9 }); // Create a Indexed Stacked Area Series IndexedStackedAreaSeries areaSeries = new IndexedStackedAreaSeries(); // Add indexed stacked area series elements to the Indexed Stacked Area Series areaSeries.add(seriesElement1); areaSeries.add(seriesElement2); areaSeries.add(seriesElement3); // Add series to the plot area plotArea.getSeries().add(areaSeries); // Create a title and add it to the YAxis Title lTitle = new Title("Visitors (in millions)"); areaSeries.getYAxis().getTitles().add(lTitle); //Adding AxisLabels to the XAxis areaSeries.getXAxis().getLabels().add(new IndexedXAxisLabel("Q1", 0)); areaSeries.getXAxis().getLabels().add(new IndexedXAxisLabel("Q2", 1)); areaSeries.getXAxis().getLabels().add(new IndexedXAxisLabel("Q3", 2)); areaSeries.getXAxis().getLabels().add(new IndexedXAxisLabel("Q4", 3)); // Add the chart to the page page.getElements().add(chart); // Save the PDF document.draw("[PhysicalPath]/MyDocument.pdf");
[Java]
// Create a PDF Document
Document document = new Document();
// Create a Page and add it to the document
Page page = new Page();
document.getPages().add(page);
// Create a chart
Chart chart = new Chart(0, 0, 400, 230);
// Create a plot area
PlotArea plotArea = chart.getPrimaryPlotArea();
// Create header titles and add it to the chart
Title title1 = new Title("Website Visitors");
Title title2 = new Title("Year - 2007");
chart.getHeaderTitles().add(title1);
chart.getHeaderTitles().add(title2);
AutoGradient myAutogradient1 = new AutoGradient(90.0, CmykColor.getRed(), CmykColor.getIndianRed())
AutoGradient myAutogradient2 = new AutoGradient(90.0F, CmykColor.getGreen(), CmykColor.getYellowGreen())
AutoGradient myAutogradient3 = new AutoGradient(120.0F, CmykColor.getBlue(), CmykColor.getLightBlue()) // Create a indexed 100% stacked area series elements and add values to it Indexed100PercentStackedAreaSeriesElement seriesElement1 = new Indexed100PercentStackedAreaSeriesElement("Website A", myAutogradient1); seriesElement1.getValues().add(new float[] { 5, 7, 9, 6 }); Indexed100PercentStackedAreaSeriesElement seriesElement2 = new Indexed100PercentStackedAreaSeriesElement("Website B", myAutogradient2); seriesElement2.getValues().add(new float[] { 4, 2, 5, 8 }); Indexed100PercentStackedAreaSeriesElement seriesElement3 = new Indexed100PercentStackedAreaSeriesElement("Website C", myAutogradient3); seriesElement3.getValues().add(new float[] { 2, 4, 6, 9 }); // Create a Indexed 100% Stacked Area Series Indexed100PercentStackedAreaSeries areaSeries = new Indexed100PercentStackedAreaSeries(); // Add indexed 100% stacked area series elements to the Indexed 100% Stacked Area Series areaSeries.add(seriesElement1); areaSeries.add(seriesElement2); areaSeries.add(seriesElement3); // Add series to the plot area plotArea.getSeries().add(areaSeries); // Create a title and add it to the yAxis Title lTitle = new Title("Visitors (in millions)"); areaSeries.getYAxis().getTitles().add(lTitle); //Adding AxisLabels to the XAxis areaSeries.getXAxis().getLabels().add(new IndexedXAxisLabel("Q1", 0)); areaSeries.getXAxis().getLabels().add(new IndexedXAxisLabel("Q2", 1)); areaSeries.getXAxis().getLabels().add(new IndexedXAxisLabel("Q3", 2)); areaSeries.getXAxis().getLabels().add(new IndexedXAxisLabel("Q4", 3)); // Add the chart to the page page.getElements().add(chart); // Save the PDF document.draw("[PhysicalPath]/MyDocument.pdf");