Hello,
I would like to print the text of the labels of the different axes of a rose in the same color as the axe itself.
is it possible ? How do I have to proceed ?
Here is an example :
#include "chartdir.h"
int main(int argc, char *argv[])
{
// Data for the chart
double data[] = {1.19, 0.06, 0.8, 1.42, 2.13, 1.77, 1.22, 3.0, 1.5,
0.86, 0.95, 0.63, 0.12, 0.15, 1.6, 2.0, 1.4, 0.70};
int colors[] = {0x2E972E, 0xFF1717, 0xFF1717, 0x463AD0, 0x83345B, 0x521678, 0x345320, 0x973400, 0xB10F28,
0x2E972E, 0xFF1717, 0xFF1717, 0x463AD0, 0x83345B, 0x521678, 0x345320, 0x973400, 0xB10F28};
// The labels on the angular axis (spokes)
const char* labels[] = {
"My label01",
"My label02",
"My label03",
"My label04",
"My label05",
"My label06",
"My label07",
"My label08",
"My label09",
"My label10",
"My label11",
"My label12",
"My label13",
"My label14",
"My label15",
"My label16",
"My label18",
"My label19"
};
const int labels_size = (int)(sizeof(labels)/sizeof(*labels));
PolarChart *c = new PolarChart(800, 600, Chart::silverColor(), 0x000000, 1);
c->addTitle("Votre situation", "arialbi.ttf", 15, 0xffffff)->setBackground(0x000000);
c->setPlotArea(400, 320, 180, 0xffffff);
c->setGridStyle(false);
// Set angular axis as 0 - 360, with a spoke every 20 units
c->angularAxis()->setLinearScale(0, 360, 20);
// Set angular axis as 0 - 360, either 8 spokes
c->angularAxis()->setLinearScale(0, 360, StringArray(labels, labels_size));
// Add sectors to the chart as sector zones
for(int i = 0; i < (int)(sizeof(data) / sizeof(data[0])); ++i) {
c->angularAxis()->addZone(20*i-90+1, 20*i-70-1, 0, data[i], colors[i], colors[i]);
}
c->addLineLayer(DoubleArray(data, (int)(sizeof(data) / sizeof(data[0]))), Chart::Transparent);
// Output the chart
c->makeChart("roseidx.png");
c->makeChart("roseidx.svg");
delete c;
return 0;
}
How can I use the colors defined in the colors array to print the labels ?
Thank you for your help!
Regards
Alain
|