English 中文(简体)
MS Chart Scaleview & Threading
原标题:

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();
        }
    }
问题回答

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.

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.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签