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

Message ListMessage List     Post MessagePost Message

  Adding tags to Financechart
Posted by Dave on Jun-12-2020 01:35
I created an array to hold the tag values as extrafield for addScatterLayer special shapes:

    char labels [chartBars][3];

Gave it values for the relevant locations and the rest as ""

then

    ScatterLayer *myLayer = mainChart->addScatterLayer(DoubleArray(), DoubleArray(Signal, chartBars), "Signal", Chart::ArrowShape(180, 1, 0.4, 0.4), 11, 0x9900cc);

That works fine and I get the symbols in the right locations...

then following your example

    myLayer->addExtraField (StringArray(labels, (int)(sizeof(labels / sizeof(labels[0]))));

that gives me a compile error

error: no matching function for call to ‘StringArray::StringArray(char [60][3], int)

couldn't find guidance in the addExtraField documentation....

It's coming along amazing with realtime updates, special symbols, abd mousewheel and keyboard control....  Love it!!!!


Thanks!!!

David

  Re: Adding tags to Financechart
Posted by Peter Kwan on Jun-12-2020 10:04
Hi Dave,

This error means the variable data type is incorrect. As C++ is a strongly typed language, the data type for "labels" must be implicitly convertible to the type expected by StringArray. The StringArray expects an array of text strings (const char * const *data). See:

https://www.advsofteng.com/doc/cdcpp.htm#StringArray.htm

In C++, an array of char (that is, char[]) is implicitly convertible to a text string (char *). However, it does not mean an array of an array of char (char[][]) is implicitly convertible to an array of text strings. These two types have completely different memory layout and are not convertible to each others. That is the cause of the error.

To solve the problem, you need to create an array of text strings (char *) instead. For example:

// This is not an array of "char *" and cannot be used for StringArray
char labels [chartBars][3];

.....

// This is an array of "char *" usable for StringArray
char* labels2[chartBars];

// Convert from "char[][]" to "char *[]"
for (int i = 0; i < chartBars; ++i)
    labels2[charBars] = labels[charBars];

// Now you can use labels2 in StringArray
myLayer->addExtraField (StringArray(labels2, chartBars));


Hope this can help.

Regards
Peter Kwan