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

Message ListMessage List     Post MessagePost Message

  Question. about relation chartDirector's api ( setChart getChart getMinValue layout)
Posted by jai min lee on Oct-10-2014 13:07
Attachments:
I had to modify xyzoomscrollDlg.cpp. as follows.



// redraw call

void CXyzoomscrollDlg::drawImageChart(CChartViewer *viewer){

double Xmin = (double)c->xAxis()->getMinValue();
double Xmax = (double)c->xAxis()->getMaxValue();
double Ymin = (double)c->yAxis()->getMinValue();
double Ymax = (double)c->yAxis()->getMaxValue();

CString str;
str.Format("<: chart info: %p %f %f %f %f", c, Xmin, Xmax, Ymin, Ymax);
::OutputDebugString(str);
:

:

:

delete m_ChartViewer.getChart();
m_ChartViewer.setChart(c);
XYChart *xc = (XYChart*)m_ChartViewer.getChart();
Xmin = (double)xc->xAxis()->getMinValue();
Xmax = (double)xc->xAxis()->getMaxValue();
Ymin = (double)xc->yAxis()->getMinValue();
Ymax = (double)xc->yAxis()->getMaxValue();
str.Format("<:-chart info: %p %f %f %f %f", xc, Xmin, Xmax, Ymin, Ymax);
::OutputDebugString(str);

}



// view port change

void CXyzoomscrollDlg::OnViewPortChanged1()
{
// In addition to updating the chart, we may also need to update other controls that
// changes based on the view port.
updateControls(&m_ChartViewer);

// Update the chart if necessary
if (m_ChartViewer.needUpdateChart()){
  drawImageChart(&m_ChartViewer);
}

XYChart *c = (XYChart*)m_ChartViewer.getChart();
  double Xmin = (double)c->xAxis()->getMinValue();
  double Xmax = (double)c->xAxis()->getMaxValue();
  double Ymin = (double)c->yAxis()->getMinValue();
  double Ymax = (double)c->yAxis()->getMaxValue();
  CString str;
  str.Format("<:u1 chart info: %p %f %f %f %f", c, Xmin, Xmax, Ymin, Ymax);
  ::OutputDebugString(str);

:

:

}





This is my OutputDebugString( DebugView log)

////////////////////////////////////////////////////////////////////////////////

//load  First chart



[19216] <: chart info: 000000000B79D300 0.000000 675.000000 250.000000 0.000000
[19216] <:-chart info: 000000000B79D300 0.000000 675.000000 250.000000 0.000000

[19216] <:u1 chart info: 000000000B79D300 0.000000 675.000000 250.000000 0.000000
[19216] <:u2 chart info: 000000000B79D300 0.000000 675.000000 250.000000 0.000000



//change new chart.  load Second chart


[19216] <: chart info: 000000000C3A1130 0.000000 2110.000000 8000.000000 0.000000
[19216] <:-chart info: 000000000C3A1130 0.000000 2110.000000 0.000000 8000.000000
[19216] <:u1 chart info: 000000000C3A1130 0.000000 2110.000000 0.000000 8000.000000
[19216] <:u2 chart info: 000000000C3A1130 0.000000 2110.000000 0.000000 8000.000000



//zoom in call


[19216] <: chart info: 000000000C3A11D0 0.000000 2110.000000 0.000000 8000.000000
[19216] <:-chart info: 000000000C3A11D0 166.050000 214.650000 67.500000 44.375000
[19216] <:u1 chart info: 000000000C3A11D0 166.050000 214.650000 67.500000 44.375000
[19216] <:u2 chart info: 000000000C3A11D0 166.050000 214.650000 67.500000 44.375000



//zoom out call


[19216] <: chart info: 000000000C3A1270 0.000000 2110.000000 0.000000 8000.000000
[19216] <:-chart info: 000000000C3A1270 139.514400 236.714400 78.310938 32.060937
[19216] <:u1 chart info: 000000000C3A1270 139.514400 236.714400 78.310938 32.060937
[19216] <:u2 chart info: 000000000C3A1270 139.514400 236.714400 78.310938 32.060937



//zoom out call


[19216] <: chart info: 000000000C3A1310 0.000000 2110.000000 0.000000 8000.000000
[19216] <:-chart info: 000000000C3A1310 86.443200 280.843200 99.932812 7.432812
[19216] <:u1 chart info: 000000000C3A1310 86.443200 280.843200 99.932812 7.432812
[19216] <:u2 chart info: 000000000C3A1310 86.443200 280.843200 99.932812 7.432812



//zoom out call
[19216] <: chart info: 000000000C3A1130 0.000000 2110.000000 0.000000 8000.000000
[19216] <:-chart info: 000000000C3A1130 0.000000 388.800000 185.000000 0.000000
[19216] <:u1 chart info: 000000000C3A1130 0.000000 388.800000 185.000000 0.000000
[19216] <:u2 chart info: 000000000C3A1130 0.000000 388.800000 185.000000 0.000000



//zoom out call


[19216] <: chart info: 000000000C3A11D0 0.000000 2110.000000 0.000000 8000.000000
[19216] <:-chart info: 000000000C3A11D0 0.000000 675.000000 250.000000 0.000000
[19216] <:u1 chart info: 000000000C3A11D0 0.000000 675.000000 250.000000 0.000000
[19216] <:u2 chart info: 000000000C3A11D0 0.000000 675.000000 250.000000 0.000000
//////////////////////////////////////////////////////////////////////////////////////////////////////////////



Why getMinValue api have different value?



it Still has the old value.



m_ChartViewer.setChart(c);
XYChart *xc = (XYChart*)m_ChartViewer.getChart();




I want to receive the changed value through getchart ().



scenario



1. First Graph Load

X Y W H

0.000000 675.000000 250.000000 0.000000



2.

zoom in out control



3. Second Graph Load

X Y W H

0.000000 2110.000000 0.000000 8000.000000



4.

zoom in out control



1,2, 3, 4, 1,2,3,4........



Let us know what the problem is...



Dear advsofteng's supporter.
XyzoomscrollDlg.cpp

  Re: Question. about relation chartDirector's api ( setChart getChart getMinValue layout)
Posted by Peter Kwan on Oct-11-2014 02:45
Hi,

ChartDirector does not know whether the chart you loaded to the CChartViewer is a new
chart or is a continuation of the old chart.

It is common to load different charts when zooming in and out. For example, in a financial
chart, when it is zoomed out to 180 days, the chart may display a daily candlestick chart
(one candlestick per day). If it is zoomed in to a few hours, it may display a line chart with
one data point per minute. So even if you charts are different, ChartDirector will not
automatically assume it is a new chart.

In the "XY Zooming and Scrolling" sample code, the code is designed to set the full range
based on the first chart. All subsequent charts will be based on the full range of the first
chart. If you want to change to reset the full range, you may use:

viewer->setFullRange("x", 0, 0);
viewer->setFullRange("y", 0, 0);

In the "Simple Zooming and Scrolling", the full range is provided by the code using viewer-
>setFullRange(....). To change the full range, simply call the setFullRange again with
different values. Because an axis must have a non-zero range (the minValue and maxValue
must be different), if you call setFullRange with minValue and maxValue being equal (eg.
both being 0), the setFullRange will become undefined. In this case, the full range will be
automatically taken from the first chart.

Regards
Peter Kwan

  Re: Question. about relation chartDirector's api ( setChart getChart getMinValue layout)
Posted by jai min lee on Oct-11-2014 08:39
Hi Peter,

Your explanation is complete. Thank you for all these details.

Kind regards,

jai min lee