FillRegion tool with sampled points

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

FillRegion tool with sampled points

Post by asupriya » Mon Apr 16, 2012 10:24 am

I have a T-chart with FillRegion tool. How can make sure that the fill region uses only the data points that are fed to the series, and NOT the ones interpolated between the actual data points.

Thanks and best regards,

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: FillRegion tool with sampled points

Post by Sandra » Tue Apr 17, 2012 11:18 am

Hello asupriya,

I am not sure understand well as you want achieve, but I think would be very helpful for you, use SeriesBandTool instead of SeriesRegionTool as do in next code:

Code: Select all

 public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        private Steema.TeeChart.Styles.Line line1,line2;
        private Steema.TeeChart.Functions.Smoothing smoothing1;
        private Steema.TeeChart.Tools.SeriesBandTool BandTool;
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;

            line1 = new Line(tChart1.Chart);
            line2 = new Line(tChart1.Chart);
            smoothing1 = new Smoothing();
            line1.Add(new int[] { 4, 9, 5, 7, 2, 12, 15 });
            line1.Color = Color.YellowGreen;
            line2.DataSource = line1;
            line2.Function = smoothing1;
            line2.Color = Color.BlueViolet;
            //Smoothing
            smoothing1.Factor = 4;
            smoothing1.Period = 1;
            smoothing1.Interpolate = true;
            //ColorBand
           BandTool  = new SeriesBandTool(tChart1.Chart);
           BandTool.Series = line2;
           BandTool.Series2 = line1;
           BandTool.Brush.Color = Color.Green;
           BandTool.Brush.Transparency = 50;           
        }
Can you tell us if previous code works as you expect?

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Re: FillRegion tool with sampled points

Post by asupriya » Wed Apr 18, 2012 10:12 am

Series band tool is not the solution we are looking for. SeriesBand fills the whole chart area. What we need is the ability to fill-in the region covered by the fastline series such that the lines are drawn only with the help of actual data points added to fastline series.

For example, if the actual data added to fastline series has 12 points (x,y values) per cycle and if the system has a frequency of 60 cycles/sec, then there will be 720 points per second-worth of data. If we plot this data on a graph panel, we like to see only 12 lines (of FillRegion) between peak-peak of a waveform. Currently, we see that the number of lines drawn (of FillRegion) vary based on the width of graph panel. If we resize the graph panel to a width of 600 pixels, we see only two or three lines between the peaks, if the width is set to 1200 or so, the number of lines drawn changes arbitrarily.

My question is: how can i make sure that the number of lines drawn of FillRegion tool always correspond to the actual datapoints loaded with the series.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: FillRegion tool with sampled points

Post by Sandra » Thu Apr 19, 2012 8:38 am

Hello asupriya,

Thanks for information, but would be very helpful for us if you could arrange a simple example for us where we can reproduce your problem, because we can try to find a good solution for you.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Re: FillRegion tool with sampled points

Post by asupriya » Sat Apr 21, 2012 6:45 am

Attached is the VS2008 project with its own input data. This input data is collected at 720 samples/second (with 12 samples per cycle and a frequency of 60 cycles/sec).

The attached screenshot below shows that there are too many vertical lines drawn for 12 actual points in a cycle.
1.png
1.png (46.65 KiB) Viewed 11046 times
My question is, how can I make sure that the vertical lines in a cycle truly correspond to the data fed to the series?

Thanks for your help.
Attachments
SampleTeeCart.zip
(301.53 KiB) Downloaded 518 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: FillRegion tool with sampled points

Post by Narcís » Mon Apr 23, 2012 10:05 am

Hi asupriya,

Thanks for the info.

The vertical lines shown in your image are those corresponding to the SeriesRegionTool brush pattern you chose:

Code: Select all

            srgn.Brush.Style = System.Drawing.Drawing2D.HatchStyle.Vertical
SeriesRegionTool.Brush inherits from System.Drawing.Brush and its Style property is a System.Drawing.Drawing2D.HatchStyle enum value.

Having that in mind, System.Drawing.Brush and System.Drawing.Drawing2D.HatchStyle knows nothing from SeriesRegiontool and TeeChart series. The only option I can think of to achieve what you request is using an Area series with visible area lines, for example:

Code: Select all

    Private Sub DisplayBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisplayBtn.Click
        Try
            'Dim sBandTool As New Steema.TeeChart.Tools.SeriesBandTool
            'sBandTool.Series = FastLine1
            'GraphChart.Tools.Add(sBandTool)
            GraphChart.Aspect.View3D = False
            GraphChart.Header.Text = "Graph"
            GraphChart.Zoom.Direction = Steema.TeeChart.ZoomDirections.Horizontal
            ' FastLine1.Clear()
      'FastLine1.DrawAllPoints = False
      ''FastLine1.DrawAllPointsStyle = Steema.TeeChart.Styles.DrawAllPointsStyle.MinMax
      'FastLine1.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint
      'FastLine1.LinePen.Width = 1
      'FastLine1.LinePen.Style = Drawing2D.DashStyle.Solid
      GraphChart.Series.RemoveAllSeries()

      Dim Area1 As New Steema.TeeChart.Styles.Area
      GraphChart.Series.Add(Area1)
      Area1.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint
      Area1.Color = Color.Transparent
      Area1.UseOrigin = True
      Area1.Origin = 0

            Dim txtReader As New System.IO.StreamReader("..\..\input.txt")
            Dim tmpStr As String()
            While Not txtReader.EndOfStream
                tmpStr = Split(txtReader.ReadLine, ",")
        Area1.Add(CDbl(tmpStr(0)), CDbl(tmpStr(1)))
            End While
            txtReader.Close()

            'add a series region tool
            Dim srgn As New Steema.TeeChart.Tools.SeriesRegionTool
      srgn.Series = Area1 'FastLine1
            srgn.Active = True
            srgn.UseOrigin = True
            srgn.Brush.Style = System.Drawing.Drawing2D.HatchStyle.Vertical
            'set brush transparency
            srgn.Brush.Transparency = 100
            'disabling pen
            srgn.Pen.Visible = False
            'set Foreground color
            srgn.Brush.ForegroundColor = FastLine1.Color

      'GraphChart.Tools.Add(srgn)
            
        Catch ex As Exception

        End Try
    End Sub
Obviously, Area series lacks the DrawAllPoints functionality. In which case you should use the DownSampling function as in the All Features\Welcome !\Functions\Extended\Reducing number of points\DownSampling Additions example at the features demo, which is available at TeeChart's program group.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Re: FillRegion tool with sampled points

Post by asupriya » Mon Apr 23, 2012 11:31 am

Narcis,

Area series is not a feasible solution for us. FastLine series itself is not fast enough for our data volumes and area series is out question.

One related question I have is that the issues posted herelong ago shows that the vertical lines are dependent on the series data. How is it so if the brush is not aware of the data source?

Thanks

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: FillRegion tool with sampled points

Post by Narcís » Mon Apr 23, 2012 11:51 am

Hi asupriya,
Area series is not a feasible solution for us. FastLine series itself is not fast enough for our data volumes and area series is out question.
In that case the only solution I can think is that you create your custom series inheriting from FastLine series and overriding relevant drawing methods, eg.: DrawValue method. Please bear in mind that drawing more elements into a FastLine series you'll slow it down. To improve your project's performance I strongly recommend you to read the Real-time Charting article here. If that's not enough for your needs you may also consider using TeeChart.Direct2D.dll. Last but not least, you'll find custom series examples here:

http://www.teechart.net/support/viewtopic.php?t=4309
http://www.teechart.net/support/viewtop ... f=4&t=6590
One related question I have is that the issues posted here long ago shows that the vertical lines are dependent on the series data. How is it so if the brush is not aware of the data source?
This is an issue (TF02014468) with FastLine series when DrawAllPoints is set to false and SeriesRegionTool but there's no mention that tool's brush is linked to series data. As you can see in the screen-shots in the thread you pointed at, SeriesRegionTool draws more brush pattern lines there than points are in the series, the same issue discussed in this thread.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Marc
Site Admin
Site Admin
Posts: 1265
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: FillRegion tool with sampled points

Post by Marc » Mon Apr 23, 2012 12:39 pm

Hello,

You could run this code in the Chart's OnAfterDraw event, worth checking how it fairs in performance terms. You do not need the SeriesRegion Tool in the chart to obtain the vertical lines:

Code: Select all

        private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            if (tChart1[0].Count > 0)
                for (int i = tChart1[0].FirstDisplayedIndex(); i <= tChart1[0].LastDisplayedIndex(); i++)
                {
                    g.Line(tChart1[0].CalcXPosValue(tChart1[0].XValues[i]), tChart1[0].CalcYPosValue(tChart1[0].YValues[i]),
                        tChart1[0].CalcXPosValue(tChart1[0].XValues[i]), tChart1.Axes.Left.CalcYPosValue(0));
                }
        }
Regards,
Marc Meumann
Steema Support

Post Reply