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

Message ListMessage List     Post MessagePost Message

  is only way re create chart for update the values ?
Posted by Burak Yeler on Jul-08-2023 20:45
Attachments:
I cant find any way for the change value of the angular meter properly. please help;

following codes has simple angular meter. when i press samplebutton. nothing changes.
how can i update my angular meters efficiently.

//OF course if i create


        double value = 45;
        MeterPointer mp;
        AngularMeter m;

        public MainForm()
        {
            InitializeComponent();

            m = new AngularMeter(200, 200);
            m.setMeter(100, 100, 100, -90, 90);
            m.setScale(0, 100, 20, 10, 5);
            mp = m.addPointer(value, 0xff0000);
            winChartViewer1.Chart = m;
        }



        private void Sample_Button_Click(object sender, EventArgs e)
        {
            value++;
            mp.setPos(value);
            winChartViewer1.updateDisplay(true);
            winChartViewer1.updateViewPort(true,true);
            winChartViewer1.Refresh();
        }
1.JPG

  Re: is only way re create chart for update the values ?
Posted by Burak Yeler on Jul-08-2023 20:46
//of course if i create new angular meter and assing it to viewers chart property it works. but i dont think so this is the right way

  Re: is only way re create chart for update the values ?
Posted by Peter Kwan on Jul-10-2023 12:37
Hi Burak,

Redrawing the entire meter is in fact the correct way to update. It is simply, fast and efficient. All our charts (including real-time charts, are drawn this way.)

The following is an example:

double value = 45;

public MainForm()
{
     InitializeComponent();
     updateMeter();
}

private void updateMeter()
{
    AngularMeter m = new AngularMeter(200, 200);
    m.setMeter(100, 100, 100, -90, 90);
    m.setScale(0, 100, 20, 10, 5);
    m.addPointer(value, 0xff0000);
    winChartViewer1.Chart = m;
}

private void Sample_Button_Click(object sender, EventArgs e)
{
    value++;
    updateMeter();
}


Redrawing everything usually results in simpler code, as you can change anything in the meter (the background color, the labels, etc) by simply changing a parameter and no extra charting code is needed. The code that updates the meter do not need use the ChartDirector API at all, and you can change the meter (eg. change from AngularMeter to LinearMeter or to a bar chart with a single bar) and this would not affect the code that updates the meter.


The reason it is fast is because there is no efficient way to "undraw" things on a picture. If you move the pointer, it is necessary to "undraw" the original pointer. There can be things behind and in front of the pointer. To undraw an object, we must fill the void left behind with these things. For complicated objects, the overhead is high and it may end up faster to just redraw everything.

(You may notice that most computer games always redraw everything no matter what is changed in the game. They described their performance in "frame per second".)

Best Regards
Peter Kwan

  Re: is only way re create chart for update the values ?
Posted by Burak Yeler on Jul-12-2023 03:57
Firstly thanks for your answer.

You're right about the flexibility this method provides. It's the first time I've encountered this style, so I spent hours searching for the error within myself. I'm relieved now and can start my project.