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

Message ListMessage List     Post MessagePost Message

  how can i get already set chart from chartviewer?
Posted by jay on Jul-21-2017 09:25
this question is related to my previous question below.
(http://www.chartdir.com/forum/download_thread.php?site=chartdir&bn=chartdir_support&thread=1500506530)

i made a Simple XYChart then set title, add layer and data.
after ChartViewer.setChart(), my XYChart displayed well and I released my XYChart (delete XYChart)

my problem starts here.

if i want to chage the title of chart or add a line data in current chart, how can i do that?

after ChartViewer.setChart(), i tried to not delete my XYChart.

I changed title, and added linedata to my XYChart.

then I ChartViewer.setChart() again, but chart viewer changes nothing.

this makes me crazy. please help me.

how can i solve my problem?

  Re: how can i get already set chart from chartviewer?
Posted by Peter Kwan on Jul-22-2017 00:05
Hi Jay,

You can change anything you like in the chart by just drawing another chart.

For example, if you want to change the chart title, the code is like:

std::string myChartTitle = "ABC";

void drawChart()
{
    XYChart *c = new XYChart(....);
    c->addTitle(myChartTitle.c_str());
    ......

    m_ChartViewer.setChart(c);
    delete c;
}

When the user changes the chart title, you can use:

myChartTitle = "... new title...";
drawChart();


The above method is simple and easy to implement. Basically, you just need to use variables for anything thing you want to change.

For your reference, there is a sample code "Interactive Financial Chart" in which a lot of things can be modified by the user. It is implemented using the above method. You can try it to see how smooth it works.

http://www.advsofteng.com/doc/cdcpp.htm#financedemo.htm

Hope this can help.

Regards
Peter Kwan