<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to 1: Refreshing data dynamically</title><link>https://sourceforge.net/p/swt-chart/support-requests/1/</link><description>Recent changes to 1: Refreshing data dynamically</description><atom:link href="https://sourceforge.net/p/swt-chart/support-requests/1/feed.rss" rel="self"/><language>en</language><lastBuildDate>Sun, 11 Jan 2009 15:56:16 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/swt-chart/support-requests/1/feed.rss" rel="self" type="application/rss+xml"/><item><title>Refreshing data dynamically</title><link>https://sourceforge.net/p/swt-chart/support-requests/1/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have a simple question related to the way I could refresh data of a serie dynamically.&lt;/p&gt;
&lt;p&gt;Suppose I have a thread that receive an array of double  a few times per second. The size of the array is for example 1000. What is the best and fastest way to refresh my serie and make sure I will see all arrays in my chart and make sure that the Eclipse IDE won't be freeze by the thread and by the update of the chart?&lt;/p&gt;
&lt;p&gt;I made the following example, but I have several problem with it.&lt;br /&gt;
1- The updates freeze the IDE&lt;br /&gt;
2- The refresh of the serie is pretty slow &lt;br /&gt;
3- The update of the chart starts only at the end of the processing of the array. If i replace the for loop by a infite loop, the UI is freeze infititely&lt;br /&gt;
4- Make sure the IDE have enough cpu to continue to work.&lt;/p&gt;
&lt;p&gt;You can answer me at the following address: &lt;/p&gt;
&lt;p&gt;lapointe_vincent_1975@hotmail.com&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Vincent&lt;/p&gt;
&lt;p&gt;Example (based on LargeSeriesExample.java):&lt;/p&gt;
&lt;p&gt;public class SampleView extends ViewPart {&lt;/p&gt;
&lt;p&gt;public SampleView() {&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;public void createPartControl(Composite parent) {&lt;/p&gt;
&lt;p&gt;final Chart chart = new Chart(parent, SWT.NONE);&lt;/p&gt;
&lt;p&gt;chart.getTitle().setText("Large Series Example");&lt;br /&gt;
chart.getAxisSet().getXAxis(0).getTitle().setText("Data Points");&lt;br /&gt;
chart.getAxisSet().getYAxis(0).getTitle().setText("Amplitude");&lt;/p&gt;
&lt;p&gt;final ILineSeries lineSeries = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE, "line series1");&lt;/p&gt;
&lt;p&gt;lineSeries.setSymbolType(PlotSymbolType.NONE);&lt;br /&gt;
lineSeries.setYSeries(getSeries(0, i));&lt;/p&gt;
&lt;p&gt;// adjust the axis range&lt;br /&gt;
chart.getAxisSet().adjustRange();&lt;/p&gt;
&lt;p&gt;parent.getShell().getDisplay().asyncExec(new Runnable() {&lt;br /&gt;
@Override&lt;br /&gt;
public void run() {&lt;br /&gt;
for (int t=0; t&amp;lt; 100; t++) {&lt;br /&gt;
lineSeries.setYSeries(getSeries((double)t, 0));&lt;br /&gt;
chart.redraw();&lt;br /&gt;
chart.update();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
);&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;private static double[] getSeries(double t, double y) {&lt;br /&gt;
double[] series = new double[1000];&lt;br /&gt;
for (int i = 0; i &amp;lt; series.length; i++) {&lt;br /&gt;
series[i] = y + Math.sin(t + i  * 33 * Math.PI/ series.length) + Math.sin(t + i * 15 * Math.PI/ series.length);&lt;br /&gt;
}&lt;br /&gt;
return series;&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;public void setFocus() {&lt;br /&gt;
// TODO Auto-generated method stub&lt;br /&gt;
}&lt;br /&gt;
}&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Sun, 11 Jan 2009 15:56:16 -0000</pubDate><guid>https://sourceforge.net5889c41093a204d5b001d0d29701e88baa5c53a7</guid></item></channel></rss>