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

Message ListMessage List     Post MessagePost Message

  How to vertical write x-axis?
Posted by Mooseon Choi on May-30-2016 19:19
Attachments:
Hi,
I made the chart. but, my words written on the x-axis is inverted.

I attached made a chart... and My code is
[
lableangle = 0;
pLabel->setFontAngle(labelangle, axisInfo->m_labelAngleVertical);
]

I want to write to the vertical x-axis in the chart.

Look at the words(information) in the red box in the chart,

"n" starting, but I want to "i" Starting

How to modify my code?
inverted.png

  Re: How to vertical write x-axis?
Posted by Peter Kwan on May-31-2016 03:58
Hi Mooseon Choi,

Instead of using the "vertical" flag, we now suggest to simply insert newline for every character to make the labels vertical. We have developed the a "ToVertical" and "ToVerticalArray" utilities to convert a text string and a StringArray to vertical.

//
//=========================================
//

// Converts a text string to vertical by inserting newlines
class ToVertical
{
public :
    ToVertical(const char *str) {
        while (*str) {
            ret += *str;
            if (*++str) ret += 'n';
        }
    }
    operator const char *() {
        return ret.c_str();
    }
private :
    std::string ret;
};

// Converts a StringArray to vertical by inserting newlines
class ToVerticalArray
{
public :
    ToVerticalArray(StringArray labels) {
        buffer.resize(labels.len);
        for (int i = 0; i < labels.len; ++i)
            verticalLabels.push_back((buffer[i] = ToVertical(labels[i])).c_str());
    }
    operator StringArray() {
        return StringArray(&(verticalLabels[0]), verticalLabels.size());
    }
private :
    std::vector<std::string> buffer;
    std::vector<const char *> verticalLabels;
};

//
//=========================================
//


With these utilities, instead of using:

c->xAxis()->setLabels(myStringArray);

you may use the following code to convert to vertical:

c->xAxis()->setLabels(ToVerticalArray(myStringArray));


Hope this can help.

Regards
Peter Kwan