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

Message ListMessage List     Post MessagePost Message

  set mark dynamically
Posted by Lokesh on Oct-31-2013 13:07
Hi,
    I belong to the beginner class programmers, so please forgive if I have wrote anything stupid below.
    I am using ChartDirector in .Net. What I want to do is actually move a mark with the help of a track bar. I couldn't find a way to access already created marks; so I stored the marks into a list when I created them and made the list a member for later access.
Below is the code:

private void drawMarks(MultiChart chrt, double xVal, int colr)
        {
            XYChart xyChrt;
            for (int i = 0; i < chrt.getChartCount(); i++)
            {
                xyChrt = (chrt.getChart(i) as XYChart);
                m_marku.Add(xyChrt.xAxis().addMark(xVal, colr));
                m_marku.Last().setLineWidth(2);
                m_marku.Last().setAlignment(Chart.Left);
            }
        }

Now I set the track bar min and max corresponding to the chart. Following is the scroll event method of the track bar:

private void trckBarTop_Scroll(object sender, EventArgs e)
        {
            if (m_marku != null)
                m_marku.ForEach(i => i.setValue(trckBarTop.Value));
        }

It's not working though. Am I doing something wrong?

  Re: set mark dynamically
Posted by Peter Kwan on Nov-02-2013 01:25
Hi Lokesh,

In ChartDirector, once a chart is drawn (displayed to screen), it cannot be changed. Also, even if you can change the chart, your current method would not work. It just adds additional marks to the chart without removing the old marks. So the track bar will very quickly add a huge number of marks to the chart.

In your case, actually there is a much simplier method. You must have some charting code to create the MultiChart in the first place. In that charting code, please add the marks there, like:


// Your original charting code
void drawChart()
{
      XYChart c1 = .....;
      ....

      // Add the mark there
      c1.addMark(trckBarTop.Value, colr);

      .... display the chart as usual (eg. set to the WinChartViewer).
}


Then your trckBarTop_Scroll code can be simply:

private void trckBarTop_Scroll(object sender, EventArgs e)
{
      drawChart();
}


Hope this can help.

Regards
Peter Kwan

  Re: set mark dynamically
Posted by Lokesh on Nov-05-2013 12:12
Hi Peter,

Sorry for my late reply.

Thank you for your suggestion. That helped a lot. Have a good day.

Regards,
Lokesh