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

Message ListMessage List     Post MessagePost Message

  not refresh the chart
Posted by Virginia on Sep-18-2013 20:44
Hello all,

I have a problem, when i use the function  c.yAxis().setLinearScale(20, 70, 10) actuated by
a button not refresh the chart.

Thank you for your help!

  Re: not refresh the chart
Posted by Peter Kwan on Sep-19-2013 03:03
Hi Virginia,

To change the chart, you would need to redraw the chart. The code structure should be similar to the structure of the "Interactive Financial Chart" sample code. In that sample code, the users can control a lot of things in the chart. In the code, basically, when the user changes anything, the chart is redrawn. There is only one charting subroutine to draw the initial chart and handle all the user changes, so the code is very simple.

For your case, it would be like (as I am not sure of your programming language, I will use C#/Java syntax in the example):


double lowerLimit = 0;
double upperLimit = 100;
double tickInc = 10;

void drawChart()
{
    XYChart c = new XYChart(.........);
    ... create chart as usual ...
    c.yAxis().setLinearScale(lowerLimit, upperLimit, tickInc);
    ... continue code to create and display chart as usual ...
}


Now, when the user clicks a button, you just need to do:

lowerLimit = 20;
upperLimit = 70;
tickInc = 10;
drawChart();


You can see that in the button event handler, no charting code is needed (there is no need to know how to use ChartDirector in the button event handler). So the code structure is clean and simple. All the charting code is in drawChart. You can also very easily create other user interface (such as using a scroll bar) to control the axis scale (by manipulating the lowerLimit, upperLimit and tickInc).


Hope this can help.

Regards
Peter Kwan

  Re: not refresh the chart
Posted by Virginia on Sep-19-2013 19:33
Thanks for your help Peter, but what is making these changes would need sion redrawing
the chart. You know if you can do what I want?

  Re: not refresh the chart
Posted by Virginia on Sep-19-2013 20:09
Thanks for your help Peter, but what is making these changes would need sion redrawing
the chart. You know if you can do what I want?

  Re: not refresh the chart
Posted by Peter Kwan on Sep-19-2013 23:16
Hi Virginia,

Sorry, I did not quite understand what you mean by "would need sion redrawing
the chart." I did not understand what does "sion" mean.

Anyway, when your change the axis scale using setLinearScale, you probably expect the chart to be different because the scale has changed. So the computer must redraw the chart. We only need to determine how the chart is redrawn. Should the chart be redrawn automatically and immediately when setLinearScale is called, or should the chart be redrawn under the control of your code? The performance is almost the same in both cases, because the chart would need to be redrawn anyway.

In ChartDirector, the chart would need to be redrawn under the control of your code. So it is best to create a "drawChart" routine that your code can call to draw and redraw tne chart.

Hope this can help.

Regards
Peter Kwan

  Re: not refresh the chart
Posted by Virginia on Sep-20-2013 00:01
Hi Peter,
Now I understand how to do it, thanks for your help!

Virgina.

  Re: not refresh the chart
Posted by Virginia on Sep-20-2013 00:49
Hi Peter,
Now I understand how to do it, thanks for your help!

Virgina.