Column Chart

Vertical tetragons are used to display information in column charts. There are three column chart types, Normal, Stacked, and 100% Stacked.

Normal

Normal column charts create tetragons based on the data. They use DateTimeXAxis or IndexedXAxis as the XAxis based on the series and NumericYAxis as the YAxis.

Figure 1. Normal Column Chart

// Create a PDF Document
Document document = new Document();
// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add(page);

// Create a chart
Chart chart = new Chart(0, 0, 400, 230);
// Create a plot area
PlotArea plotArea = chart.PrimaryPlotArea;

// Create header titles and add it to the chart
Title title1 = new Title("Website Visitors");
Title title2 = new Title("Year - 2007");
chart.HeaderTitles.Add(title1);
chart.HeaderTitles.Add(title2);

// Create a indexed column series and add values to it
IndexedColumnSeries columnSeries1 = new IndexedColumnSeries("Website A");
columnSeries1.Values.Add(new float[] { 5, 7, 9, 6 });
IndexedColumnSeries columnSeries2 = new IndexedColumnSeries("Website B");
columnSeries2.Values.Add(new float[] { 4, 2, 5, 8 });
IndexedColumnSeries columnSeries3 = new IndexedColumnSeries("Website C");
columnSeries3.Values.Add(new float[] { 2, 4, 6, 9 });

// Create autogradient and assign it to series
AutoGradient autogradient1 = new AutoGradient(180f, CmykColor.Red, CmykColor.IndianRed);
columnSeries1.Color = autogradient1;
AutoGradient autogradient2 = new AutoGradient(180f, CmykColor.Green, CmykColor.YellowGreen);
columnSeries2.Color = autogradient2;
AutoGradient autogradient3 = new AutoGradient(180f, CmykColor.Blue, CmykColor.LightBlue);
columnSeries3.Color = autogradient3;

// Add indexed column series to the plot area
plotArea.Series.Add(columnSeries1);
plotArea.Series.Add(columnSeries2);
plotArea.Series.Add(columnSeries3);

// Create a title and add it to the yaxis
Title lTitle = new Title("Visitors (in millions)");
columnSeries1.YAxis.Titles.Add(lTitle);

//Adding AxisLabels to the XAxis
columnSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Q1", 0));
columnSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Q2", 1));
columnSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Q3", 2));
columnSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Q4", 3));

// Add the chart to the page
page.Elements.Add(chart);
// Save the PDF
document.Draw(pdfFilePath);  
' Create a PDF Document
Dim MyDocument As New Document()
' Create a Page and add it to the MyDocument
Dim MyPage As New Page()
MyDocument.Pages.Add(MyPage)

' Create a MyChart
Dim MyChart As New Chart(0, 0, 400, 230)

' Create a plot area
Dim MyPlotArea As PlotArea = MyChart.PrimaryPlotArea

' Create header titles and add it to the MyChart
Dim MyTitle1 As New Title("Website Visitors")
Dim MyTitle2 As New Title("Year - 2007")
MyChart.HeaderTitles.Add(MyTitle1)
MyChart.HeaderTitles.Add(MyTitle2)

' Create a indexed column series and add values to it
Dim MyColumnSeries1 As New IndexedColumnSeries("Website A")
MyColumnSeries1.Values.Add(New Single() {5, 7, 9, 6})
Dim MyColumnSeries2 As New IndexedColumnSeries("Website B")
MyColumnSeries2.Values.Add(New Single() {4, 2, 5, 8})
Dim MyColumnSeries3 As New IndexedColumnSeries("Website C")
MyColumnSeries3.Values.Add(New Single() {2, 4, 6, 9})

' Add autogradient colors to series
Dim MyAutogradient1 As AutoGradient = New AutoGradient(90.0F, CmykColor.Red, CmykColor.IndianRed)
MyColumnSeries1.Color = MyAutogradient1
Dim MyAutogradient2 As AutoGradient = New AutoGradient(90.0F, CmykColor.Green, CmykColor.YellowGreen)
MyColumnSeries2.Color = MyAutogradient2
Dim MyAutogradient3 As AutoGradient = New AutoGradient(120.0F, CmykColor.Blue, CmykColor.LightBlue)
MyColumnSeries3.Color = MyAutogradient3

' Add indexed column series to the plot area
MyPlotArea.Series.Add(MyColumnSeries1)
MyPlotArea.Series.Add(MyColumnSeries2)
MyPlotArea.Series.Add(MyColumnSeries3)

' Create a title and add it to the yaxis
Dim MylTitle As New Title("Visitors (in millions)")
MyColumnSeries1.YAxis.Titles.Add(MylTitle)

'Adding AxisLabels to the XAxis
MyColumnSeries1.XAxis.Labels.Add(New IndexedXAxisLabel("Q1", 0))
MyColumnSeries1.XAxis.Labels.Add(New IndexedXAxisLabel("Q2", 1))
MyColumnSeries1.XAxis.Labels.Add(New IndexedXAxisLabel("Q3", 2))
MyColumnSeries1.XAxis.Labels.Add(New IndexedXAxisLabel("Q4", 3))

' Add the MyChart to the MyPage
MyPage.Elements.Add(MyChart)
' Save the PDF
MyDocument.Draw(pdfFilePath)          

Stacked

Stacked charts show related data, one on top of the other. They use DateTimeXAxis or IndexedXAxis as the XAxis based on the series and NumericYAxis as the YAxis.

Figure 2. Stacked Column Chart

// Create a PDF Document
Document document = new Document();
// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add(page);

// Create a chart
Chart chart = new Chart(0, 0, 400, 230);
// Create a plot area
PlotArea plotArea = chart.PrimaryPlotArea;

// Create header titles and add it to the chart
Title title1 = new Title("Website Visitors");
Title title2 = new Title("Year - 2007");
chart.HeaderTitles.Add(title1);
chart.HeaderTitles.Add(title2);

// Create a indexed stacked column series elements and add values to it
IndexedStackedColumnSeriesElement seriesElement1 = new IndexedStackedColumnSeriesElement("Website A");
seriesElement1.Values.Add(new float[] { 5, 7, 9, 6 });
IndexedStackedColumnSeriesElement seriesElement2 = new IndexedStackedColumnSeriesElement("Website B");
seriesElement2.Values.Add(new float[] { 4, 2, 5, 8 });
IndexedStackedColumnSeriesElement seriesElement3 = new IndexedStackedColumnSeriesElement("Website C");
seriesElement3.Values.Add(new float[] { 2, 4, 6, 9 });

// Create autogradient and assign it to series
AutoGradient autogradient1 = new AutoGradient(180f, CmykColor.Red, CmykColor.IndianRed);
seriesElement1.Color = autogradient1;
AutoGradient autogradient2 = new AutoGradient(180f, CmykColor.Green, CmykColor.YellowGreen);
seriesElement2.Color = autogradient2;
AutoGradient autogradient3 = new AutoGradient(180f, CmykColor.Blue, CmykColor.LightBlue);
seriesElement3.Color = autogradient3;

// Create a Indexed Stacked Column Series
IndexedStackedColumnSeries columnSeries = new IndexedStackedColumnSeries();
// Add indexed stacked column series elements to the Indexed Stacked Column Series
columnSeries.Add(seriesElement1);
columnSeries.Add(seriesElement2);
columnSeries.Add(seriesElement3);
// Add series to the plot area
plotArea.Series.Add(columnSeries);

// Create a title and add it to the yaxis
Title lTitle = new Title("Visitors (in millions)");
columnSeries.YAxis.Titles.Add(lTitle);

//Adding AxisLabels to the XAxis
columnSeries.XAxis.Labels.Add(new IndexedXAxisLabel("Q1", 0));
columnSeries.XAxis.Labels.Add(new IndexedXAxisLabel("Q2", 1));
columnSeries.XAxis.Labels.Add(new IndexedXAxisLabel("Q3", 2));
columnSeries.XAxis.Labels.Add(new IndexedXAxisLabel("Q4", 3));

// Add the chart to the page
page.Elements.Add(chart);
// Save the PDF
document.Draw(pdfFilePath);        
' Create a PDF Document
Dim MyDocument As New Document()
' Create a Page and add it to the MyDocument
Dim MyPage As New Page()
MyDocument.Pages.Add(MyPage)

' Create a MyChart
Dim MyChart As New Chart(0, 0, 400, 230)
' Create a plot area
Dim MyPlotArea As PlotArea = MyChart.PrimaryPlotArea

' Create header titles and add it to the MyChart
Dim MyTitle1 As New Title("Website Visitors")
Dim MyTitle2 As New Title("Year - 2007")
MyChart.HeaderTitles.Add(MyTitle1)
MyChart.HeaderTitles.Add(MyTitle2)

' Create a indexed stacked column series elements and add values to it
Dim MySeriesElement1 As New IndexedStackedColumnSeriesElement("Website A")
MySeriesElement1.Values.Add(New Single() {5, 7, 9, 6})
Dim MySeriesElement2 As New IndexedStackedColumnSeriesElement("Website B")
MySeriesElement2.Values.Add(New Single() {4, 2, 5, 8})
Dim MySeriesElement3 As New IndexedStackedColumnSeriesElement("Website C")
MySeriesElement3.Values.Add(New Single() {2, 4, 6, 9})

' Add autogradient colors to series
Dim MyAutogradient1 As AutoGradient = New AutoGradient(90.0F, CmykColor.Red, CmykColor.IndianRed)
MySeriesElement1.Color = MyAutogradient1
Dim MyAutogradient2 As AutoGradient = New AutoGradient(90.0F, CmykColor.Green, CmykColor.YellowGreen)
MySeriesElement2.Color = MyAutogradient2
Dim MyAutogradient3 As AutoGradient = New AutoGradient(120.0F, CmykColor.Blue, CmykColor.LightBlue)
MySeriesElement3.Color = MyAutogradient3

' Create a Indexed Stacked Column Series
Dim MyColumnSeries As New IndexedStackedColumnSeries()
' Add indexed stacked column series elements to the Indexed Stacked Column Series
MyColumnSeries.Add(MySeriesElement1)
MyColumnSeries.Add(MySeriesElement2)
MyColumnSeries.Add(MySeriesElement3)
' Add series to the plot area
MyPlotArea.Series.Add(MyColumnSeries)

'Create a title and add it to the yaxis
Dim MylTitle As New Title("Visitors (in millions)")
MyColumnSeries.YAxis.Titles.Add(MylTitle)

'Adding AxisLabels to the XAxis
MyColumnSeries.XAxis.Labels.Add(New IndexedXAxisLabel("Q1", 0))
MyColumnSeries.XAxis.Labels.Add(New IndexedXAxisLabel("Q2", 1))
MyColumnSeries.XAxis.Labels.Add(New IndexedXAxisLabel("Q3", 2))
MyColumnSeries.XAxis.Labels.Add(New IndexedXAxisLabel("Q4", 3))

' Add the MyChart to the MyPage
MyPage.Elements.Add(MyChart)
' Save the PDF
MyDocument.Draw(pdfFilePath)      

100% Stacked

100% stacked charts are similar to stacked charts, but here the data is expressed as a percentage. They use DateTimeXAxis or IndexedXAxis as the XAxis based on the series and PercentageYAxis as the YAxis.

Figure 3. Stacked 100% Column Chart

// Create a PDF Document
Document document = new Document();
// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add(page);

// Create a chart
Chart chart = new Chart(0, 0, 400, 230);
// Create a plot area
PlotArea plotArea = chart.PrimaryPlotArea;

// Create header titles and add it to the chart
Title title1 = new Title("Website Visitors");
Title title2 = new Title("Year - 2007");
chart.HeaderTitles.Add(title1);
chart.HeaderTitles.Add(title2);

// Create a indexed 100% column series elements and add values to it
Indexed100PercentStackedColumnSeriesElement seriesElement1 = new Indexed100PercentStackedColumnSeriesElement("Website A");
seriesElement1.Values.Add(new float[] { 5, 7, 9, 6 });
Indexed100PercentStackedColumnSeriesElement seriesElement2 = new Indexed100PercentStackedColumnSeriesElement("Website B");
seriesElement2.Values.Add(new float[] { 4, 2, 5, 8 });
Indexed100PercentStackedColumnSeriesElement seriesElement3 = new Indexed100PercentStackedColumnSeriesElement("Website C");
seriesElement3.Values.Add(new float[] { 2, 4, 6, 9 });

// Create autogradient and assign it to series
AutoGradient autogradient1 = new AutoGradient(180f, CmykColor.Red, CmykColor.IndianRed);
seriesElement1.Color = autogradient1;
AutoGradient autogradient2 = new AutoGradient(180f, CmykColor.Green, CmykColor.YellowGreen);
seriesElement2.Color = autogradient2;
AutoGradient autogradient3 = new AutoGradient(180f, CmykColor.Blue, CmykColor.LightBlue);
seriesElement3.Color = autogradient3;

// Create a Indexed 100% Stacked Column Series
Indexed100PercentStackedColumnSeries columnSeries = new Indexed100PercentStackedColumnSeries();
// Add indexed 100% column series elements to the Indexed 100% Stacked Column Series
columnSeries.Add(seriesElement1);
columnSeries.Add(seriesElement2);
columnSeries.Add(seriesElement3);
// Add series to the plot area
plotArea.Series.Add(columnSeries);

// Create a title and add it to the yaxis
Title lTitle = new Title("Visitors (in millions)");
columnSeries.YAxis.Titles.Add(lTitle);

//Adding AxisLabels to the XAxis
columnSeries.XAxis.Labels.Add(new IndexedXAxisLabel("Q1", 0));
columnSeries.XAxis.Labels.Add(new IndexedXAxisLabel("Q2", 1));
columnSeries.XAxis.Labels.Add(new IndexedXAxisLabel("Q3", 2));
columnSeries.XAxis.Labels.Add(new IndexedXAxisLabel("Q4", 3));

// Add the chart to the page
page.Elements.Add(chart);
// Save the PDF
document.Draw(pdfFilePath);        
' Create a PDF Document
Dim MyDocument As New Document()
' Create a Page and add it to the MyDocument
Dim MyPage As New Page()
MyDocument.Pages.Add(MyPage)

' Create a MyChart
Dim MyChart As New Chart(0, 0, 400, 230)

' Create a plot area
Dim MyPlotArea As PlotArea = MyChart.PrimaryPlotArea

' Create header titles and add it to the MyChart
Dim MyTitle1 As New Title("Website Visitors")
Dim MyTitle2 As New Title("Year - 2007")
MyChart.HeaderTitles.Add(MyTitle1)
MyChart.HeaderTitles.Add(MyTitle2)

' Create a indexed 100% column series elements and add values to it
Dim MySeriesElement1 As New Indexed100PercentStackedColumnSeriesElement("Website A")
MySeriesElement1.Values.Add(New Single() {5, 7, 9, 6})
Dim MySeriesElement2 As New Indexed100PercentStackedColumnSeriesElement("Website B")
MySeriesElement2.Values.Add(New Single() {4, 2, 5, 8})
Dim MySeriesElement3 As New Indexed100PercentStackedColumnSeriesElement("Website C")
MySeriesElement3.Values.Add(New Single() {2, 4, 6, 9})

' Add autogradient colors to series
Dim MyAutogradient1 As AutoGradient = New AutoGradient(90.0F, CmykColor.Red, CmykColor.IndianRed)
MySeriesElement1.Color = MyAutogradient1
Dim MyAutogradient2 As AutoGradient = New AutoGradient(90.0F, CmykColor.Green, CmykColor.YellowGreen)
MySeriesElement2.Color = MyAutogradient2
Dim MyAutogradient3 As AutoGradient = New AutoGradient(120.0F, CmykColor.Blue, CmykColor.LightBlue)
MySeriesElement3.Color = MyAutogradient3

' Create a Indexed 100% Stacked Column Series
Dim MyColumnSeries As New Indexed100PercentStackedColumnSeries()

'Add indexed 100% column series elements to the Indexed 100% Stacked Column Series
MyColumnSeries.Add(MySeriesElement1)
MyColumnSeries.Add(MySeriesElement2)
MyColumnSeries.Add(MySeriesElement3)

' Add series to the plot area
MyPlotArea.Series.Add(MyColumnSeries)

' Create a title and add it to the yaxis
Dim MylTitle As New Title("Visitors (in millions)")
MyColumnSeries.YAxis.Titles.Add(MylTitle)

'Adding AxisLabels to the XAxis
MyColumnSeries.XAxis.Labels.Add(New IndexedXAxisLabel("Q1", 0))
MyColumnSeries.XAxis.Labels.Add(New IndexedXAxisLabel("Q2", 1))
MyColumnSeries.XAxis.Labels.Add(New IndexedXAxisLabel("Q3", 2))
MyColumnSeries.XAxis.Labels.Add(New IndexedXAxisLabel("Q4", 3))

' Add the MyChart to the MyPage
MyPage.Elements.Add(MyChart)

' Save the PDF
MyDocument.Draw(pdfFilePath)

In this topic