#include "chartdir.h"
int main(int argc, char *argv[])
{
//The data for the chart
double data0[] = {22, 27.4, 22, 17, 13, 27, 26, 20.2, 23, 28, 27, 24};
//The circular data points used to represent the zones
double zone0[] = {15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15};
double zone1[] = {25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25};
//The labels for the chart
const char *labels[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
"Aug", "Sept", "Oct", "Nov", "Dec"};
//Create a PolarChart object of size 400 x 420 pixels
PolarChart *c = new PolarChart(400, 420);
//Set background color to a 2 pixel pattern color, with a black border and 1
//pixel 3D border effect
int pattern[] = {0xffffff, 0xe0e0e0};
c->setBackground(c->patternColor(IntArray(pattern,
sizeof(pattern)/sizeof(*pattern)), 2), 0, 1);
//Add a title to the chart using 16 pts Arial Bold Italic font. The title
//text is white (0xffffff) on 2 pixel pattern background
int pattern2[] = {0x0, 0x80};
c->addTitle("Chemical Concentration", "arialbi.ttf", 16, 0xffffff
)->setBackground(c->patternColor(IntArray(pattern2,
sizeof(pattern2)/sizeof(*pattern2)), 2));
//Set center of plot area at (200, 240) with radius 145 pixels. Set
//background color to 0xffcccc
c->setPlotArea(200, 240, 145, 0xffcccc);
//Set the grid style to circular grid
c->setGridStyle(false);
//Set the radial axis label format
c->radialAxis()->setLabelFormat("{value} ppm");
//Add a legend box at (200, 30) top center aligned, using 9 pts Arial Bold
//font. with a black border, and 1 pixel 3D border effect.
LegendBox *legendBox = c->addLegend(200, 30, false, "arialbd.ttf", 9);
legendBox->setAlignment(TopCenter);
//Add a legend key to represent the red (0xffcccc) zone
legendBox->addKey("Over-Absorp", 0xffcccc);
//Add a spline area layer using circular data to represent the green
//(0xaaffaa) and blue (0xccccff) zones
c->addSplineAreaLayer(DoubleArray(zone1, sizeof(zone1)/sizeof(*zone1)),
0xaaffaa, "Normal");
c->addSplineAreaLayer(DoubleArray(zone0, sizeof(zone0)/sizeof(*zone0)),
0xccccff, "Under-Absorp");
//Add a blue (0x80) spline line layer with line width set to 3 pixels
c->addSplineLineLayer(DoubleArray(data0, sizeof(data0)/sizeof(*data0)), 0x80
)->setLineWidth(3);
//Set the labels to the angular axis as spokes. Set the font size to 10 pts
//fonts.
c->angularAxis()->setLabels(StringArray(labels,
sizeof(labels)/sizeof(*labels)))->setFontSize(10);
//output the chart
c->makeChart("polarzones.png");
//free up resources
delete c;
return 0;
}
|