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

Message ListMessage List     Post MessagePost Message

  How to truncate legend text on LEFT side and keep data labels using full text?
Posted by John Vella on Dec-01-2023 07:06
Is it possible for the tooltip text for datasets so it shows the full dataset name, while the entries in a legend box shows truncated text BUT has the text truncated on the left (ie the "..." appear on left side of legend labels)?

I'm currently doing the truncating manually to get the left-side truncation but it requires truncating the dataset name, which means the tooltip text isn't showing the full text.

I have a single LineLayer where I add multiple datasets. The layer's setHTMLImageMap uses "title='<*cdml*>{dataSetName}'" for the tooltip.

Is there a way to achieve what I want (using Qt and C++) ?

  Re: How to truncate legend text on LEFT side and keep data labels using full text?
Posted by Peter Kwan on Dec-01-2023 17:14
Hi John,

Yes, you can create string array containing the short dataset names, add that as an extra field, and configure the legend box to use the short data names with {dsFieldN} (N depends on which extra field is your shorten dataset names).

Continue with your previous thread:

https://www.chartdir.com/forum/download_thread.php?site=chartdir&bn=chartdir_support&thread=1700688695&new_thread=1

Layer *layer = c.addLineLayer(.....);
layer->addDataSet(.....);
layer->addDataSet(.....);
layer->addDataSet(.....);

// One StringArray for each data set
layer->addExtraField(....);
layer->addExtraField(....);
layer->addExtraField(....);

// Assume you have 3 data sets, so there should be a StringArray with 3 text strings
// for the 3 shortened dataset names
layer->addExtraField(StringArray(shortenNames, 3));

// The shortened name is in the 4th extra field. {dsField3} means the 4th extra field
// is associated with the dataset (as opposed to associated with the data points)
c->getLegend()->setText("{dsField3}");


Best Regards
Peter Kwan