views:

1387

answers:

2

Hi I have taken the example from the samples off the microsfot website. The example is the realtime Date&Time for C#. The example works perfectly when using a short distance and basically running it exactly as it is however I need to be able to monitor my graph for atleast 45min-1hour and only then must the values start falling off. What I would like to do is have about 5min watch time and the rest of the plotted graph I would like to be able to scroll back. So below is the area that is the problem. I need to add the scale view in order to set the amount I can see on the graph before it scrolls(Which doesnt work as well), but the moment I make the scale view above 1 none of the X-Axis value labels are inserted and if so then only 1 of them are and no more. The code is a bit messy as this has been very frustrating. Can someone either assist or guide me to a better chart as the support and documentation of this chart is terrible.

private void startTrending_Click(object sender, EventArgs e)
    {
        // Disable all controls on the form
        startTrending.Enabled = false;
        // and only Enable the Stop button
        stopTrending.Enabled = true;            
        // Predefine the viewing area of the chart
        minValue = DateTime.Now;
        maxValue = minValue.AddMinutes(120);           
        chart1.ChartAreas[0].AxisX.Minimum = minValue.ToOADate();
        chart1.ChartAreas[0].AxisX.Maximum = maxValue.ToOADate();

        // Reset number of series in the chart.
        chart1.Series.Clear();

        // create a line chart series
        Series newSeries = new Series("Series1");
        newSeries.ChartType = SeriesChartType.Line;
        newSeries.BorderWidth = 2;
        newSeries.Color = Color.OrangeRed;
        newSeries.XValueType = ChartValueType.Time;           
        chart1.Series.Add(newSeries);            
        /*chart1.ChartAreas[0].AxisX.LabelStyle.Format = "hh:mm";
        chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Minutes;
        chart1.ChartAreas[0].AxisX.Interval = 1;
        chart1.ChartAreas[0].AxisX.MajorGrid.Interval = 1;
        chart1.ChartAreas[0].AxisX.MajorTickMark.Interval = 0.5; 
        chart1.ChartAreas[0].AxisX.  */          
        chart1.ChartAreas[0].AxisX.ScrollBar.Enabled = true;
        chart1.ChartAreas[0].AxisX.ScaleView.SizeType = DateTimeIntervalType.Minutes;
        chart1.ChartAreas[0].AxisX.ScaleView.Size = 1;
        chart1.ChartAreas[0].CursorX.Interval = 0;

        // start worker threads.
        if (addDataRunner.IsAlive == true)
        {
            addDataRunner.Resume();
        }
        else
        {
            addDataRunner.Start();
        }
    }
A: 

I recommend the open source, and awesome, WPF Dynamic Data Display library from MS Research.

It comes with a bunch of sample projects, one of which you can probably tailor to meet your needs.

Winston Smith
A: 

Switched to a chart called TeeChart. Got to pay for it, but definitely worth it. Been battling for a couple days on MSChart. Did the exact same thing in TeeChart in 30mins.

Warren