How to Smooth 3D graph data

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
vishwa
Newbie
Newbie
Posts: 33
Joined: Mon Oct 15, 2007 12:00 am

How to Smooth 3D graph data

Post by vishwa » Wed Nov 23, 2011 7:17 am

Hi,
We are using TeeChart in our project to show data in 3D mode. The data shown is like spikes. We are using surface.Add(....) function of class Steema.TeeChart.Styles.Surface . Our requirement is to show data smoothly; ie instead of spikes it should show data in transitional way. I have attached following screen shots for you kind reference.
1.) TeeChartSpikes.png [This is how TeeChart implementation looks, it shows data in spikes.]
2.) CWGraph3D-SmoothGraph.png [We want data shown in teechart should appear like this screen shot. Here data representation is smooth and not in spikes. This graph uses control CWGraph3D]

I am using TeeChart version 3.5.3146.24805. Please let me know the option available to achieve data smoothness with mentioned TeeChart version.

Thanks in advance
Attachments
CWGraph3D-SmoothGraph.png
Smooth Data in control CWGraph3D
CWGraph3D-SmoothGraph.png (99.38 KiB) Viewed 4640 times
TeeChartSpikes.png
Spiked Data in TeeChart
TeeChartSpikes.png (62.96 KiB) Viewed 4641 times

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

Re: How to Smooth 3D graph data

Post by Sandra » Wed Nov 23, 2011 3:05 pm

Hello vishwa

I think that would be very helpful for you, take a look in the demo project, concretely in the sample All features\Welcome !\Chart styles\Extended\Surface\Surface Smoothing. Where you find an example that allow you achieve as you want. On the other hand, you need know that if you have a lot of values in your series, your speed may be decrease, so I recommend too, see the link, concretely in the real-time Charting article, where you find information how you have do to improve your performance.

I hope will helps.

Thank,
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

vishwa
Newbie
Newbie
Posts: 33
Joined: Mon Oct 15, 2007 12:00 am

Re: How to Smooth 3D graph data

Post by vishwa » Tue Nov 29, 2011 1:07 pm

Hi,
Thanks for same day reply. The method you mentioned gives "Index out of bounds exception" in our case. As an alternative I am thinking is it possible to show surface data in transitional color as such:
Suppose I have defined color range red, green, blue, yellow, white and corresponding value range 1, 2, 3, 4, 5.
Now suppose in surface I want to add a point with value 3 so it should show all colors transitionally form red to green to blue.
If I plot a point with value 1 then it's color will be red only because there is no lower value and color range defined for this.
If I plot a point with value 5 then while reaching from 1 to 5 it should show all defined color corresponding to value range.

This also will gives smoothing effect to the graph.
Please let me know is it possible to do this in TeeChart surface series. Please tell me the examples also.

As a refrence I have seen this effect in TeeChart demo in Welcome !\Chart styles\Standard\Area\Gradient but here it is done only with 3 color [StartColor, MidColor, EndColor] option in Area series. I want similar effect with multiple colors for surface series.

Please let me know any possibilty.
Thanks a lot

vishwa
Newbie
Newbie
Posts: 33
Joined: Mon Oct 15, 2007 12:00 am

Re: How to Smooth 3D graph data

Post by vishwa » Thu Dec 01, 2011 7:19 am

Hi Sandra,
I tried your suggestion to implement smoothing in 3D chart using method SmoothGrid3D of class TeeSmoothGrid3D . This code I took from the location you pointed out: All features\Welcome !\Chart styles\Extended\Surface\Surface Smoothing

Unfortunatly even after handling all cases it throws an unhandled exception immediatly after calling the smoothing code. Stack trace of error is following:

************** Exception Text **************
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Steema.TeeChart.Styles.Custom3DGrid.FillIrregularGrid(Int32 startIndex, Int32& xCount, Int32& zCount, Double minX, Double minZ)
at Steema.TeeChart.Styles.Custom3DGrid.FillGridIndex(Int32 StartIndex)
at Steema.TeeChart.Styles.Custom3DGrid.DoBeforeDrawChart()
at Steema.TeeChart.Chart.InternalDraw(Graphics g, Boolean noTools)
at Steema.TeeChart.Chart.InternalDraw(Graphics g)
at Steema.TeeChart.TChart.Draw(Graphics g)
at Steema.TeeChart.TChart.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Just an update I'm calling this code after checking IsHandleCreated or not.

Please help me finding out a suitable solution for smoothing of data without any problem.
Thanks a lot

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

Re: How to Smooth 3D graph data

Post by Sandra » Thu Dec 01, 2011 11:41 am

Hello vishwa,

I have very grateful if you can send us a simple project so we can reproduce your problem exactly here and try to find a 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

vishwa
Newbie
Newbie
Posts: 33
Joined: Mon Oct 15, 2007 12:00 am

Re: How to Smooth 3D graph data

Post by vishwa » Thu Dec 01, 2011 2:58 pm

Hi Sandra,
I'm attaching project which has issue in data smoothing [test2.zip] for your kind reference.

Steps to Reproduce Error:
Click on 'Smooth' button, immediatly it will throw following exception

"Index was outside the bounds of the array."
at Steema.TeeChart.Styles.Custom3DGrid.FillIrregularGrid(Int32 startIndex, Int32& xCount, Int32& zCount, Double minX, Double minZ)
at Steema.TeeChart.Styles.Custom3DGrid.FillGridIndex(Int32 StartIndex)
at Steema.TeeChart.Styles.Custom3DGrid.FillGridIndex()
at ACM_Smoothing.Form1.button3_Click(Object sender, EventArgs e) in D:\Mahesh\Testing\ACM-Smoothing\ACM-Smoothing\Form1.cs:line 386
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at ACM_Smoothing.Program.Main() in XXXXXXXXX\Testing\ACM-Smoothing\ACM-Smoothing\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Note:
Please add TeeChart dll version [3.5.3146.24805] reference. Application Startup may take a little lnoger as data used is large in size[700 KB] . This is same data which is used in our project.

Please let me know the available or planned fix.

Thanks a lot
Attachments
test2.zip
TeeChart Crash on Data Smoothing
(461.77 KiB) Downloaded 154 times

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

Re: How to Smooth 3D graph data

Post by Sandra » Fri Dec 02, 2011 3:34 pm

Hello vishwa,

Ok. I can see that you doesn't use last build of TeeChart.Net version 3, I am using this version (3.5.3700.30574) and your exception doesn't appear for me. Please update your version of TeeChart.net and try again if your problem persist. If exception still appears please let me know.

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

vishwa
Newbie
Newbie
Posts: 33
Joined: Mon Oct 15, 2007 12:00 am

Re: How to Smooth 3D graph data

Post by vishwa » Wed Dec 14, 2011 5:14 am

Hi Sandra,
I confirm that with TeeChart version [3.5.3700.30574] crash did not happen while implementing smoothing. But after implementing this my application became very slow. For that you pointed out me to link http://www.teechart.net/reference/articles/index.php .But method mentioned here seems helpful in 2D graph.
Please can you let me know methods to use in 3D graph also to make application faster after implementing smoothing.
Also please reply the question asked in previous post about possibility of passing multiple colors and data range to surface series to get color transition effect.
[As a refrence I have seen this effect in TeeChart demo in Welcome !\Chart styles\Standard\Area\Gradient but here it is done only with 3 color [StartColor, MidColor, EndColor] option in Area series. I want similar effect with multiple colors for surface series.]

Thanks for your help

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

Re: How to Smooth 3D graph data

Post by Sandra » Wed Dec 14, 2011 4:56 pm

Hello vishwa,
I confirm that with TeeChart version [3.5.3700.30574] crash did not happen while implementing smoothing. But after implementing this my application became very slow. For that you pointed out me to link http://www.teechart.net/reference/articles/index.php .But method mentioned here seems helpful in 2D graph.
Please can you let me know methods to use in 3D graph also to make application faster after implementing smoothing.
You can check do something as do the sample All Features\Welcome !\Chart styles\Extended\Surface\Surface Smoothing when check the More Speed checkBox? So I think it can help you to improve your speed.
Also please reply the question asked in previous post about possibility of passing multiple colors and data range to surface series to get color transition effect. [As a refrence I have seen this effect in TeeChart demo in Welcome !\Chart styles\Standard\Area\Gradient but here it is done only with 3 color [StartColor, MidColor, EndColor] option in Area series. I want similar effect with multiple colors for surface series.]
Ok. Can you try to check if without NaN and UseColorRange = true appears the same effect that example Welcome !\Chart styles\Standard\Area\Gradient ? So I think the problem is when you add the NaN values.

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

vishwa
Newbie
Newbie
Posts: 33
Joined: Mon Oct 15, 2007 12:00 am

Re: How to Smooth 3D graph data

Post by vishwa » Thu Dec 15, 2011 3:26 pm

Hi Sandra,
Thanks for your help but it may not be feasible in our case to hide many important things to make smoothing faster.
Coming to color tansition my requirement is I want to pass range values and colors as per following table:
0 yellow
1 green
2 cyan
3 blue
4 red


Now after adding data to surface series; if data value is 0 it should show yellow; if it is 1 then it should that value in color transition going from yellow to green.
Similary if data value is 4 it should show that value in such a way so that we can see all color from yellow to green, cyan, blue, red in transitional way.
[Please refer attached bitmap for refrence. Here control used is CWGraph3D. ]

Can you please let me know if same effect is possible in TeeChart also for surface series ?] I hope I'm able to explain my problem. Please let me know for any other inputs.

Thanks.
Attachments
ColorTransition.png
Color Traansition in CWGraph3D
ColorTransition.png (89.41 KiB) Viewed 4446 times

vishwa
Newbie
Newbie
Posts: 33
Joined: Mon Oct 15, 2007 12:00 am

Re: How to Smooth 3D graph data

Post by vishwa » Fri Dec 16, 2011 6:44 am

Hi Sandra,
The code provided by you to implement smoothing makes my application non-responsive and that code itself takes approx 3.5- 4 seconds. To interact with the application I must kill the process. Also after putting the code to make it faster [hiding axis and wall] I got exception caused by code

Code: Select all

surface.FillGridIndex(); 
This code is being called immediatly after

Code: Select all

TeeSmoothGrid3D.SmoothGrid3D(surface);
The exception says:
Index was outside the bounds of the array.
at Steema.TeeChart.Styles.Custom3DGrid.SearchValue(Int32& aCount, Double[] values, Double aValue)
at Steema.TeeChart.Styles.Custom3DGrid.FillIrregularGrid(Int32 startIndex, Int32& xCount, Int32& zCount, Double minX, Double minZ)
at Steema.TeeChart.Styles.Custom3DGrid.FillGridIndex(Int32 StartIndex)
at Steema.TeeChart.Styles.Custom3DGrid.FillGridIndex()

This happened with TeeChart version [3.5.3700.30575]. Please let me know suitable faster smoothing method asap as issue is critical to our project release.

Please provide your inputs.
Thanks

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

Re: How to Smooth 3D graph data

Post by Sandra » Mon Dec 19, 2011 1:08 pm

Hello vishwa,

Sorry for the delay. About your question of range I suggest you two options use property UseColorRange=true and adding the StartColor,MiddleColor and EndColor as do in next attached example. And also, you can add specific color for each point. In this option when you do smooth in the Surface, you need save the colors and assign in the smoothed series.
SurfaceTest.zip
(20.66 KiB) Downloaded 166 times
Can you tell us if previous suggestions, help you to achieves as you want do?

On the other hand, about the slow speed, I am afraid that there aren't a optimal solution about it so when you running higher numbers of cells, that is, incrementing the private const MaxAllowedCells, causes your code to execute without an error but makes for an application that is so slow to paint that it is impracticable. I recomend take a look in this link where explain which is the better solution and because the chart is slow. On the other hand, we follow work to increase the performance of our series for it have a optimal result for our client.
The code provided by you to implement smoothing makes my application non-responsive and that code itself takes approx 3.5- 4 seconds. To interact with the application I must kill the process. Also after putting the code to make it faster [hiding axis and wall] I got exception caused by code
CODE: SELECT ALL
surface.FillGridIndex();
This code is being called immediatly after
CODE: SELECT ALL
TeeSmoothGrid3D.SmoothGrid3D(surface);

The exception says:
Index was outside the bounds of the array.
at Steema.TeeChart.Styles.Custom3DGrid.SearchValue(Int32& aCount, Double[] values, Double aValue)
at Steema.TeeChart.Styles.Custom3DGrid.FillIrregularGrid(Int32 startIndex, Int32& xCount, Int32& zCount, Double minX, Double minZ)
at Steema.TeeChart.Styles.Custom3DGrid.FillGridIndex(Int32 StartIndex)
at Steema.TeeChart.Styles.Custom3DGrid.FillGridIndex()
This happened with TeeChart version [3.5.3700.30575]. Please let me know suitable faster smoothing method asap as issue is critical to our project release.
I can not reproduce your exception here using last version 3 and version 4 and your example code and please take a look in previous link that can help you to solve your problem.

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

Post Reply