Jump to content
Software FX Community

Trouble with X Axis


User (Legacy)

Recommended Posts

Hi,

I'm working with MFC,

and I'm having some trouble with putting labels for the X axis values, and

also to place the vertical grid on.

The thing is that the same code work ok for

the Y axis an for the horizontal grid

here is the relevant code:

ICfxAxisEnumPtr pAxisEnum;

ICfxAxisPtr pAxisX, pAxisY;

ICfxSeriesEnumPtr pSeriesEnum;

ICfxSeriesPtr pSeries;

int i;

GetChart()->PutGrid( m_bYGrid ? CHART_HORZGRID : CHART_NOGRID |

m_bXGrid ? CHART_VERTGRID : CHART_NOGRID);

GetChart()->get_Axis(&pAxisEnum);

pAxisX = pAxisEnum->GetItem(AXIS_X);

ASSERT(pAxisX != NULL);

pAxisY = pAxisEnum->GetItem(AXIS_Y);

ASSERT(pAxisY != NULL);

if (pAxisX)

{

pAxisX->ClearLabels();

pAxisX->ResetScale();

pAxisX->put_Min(m_nXmin);

pAxisX->put_Max(m_nXmax);

if (m_aLabelsX.GetSize()){

pAxisX->put_STEP(1.0);

pAxisX->put_LabelValue(1.0);

for (int i = m_nXmin; (i <= m_nXmax) && (i - m_nXmin <

m_aLabelsX.GetSize()); i++)

{

LPSTR sTemp = (char*)(LPCTSTR)m_aLabelsX[i - m_nXmin];

pAxisX->put_Label(i - m_nXmin, sTemp);

}

}

}

if (pAxisY)

{

pAxisY->ClearLabels();

pAxisY->ResetScale();

pAxisY->put_Min(m_nYmin);

pAxisY->put_Max(m_nYmax);

if (m_aLabelsY.GetSize()){

pAxisY->put_Min(0);

pAxisY->put_Max(m_aLabelsY.GetSize() - 1);

pAxisY->put_STEP(1.0);

pAxisY->put_LabelValue(1.0);

for (int i = m_nYmin; (i <= m_nYmax) && (i - m_nYmin <

m_aLabelsY.GetSize()); i++)

{

LPSTR sTemp = (char*)(LPCTSTR)m_aLabelsY[i - m_nYmin];

pAxisY->put_Label(i - m_nYmin, sTemp);

}

}

}

Link to comment
Share on other sites

What exactly is the problem ? The min and max of the X-Axis can not be

controlled unless you assign X-Values to the chart, otherwise the X-Axis

will be just a collection of labels starting with the first data point and

ending with the last, in other words the range of the X-Axis is given by the

number of points in the chart.

As for the gridlines, I don't see any code that turn on the gridlines. The

labels appear to be assigned correctly.

Please describe in detail what is the problem you are having. You don't get

any labels ? what are you getting ? what do you want to get ?

--

FP

Software FX Support

"Avri" <avri@metalink.co.il> wrote in message

news:s3McYLToCHA.584@webserver1.softwarefx.com...

> Hi,

>

> I'm working with MFC,

> and I'm having some trouble with putting labels for the X axis values, and

> also to place the vertical grid on.

> The thing is that the same code work ok for

> the Y axis an for the horizontal grid

>

> here is the relevant code:

>

> ICfxAxisEnumPtr pAxisEnum;

> ICfxAxisPtr pAxisX, pAxisY;

> ICfxSeriesEnumPtr pSeriesEnum;

> ICfxSeriesPtr pSeries;

> int i;

>

> GetChart()->PutGrid( m_bYGrid ? CHART_HORZGRID : CHART_NOGRID |

> m_bXGrid ? CHART_VERTGRID : CHART_NOGRID);

>

> GetChart()->get_Axis(&pAxisEnum);

> pAxisX = pAxisEnum->GetItem(AXIS_X);

> ASSERT(pAxisX != NULL);

> pAxisY = pAxisEnum->GetItem(AXIS_Y);

> ASSERT(pAxisY != NULL);

>

> if (pAxisX)

> {

> pAxisX->ClearLabels();

> pAxisX->ResetScale();

> pAxisX->put_Min(m_nXmin);

> pAxisX->put_Max(m_nXmax);

> if (m_aLabelsX.GetSize()){

> pAxisX->put_STEP(1.0);

> pAxisX->put_LabelValue(1.0);

> for (int i = m_nXmin; (i <= m_nXmax) && (i - m_nXmin <

> m_aLabelsX.GetSize()); i++)

> {

> LPSTR sTemp = (char*)(LPCTSTR)m_aLabelsX[i - m_nXmin];

> pAxisX->put_Label(i - m_nXmin, sTemp);

> }

> }

> }

> if (pAxisY)

> {

>

>

> pAxisY->ClearLabels();

> pAxisY->ResetScale();

> pAxisY->put_Min(m_nYmin);

> pAxisY->put_Max(m_nYmax);

>

> if (m_aLabelsY.GetSize()){

> pAxisY->put_Min(0);

> pAxisY->put_Max(m_aLabelsY.GetSize() - 1);

> pAxisY->put_STEP(1.0);

> pAxisY->put_LabelValue(1.0);

> for (int i = m_nYmin; (i <= m_nYmax) && (i - m_nYmin <

> m_aLabelsY.GetSize()); i++)

> {

> LPSTR sTemp = (char*)(LPCTSTR)m_aLabelsY[i - m_nYmin];

> pAxisY->put_Label(i - m_nYmin, sTemp);

> }

> }

>

> }

>

>

>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...