ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Custom label format x-axis
Posted by Pieter on Oct-19-2016 15:32
Hi,

I use these lines of code to set the labels of a boxwhiskerlayer:

CString fontnormal = CString(g_controlfilefolder) + "fonts\\ariel.ttf";
CString fontbold = CString(g_controlfilefolder) + "fonts\\trebucbd.ttf";

const char *labels[] = { "Label1", "Label2" , "Label3", "Label4" ,  "Label5", "Label6" };
c->xAxis()->setLabels(StringArray(labels, (int)(sizeof(labels) / sizeof(labels[0]))))->setFontStyle(fontnormal);

I want only a few x-axis labels in bold. i tried to use the following functions but without success:
//layer->addCustomDataLabel(i, i, fontbold);
layer->addCustomGroupLabel(0, 0, "label3", fontbold);
layer->addCustomGroupLabel(0, i, labels[i], "arialbd.ttf", 8);
c->xAxis()->addLabel(i, "label3");
c->xAxis()->getFormattedLabel(i, fontbold);

Can someone help me? Thank you in advance!

  Re: Custom label format x-axis
Posted by Peter Kwan on Oct-20-2016 02:22
Hi Pieter,

There are several methods to specify a font for a particular axis label. One method is to use CDML:

const char *labels[] = { "Label1", "Label2" , "<*font=arialbd.ttf*>Label3", "Label4" ,  "Label5", "Label6" };

The other method is use Axis::addMark to add a mark at the specified position:

c->xAxis()->addMark(2, -1, "Label3", "arialbd.ttf", 8)->setMarkColor(Chart::Transparent, 0x000000, Chart::Transparent);

Hope this can help.

Regards
Peter Kwan

  Re: Custom label format x-axis
Posted by Pieter on Oct-20-2016 15:15
Thank you! Works perfectly!

Pieter