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

Message ListMessage List     Post MessagePost Message

  Regarding scaling on two axis Y1 & Y2
Posted by Sai on Mar-15-2013 18:49
Hi Peter,

I have two axis Y1 & Y2 both are having same unit with different scale range.
Let say Y1 has scaling 0 to 500 and Y2 has 0 to 700

I want to make same scaling on both Y1 & Y2 axis that is 0 to 700 on both axis.

I have tried setLinearScale function but it doesn't work for me.

My code is as follows.

if(m_eSeries1 == METRIC_SERIES_Y1)
{

c->xAxis()->setDateScale(viewPortTimeStamps[0], viewPortTimeStamps[noOfPoints-1]);
c->xAxis()->setMultiFormat(Chart::StartOfDayFilter(), "<*font=bold*> {value|hh:nn\\n mmm dd}", Chart::AllPassFilter(), "{value|hh:nn}");

}

if(m_eSeries2 == METRIC_SERIES_Y2)
{
double viewPortStartDate2 = (viewPortTimeStamps2[0] - m_offsetFactor) / m_scaleFactor;
double viewPortEndDate2  = (viewPortTimeStamps2[noOfPoints2-1] - m_offsetFactor) / m_scaleFactor;
viewer->syncDateAxisWithViewPort("x", c->xAxis());
c->xAxis2()->setDateScale(viewPortStartDate2, viewPortEndDate2);

c->xAxis2()->setMultiFormat(Chart::StartOfDayFilter(), "<*font=bold*> {value|hh:nn\\n mmm dd}", Chart::AllPassFilter(), "{value|hh:nn}");

}

double dScalemax = 0;
if(m_bIsMergeScale && m_szTitleY == m_szTitleY2)
{
c->layoutAxes();
double dMax = c->yAxis()->getMaxValue();
double dMax2 = c->yAxis2()->getMaxValue();
dScalemax = max(dMax,dMax2);
}


if(m_eSeries1 == METRIC_SERIES_Y1)
{

c->yAxis()->setWidth(2);
c->yAxis()->setColors(m_colorY1,m_colorY1);

if(m_bIsMergeScale && m_szTitleY == m_szTitleY2)
{
c->yAxis()->setLinearScale(0,dScalemax);
}

CustomizeLabelOfYaxis(c,c->yAxis(),m_eChartLabelType);

}

if(m_eSeries2 == METRIC_SERIES_Y2)
{
c->yAxis2()->setWidth(2);
c->yAxis2()->setColors(m_colorY2,m_colorY2);

if(m_bIsMergeScale && m_szTitleY == m_szTitleY2)
{
c->yAxis2()->setLinearScale(0,dScalemax);
}
CustomizeLabelOfYaxis(c,c->yAxis2(),m_eChartLabelType2);
}


    delete viewer->getChart();
    viewer->setChart(c);

    m_ChartViewer.setImageMap(c->getHTMLImageMap("", "", "title='{x|hh:nn:ss}: {value|P4}'"));

  Re: Regarding scaling on two axis Y1 & Y2
Posted by Peter Kwan on Mar-15-2013 23:11
Hi Sai,

If you want y1 and y2 to have the same scale, then it means you only need y1 to plot the chart. y2 is just for human reading and set the same to y1, and is not needed to plot the chart.

To do this, please do not configure your layers or data sets to use y2. Then by default, only y1 will be used to plot the chart, and y1 will be auto-scaled to contain all your data. The y2 can then be configured to synchronize with y1 using:

c->syncYAxis();

Several sample code in ChartDirector demonstrates this type of axis configuration. For example, see the sample code "Cylinder Bar Shading" and "Missing Data Points". These examples have 2 y-axes which are identical.

For your current code, ChartDirector has the restriction that you cannot change the axis scale after "layoutAxes", as ChartDirector has already set the axis scale. That's why in your case, setLinearScale would not work. The setLinearScale, if used, should be called before "layoutAxes".

Hope this can help.

Regards
Peter Kwan