Android - ScrollPager and Real Time Data

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Eliana
Newbie
Newbie
Posts: 16
Joined: Tue May 06, 2014 12:00 am

Android - ScrollPager and Real Time Data

Post by Eliana » Fri May 30, 2014 1:12 pm

Hi,

I’m using Teechart Java Android source code v3.2013.1219.

I'm having some issues presenting real time data using a Bar chart along a scroll pager.
I have modified the class WIFIStatistics in the Android teechart sample to present what I'm trying to achieve.
As you can see in the attached file, when pressing the "Start scan" button, a timer is initialized to retrieve data for a few times, representing the case where a real time data flow would need
to update the graphs.
WIFIStatistics.rar
(2.48 KiB) Downloaded 1226 times
1. Issue to update the subchart

The main chart is updated without any issue. However, in order to update the subchart I ended using the following code( after a lot of tries with other functions that
did not update the subchart)

Code: Select all

// Remove series from the scroll pager
ScrollPager s = (ScrollPager)chart.getTools().getTool(0);
				
if (s != null) {
	TChart scrollPagerChart = s.getSubChartTChart();
					
	scrollPagerChart.removeAllSeries();
	s.setSeries(null);
}
Although the subchart is updated, it creates a flickering effect which I would like to avoid and have a smooth update as the update of the main chart.

How can I achieve it?


2. Issue to configure and retain state of the subchart's colorband

I need to support the following case:

a. Initially, the colorband is drawn at the default position (middle of x axis)
b. If the user changes the position or the size of the colorband, while the charts are updated in real time, the colorband should be drawn at the new position and its size
should be updated accordingly.

I tried different functions from the library and tried to implement relevant events to accomplish this, however, unsuccessfully.

Currently, the code used in the attached sample uses the default configuration of the colorband each time it gets updated. If you try to move the colorband while
the subgraph is updated, you will get an exception.


Could you please provide some sample code how to retain the colorband's position and size and also avoid the exception?
This feature is very important for the functionality I'm implementing.


Thank you in advance,
E.

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Android - ScrollPager and Real Time Data

Post by Yeray » Fri May 30, 2014 4:13 pm

Hello Eliana,
Eliana wrote:1. Issue to update the subchart

The main chart is updated without any issue. However, in order to update the subchart I ended using the following code( after a lot of tries with other functions that
did not update the subchart)

Code: Select all

// Remove series from the scroll pager
ScrollPager s = (ScrollPager)chart.getTools().getTool(0);
				
if (s != null) {
	TChart scrollPagerChart = s.getSubChartTChart();
					
	scrollPagerChart.removeAllSeries();
	s.setSeries(null);
}
Although the subchart is updated, it creates a flickering effect which I would like to avoid and have a smooth update as the update of the main chart.

How can I achieve it?
It works fine for me if I change your code for this:

Code: Select all

			// Remove series from the scroll pager
			ScrollPager s = (ScrollPager)chart.getTools().getTool(0);
			
			if (s != null) {
				TChart scrollPagerChart = s.getSubChartTChart();
				
				/*scrollPagerChart.removeAllSeries();
				s.setSeries(null);*/
				
				Series series = availableNetworks.cloneSeries();
				series.setChart(null);
				scrollPagerChart.removeAllSeries();
				scrollPagerChart.getSeries().add(series);
			}
Eliana wrote:2. Issue to configure and retain state of the subchart's colorband

I need to support the following case:

a. Initially, the colorband is drawn at the default position (middle of x axis)
b. If the user changes the position or the size of the colorband, while the charts are updated in real time, the colorband should be drawn at the new position and its size
should be updated accordingly.

I tried different functions from the library and tried to implement relevant events to accomplish this, however, unsuccessfully.

Currently, the code used in the attached sample uses the default configuration of the colorband each time it gets updated. If you try to move the colorband while
the subgraph is updated, you will get an exception.


Could you please provide some sample code how to retain the colorband's position and size and also avoid the exception?
This feature is very important for the functionality I'm implementing.
If I understood in correctly, the change suggested above also makes this to work as you want.
Note the ScrollPager setSeries function calls some functions to set the layout of both the superior and the inferior charts.
The way I've done it, you are just avoiding the layout&aspect&colorband settings. Note they have already been called at the example startup, so it is not needed any more.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Eliana
Newbie
Newbie
Posts: 16
Joined: Tue May 06, 2014 12:00 am

Re: Android - ScrollPager and Real Time Data

Post by Eliana » Mon Jun 02, 2014 7:14 am

Hi Yeray,

Thanks for the change and the great support, it has solved my issues but I need some further assistance on the second issue.

I need to save the position/size of the colorband and propagate it in case configuration changes. This is for the case where you change the orientation of the device.
So, if the user is using landscape view and has moved/resized the subchart's panel, I would like to retain the updated position/size of the colorband at the portrait view.
I tried to configure the dragFinished event and then call the getStartLine and getEndlLine on the colorband but unsuccessfully. It seems that I have not configured the event correctly (how do you register the draglistener and where? on the scrollpager or on the colorband?) or I should have used something else to achieve what I want.

Could you please provide me with some sample code?

Also, I tried to set a legend below the subchart, however it does not show it. Is it possible to show a legend below the main chart or the subchart?

Thanks,
E.

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Android - ScrollPager and Real Time Data

Post by Yeray » Mon Jun 02, 2014 11:08 am

Hello Eliana,
Eliana wrote:I need to save the position/size of the colorband and propagate it in case configuration changes. This is for the case where you change the orientation of the device.
So, if the user is using landscape view and has moved/resized the subchart's panel, I would like to retain the updated position/size of the colorband at the portrait view.
I tried to configure the dragFinished event and then call the getStartLine and getEndlLine on the colorband but unsuccessfully. It seems that I have not configured the event correctly (how do you register the draglistener and where? on the scrollpager or on the colorband?) or I should have used something else to achieve what I want.

Could you please provide me with some sample code?
You could use onSaveInstanceState to store the state of the ColorBand Start and End values. Ie:

Code: Select all

	protected void onSaveInstanceState(Bundle outState) {
		if (chart.getTools().getTool(0).getClass() == ScrollPager.class) {
			ScrollPager s = (ScrollPager)chart.getTools().getTool(0);
			outState.putDouble("storedStart", s.getColorBandTool().getStart());
			outState.putDouble("storedEnd", s.getColorBandTool().getEnd());
		}
	}
Then, you should restore the saved settings at onCreate. However, the particularities of the ScrollPager tool gives some extra problems here.
If you try to set the stored properties at onCreate, after creating the ScrollPager tool:

Code: Select all

		//Add the scroll pager
		ScrollPager scrollPg = new ScrollPager(chart.getChart(), this);
		
		if (savedInstanceState!=null) {
			scrollPg.getColorBandTool().setStart(savedInstanceState.getDouble("storedStart"));
			scrollPg.getColorBandTool().setEnd(savedInstanceState.getDouble("storedEnd"));
		}
The above doesn't work fine, because after changing the screen orientation everything is recreated, so the program will enter in the "if (s.getSeries() == null) " in "chartPainted", the s.setSeries() method will be called, and this method is resetting the ColorBand Start and End values to show the ColorBand in the center of the series by default.
Then, I finally declared a general Bundle:

Code: Select all

	private Bundle savedState;
And used it to store the savedInstanceState at onCreate, and use it at chartPainted event, once the s.setSeries is being called:

Code: Select all

		//Add the scroll pager
		ScrollPager scrollPg = new ScrollPager(chart.getChart(), this);
		
		if (savedInstanceState!=null) {
			savedState = savedInstanceState;
			//scrollPg.getColorBandTool().setStart(savedInstanceState.getDouble("storedStart"));
			//scrollPg.getColorBandTool().setEnd(savedInstanceState.getDouble("storedEnd"));
		}
	    
    	chart.addChartPaintListener(new ChartPaintAdapter() {
			
			@Override
			public void chartPainted(ChartDrawEvent e) {
				if (chart.getTools().getTool(0).getClass() == ScrollPager.class) {
					ScrollPager s = (ScrollPager)chart.getTools().getTool(0);
					
					if (s.getSeries() == null) {
						
						s.setSeries(chart.getSeries(0));
						
						if (savedState!=null) {
							double tmpStart = savedState.getDouble("storedStart");
							double tmpEnd = savedState.getDouble("storedEnd");
							s.getColorBandTool().setStart(tmpStart);
							s.getColorBandTool().setEnd(tmpEnd);
							chart.getAxes().getBottom().setMinMax(tmpStart, tmpEnd);
						}
						
						TChart scrollPagerChart = s.getSubChartTChart();
												
						scrollPagerChart.getSeries(0).getMarks().setStyle(MarksStyle.VALUE);
						
						ThemesList.applyTheme(scrollPagerChart.getChart(), 1);
					}
				}
			}
		});
Eliana wrote:Also, I tried to set a legend below the subchart, however it does not show it. Is it possible to show a legend below the main chart or the subchart?
setSeries() also sets some aspect properties to the more common settings for a scrollPager (2D, no legend, horizontal zoom,...)
So, if you want to revert any of these settings, you should do it at chartPainted, after the setSeries call. Ie:

Code: Select all

    	chart.addChartPaintListener(new ChartPaintAdapter() {
			
			@Override
			public void chartPainted(ChartDrawEvent e) {
				//...					
					if (s.getSeries() == null) {
						
						s.setSeries(chart.getSeries(0));
						//...
						ThemesList.applyTheme(scrollPagerChart.getChart(), 1);

						chart.getLegend().setVisible(true);
						//...
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Eliana
Newbie
Newbie
Posts: 16
Joined: Tue May 06, 2014 12:00 am

Re: Android - ScrollPager and Real Time Data

Post by Eliana » Tue Jun 03, 2014 8:42 am

Hi Yeray,

Thanks for the support, the code works as expected.

Kind regards,
E.

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Android - ScrollPager and Real Time Data

Post by Yeray » Tue Jun 03, 2014 9:42 am

Hi Eliana,

Thanks for the feedback! :D
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Eliana
Newbie
Newbie
Posts: 16
Joined: Tue May 06, 2014 12:00 am

Re: Android - ScrollPager and Real Time Data

Post by Eliana » Tue Jul 08, 2014 8:43 am

Hi Yeray,

Following the previous conversation on this post, two main issues came up after testing.

1.
When you start playing with the panel of the sub chart and move it beyond the max sub chart axis, sometimes I get the following exception and I need your feedback on how to handle it (I have the src version of the library):

Code: Select all

07-08 10:11:37.037: E/AndroidRuntime(8221): FATAL EXCEPTION: main
07-08 10:11:37.037: E/AndroidRuntime(8221): java.lang.NullPointerException
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.steema.teechart.styles.Series.calcFirstLastVisibleIndex(Series.java:1467)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.steema.teechart.styles.CustomBar.calcFirstLastVisibleIndex(CustomBar.java:873)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.steema.teechart.styles.CustomBar.calcFirstLastVisibleIndex(CustomBar.java:911)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.steema.teechart.axis.AxisDraw.calcFirstLastAllSeries(AxisDraw.java:1105)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.steema.teechart.axis.AxisDraw.axisLabelsSeries(AxisDraw.java:1272)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.steema.teechart.axis.AxisDraw.draw(AxisDraw.java:1479)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.steema.teechart.axis.Axis.draw(Axis.java:3259)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.steema.teechart.axis.Axes.draw(Axes.java:467)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.steema.teechart.Chart.drawAxesSeries(Chart.java:799)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.steema.teechart.Chart.internalDraw(Chart.java:782)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.steema.teechart.Chart.paint(Chart.java:2130)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.steema.teechart.Chart.paint(Chart.java:2146)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.steema.teechart.TChart.onDraw(TChart.java:317)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.draw(View.java:13458)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12409)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12453)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2911)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12345)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12453)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2911)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12345)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12453)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.draw(View.java:13182)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.draw(View.java:13461)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.widget.FrameLayout.draw(FrameLayout.java:467)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.widget.ScrollView.draw(ScrollView.java:1555)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12409)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12453)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2911)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12345)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12453)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2911)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12345)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12453)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2911)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12345)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12453)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2911)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12345)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12453)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2911)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12345)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.View.getDisplayList(View.java:12453)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1144)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.ViewRootImpl.draw(ViewRootImpl.java:2149)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2021)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1832)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4214)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.Choreographer.doCallbacks(Choreographer.java:555)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.Choreographer.doFrame(Choreographer.java:525)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.os.Handler.handleCallback(Handler.java:615)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.os.Handler.dispatchMessage(Handler.java:92)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.os.Looper.loop(Looper.java:137)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at android.app.ActivityThread.main(ActivityThread.java:4745)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at java.lang.reflect.Method.invoke(Method.java:511)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-08 10:11:37.037: E/AndroidRuntime(8221): 	at dalvik.system.NativeStart.main(Native Method)

I tried to use the setNoLimitDrag to true in the chartPainted event in an effort to allow dragging over the chart area, but the exception still occurs.

2. In the case where there is only one bar drawn, the bar shows in the main chart but the subchart does not show.
a) I would like to show the subchart, even with just one bar, and then
b) set the subchart panel location so that it includes this single bar.
How do I achieve this?

Thanks,
Eliana.

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Android - ScrollPager and Real Time Data

Post by Yeray » Thu Jul 10, 2014 2:37 pm

Hi Eliana,
Eliana wrote:1. When you start playing with the panel of the sub chart and move it beyond the max sub chart axis, sometimes I get the following exception and I need your feedback on how to handle it (I have the src version of the library):

[...]

I tried to use the setNoLimitDrag to true in the chartPainted event in an effort to allow dragging over the chart area, but the exception still occurs.
Could you please arrange a simple example project we can run as-is to reproduce the problem here?
Eliana wrote:2. In the case where there is only one bar drawn, the bar shows in the main chart but the subchart does not show.
a) I would like to show the subchart, even with just one bar, and then
b) set the subchart panel location so that it includes this single bar.
How do I achieve this?
This is how it looks for me if I have a single bar:
device-2014-07-10-163616.png
device-2014-07-10-163616.png (28.76 KiB) Viewed 30046 times
Is this the problem you are observing?
Here it is the code I used to get the above:

Code: Select all

		tChart1.getChart().getAspect().setView3D(false);
		tChart1.getChart().getLegend().setVisible(false);

		Bar bar1 = new Bar(tChart1.getChart());
		bar1.setColor(Color.GREEN_YELLOW);
		bar1.fillSampleValues(1);
		bar1.getMarks().setVisible(false);

		ScrollPager scrollPager1 = new ScrollPager(tChart1.getChart(), this);
		
		tChart1.addChartPaintListener(new ChartPaintAdapter() {
			
			@Override
			public void chartPainted(ChartDrawEvent e) {
				if (tChart1.getTools().getTool(0).getClass() == ScrollPager.class) {
					ScrollPager s = (ScrollPager)tChart1.getTools().getTool(0);
					if (s.getSeries() == null) {
						s.setSeries(tChart1.getSeries(0));
						
						TChart scrollPagerChart = s.getSubChartTChart();
						scrollPagerChart.getSeries(0).getMarks().setVisible(false);
						s.getColorBandTool().setDrawBehind(false);
						ThemesList.applyTheme(scrollPagerChart.getChart(), 1);
					}
				}
			}
		});
		
		ThemesList.applyTheme(tChart1.getChart(), 1);
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Eliana
Newbie
Newbie
Posts: 16
Joined: Tue May 06, 2014 12:00 am

Re: Android - ScrollPager and Real Time Data

Post by Eliana » Thu Jul 10, 2014 3:22 pm

Hi Yeray,

Regarding my first issue you can use the the attached class WIFIStatistics and then do the following to reproduce the problem:
1. Press the "Start scan" button ( a timer is initialized to retrieve data for a few times, representing the case where a real time data flow would need to update the graphs)
2. While the graph is updated, move the panel beyond the maximum limit of the subgraph
3. The exception occurs.
WIFIStatistics.rar
(2.88 KiB) Downloaded 1196 times
Regarding the second issue I'm preparing some sample code and I will get back to you soon.

Best regards,
Eliana.

Eliana
Newbie
Newbie
Posts: 16
Joined: Tue May 06, 2014 12:00 am

Re: Android - ScrollPager and Real Time Data

Post by Eliana » Fri Jul 11, 2014 1:48 pm

Hi Yeray,

In addition to my previous post, also please consider this one for my second issue.

I have made a minor change to the previous attached file to re-create my problem with the single bar.
In onCreate I just added to the chart just one bar.
WIFIStatistics.rar
(2.88 KiB) Downloaded 1204 times
As you will see when the wifi statistics activity is launched, the main chart displays a single bar but there is no sub chart.

Please let me know if you need further information in order to provide me with feedback on the reported issues.

Thank you.

Kind regards,
E.

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Android - ScrollPager and Real Time Data

Post by Yeray » Fri Jul 11, 2014 1:57 pm

Hello,

I don't need to drag the colorband while the wifi is being scanned to get an exception. I just need to refresh the wifis while the distance between start and end in the color line is small.
I think there's a moment where the chart is being repainted and there's no series.
To avoid this, you can clear the series at onClick instead of removing&recreating it:

Code: Select all

				//chart.removeAllSeries();
				//availableNetworks = new Bar(chart.getChart());
				availableNetworks.clear();
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Eliana
Newbie
Newbie
Posts: 16
Joined: Tue May 06, 2014 12:00 am

Re: Android - ScrollPager and Real Time Data

Post by Eliana » Mon Jul 14, 2014 8:53 am

Hi Yeray,

Thank you for the feedback.

1. My issue related to the subchart's panel exception has been solved with the proposed modification :) many thanks!!

2. I'm still having issues when a single bar is displayed. Please consider the file I have attached at my previous post in order to reproduce the problem. The following screenshot displays my problem where only the main chart is shown:
single_bar.png
single_bar.png (33.64 KiB) Viewed 29983 times
Please advice how to handle this issue.

3. I'm trying to change the position of the subchart panel under a certain condition. Since the bars are updated dynamically, I need to handle the following case:

a. The subchart displays i.e. 10 bars and the panel location is between the 8th to 10th bar.
b. The subchart is updated and now it shows 5 bars. Since I maintain the last panel location, the panel will not show as its last location is beyond the 5th bar.
c. I need to check if the last panel location is beyond the maximum x subchart axis and if it is, then set the panel location at the beginning of the subchart.

I tried the following code at the chartPainted event, however, the getMaximum always returns 0 so it erroneously re-initializes the panel. Where do I need to perform this check and re-initialize the panel's location? Or do I need to use something else in the chartPainted event?

Code: Select all

if (savedState!=null) {
			
      double tmpStart = savedState.getDouble("storedStart");
      double tmpEnd = savedState.getDouble("storedEnd");
		                
      // check the position of the panel, and if it has exceed the min max limits, then
      // re-initialize its position
      if ((tmpStart <= 0 && tmpEnd <=0) ||
		(tmpStart > s.getSubChartTChart().getAxes().getBottom().getMaximum() && tmpEnd > s.getSubChartTChart().getAxes().getBottom().getMaximum())) {
								
			tmpStart = 0;
			tmpEnd = 1;
	}
													
	s.getColorBandTool().setStart(tmpStart);
        s.getColorBandTool().setEnd(tmpEnd);
        m_Chart.getAxes().getBottom().setMinMax(tmpStart, tmpEnd);
		                    
}
Looking forward for your feedback.

Kind regards,
E.

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Android - ScrollPager and Real Time Data

Post by Yeray » Tue Jul 15, 2014 10:01 am

Hello Eliana,
Eliana wrote:2. I'm still having issues when a single bar is displayed. Please consider the file I have attached at my previous post in order to reproduce the problem. The following screenshot displays my problem where only the main chart is shown:
I've made a simple example project to test this out of the Features demo because I don't ever get a unique bar here.
TeeChartAndroidTest.zip
(678.38 KiB) Downloaded 1129 times
And this is what I get:
device-2014-07-15-110409.png
device-2014-07-15-110409.png (58.23 KiB) Viewed 29945 times
Could you please modify the project above so we can reproduce the problem here?
Eliana wrote:3. I'm trying to change the position of the subchart panel under a certain condition. Since the bars are updated dynamically, I need to handle the following case:

a. The subchart displays i.e. 10 bars and the panel location is between the 8th to 10th bar.
b. The subchart is updated and now it shows 5 bars. Since I maintain the last panel location, the panel will not show as its last location is beyond the 5th bar.
c. I need to check if the last panel location is beyond the maximum x subchart axis and if it is, then set the panel location at the beginning of the subchart.
What about adding some condition after populating the series, and set the ColorBand to the desired position if needed? Ie:

Code: Select all

			            if (((s.getColorBandTool().getStart() < availableNetworks.getXValues().getMinimum()) ||
			                 (s.getColorBandTool().getStart() > availableNetworks.getXValues().getMaximum())) &&
			                ((s.getColorBandTool().getEnd() < availableNetworks.getXValues().getMinimum()) ||
			                 (s.getColorBandTool().getEnd() > availableNetworks.getXValues().getMaximum()))) {
			            	
			            	s.getColorBandTool().setStart(scrollPagerChart.getAxes().getBottom().getMinimum() + (scrollPagerChart.getAxes().getBottom().getRange() / 3));
			            	s.getColorBandTool().setEnd(scrollPagerChart.getAxes().getBottom().getMinimum() + (scrollPagerChart.getAxes().getBottom().getRange() * 2 / 3));
			            }
Eliana wrote:I tried the following code at the chartPainted event, however, the getMaximum always returns 0 so it erroneously re-initializes the panel. Where do I need to perform this check and re-initialize the panel's location? Or do I need to use something else in the chartPainted event?
The chartPainted event is a bit delicate place to put code. We use it to configure the size and position of the subchart because we need the position and size of the main chart for it.
If the code suggested above doesn't fit your needs, we'll be pleased to try to suggest you another solution.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Eliana
Newbie
Newbie
Posts: 16
Joined: Tue May 06, 2014 12:00 am

Re: Android - ScrollPager and Real Time Data

Post by Eliana » Wed Jul 16, 2014 12:38 pm

Hi Yeray,

Thank you for the great support. :D

After having a look at the example project, I have updated the library to the latest version and the issue with the single bar has been solved.
Also, thanks for the code provided regarding the colorband position, it covers the main requirements so no further investigations are needed.

I do have an issue which I don't recall if it happened prior to updating the library. I have modified the sample project you provided to show more bars and reproduce the issue. As you can see in the following screenshot, the mark above the bar at the edge of the main chart appears outside the main chart area and on top of the y axis.

Is there a way to avoid this from happening?
Screenshot_2014-07-16-13-22.png
Screenshot_2014-07-16-13-22.png (37.72 KiB) Viewed 29923 times
Best regards,
E.

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

Re: Android - ScrollPager and Real Time Data

Post by Marc » Fri Jul 18, 2014 2:49 pm

Hello Eliana,

Yes, there seems to have been a problem there. We've made a modification to the TeeChart code to correctly clip Bar Marks outside of the Axis bounds. The change will be included with the next update.

Regards,
Marc Meumann
Steema Support

Post Reply