How to immediately redraw chart after series changed?

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
Dennis
Newbie
Newbie
Posts: 4
Joined: Fri Mar 13, 2015 12:00 am

How to immediately redraw chart after series changed?

Post by Dennis » Wed Jun 24, 2015 9:48 am

Hi,

I'm using Teechart Java for Android.

There's a case in my app when I need to remove all bars from my chart and display a message instead.

To achieve the described behavior, I use the following steps:
1. I call

Code: Select all

series.clear()
to remove all bars from my chart.
2. I have a ChartPaintAdapter, and in chartPainted() method I use IGraphics3D to draw a message.

The question is that there's a time lag between bars removed and my message is shown. During this lag for some period of time I see just a blank chart with no data and with no message. Only after a second or two the message is shown.
Is it possible to draw a message immediately after series is cleared? How to achieve that?

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

Re: How to immediately redraw chart after series changed?

Post by Yeray » Thu Jun 25, 2015 11:12 am

Hi Dennis,

I don't see any delay with the following simple example, neither drawing text at chartPainted, or with a Toast:

Code: Select all

        tChart1.getAspect().setView3D(false);
        tChart1.getHeader().setVisible(false);
        tChart1.getLegend().setVisible(false);
        
        Bar bar1 = new Bar(tChart1.getChart());
        bar1.fillSampleValues();
        
        Bar bar2 = new Bar(tChart1.getChart());
        bar2.fillSampleValues();

		final ChartPaintAdapter cpa = new ChartPaintAdapter() {
			
			@Override
			public void chartPainted(ChartDrawEvent e) {
				if (tChart1.getSeriesCount() == 0) {
					tChart1.getGraphics3D().textOut(50, 50, "Bars cleared");
				}
			}
		};
		
		tChart1.addChartMouseListener(new ChartMouseAdapter() {
			
			@Override
			public void backgroundClicked(ChartMouseEvent e) {
				tChart1.getSeries().clear();
				
				Toast.makeText(getApplicationContext(), "Bars cleared",
						   Toast.LENGTH_LONG).show();
				
				tChart1.addChartPaintListener(cpa);
			}
		});
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

Dennis
Newbie
Newbie
Posts: 4
Joined: Fri Mar 13, 2015 12:00 am

Re: How to immediately redraw chart after series changed?

Post by Dennis » Thu Jun 25, 2015 12:25 pm

Dear Yeray,

please see an e-mail from me.

Post Reply