JFreeChart - How to show real-time on the X-Axis of a TimeSeries chart and keep datas
<p>I am new to JFreeChart. </p>

<p>I'd like to change <a href="https://stackoverflow.com/questions/21299096/jfreechart-how-to-show-real-time-on-the-x-axis-of-a-timeseries-chart">the code of Trashgod</a> to monitor something in Java. So I need to:</p>

<p>1 - Keep all datas shown. His code keeps only the last 10 samples.</p>

<p>2 - Having a variable scale on X-axis : </p>

<ul>
<li><p>Having an int input howManyDays (or something like an int input, something a little bit clever would be great ;-) ) : int howManyDays = 7;//in this case : 1 week of datas</p></li>
<li><p>Having a variable scale on X-axis a little bit complex : For example during the first seconds of execution it has for scale 1 minute. Then 10 minutes... When midnight has been passed, it should print the current day. </p></li>
</ul>

<p>I know that this instruction</p>

<pre><code>      Timer timer = new Timer(100, new ActionListener()
</code></pre>

<p>means that every 100 ms it adds a new data and then it updates the chart. I'll change it to 10 000 -> 10 seconds. My Timer for testing JFreeChart :</p>

<pre><code>            Timer timer = new Timer(10000, new ActionListener() {
                private int i,data;
                @Override
                public void actionPerformed(ActionEvent e) {
                    if ((i%10)==0) {
                        this.data += (int) Math.ceil(2*Math.random());
                    }
                    this.i++;
                    chart.update(this.data);
                }
            });
</code></pre>

<p>Of course I don't need the solution.</p>

<p>What do I really need :</p>

<ul>
<li>Maybe if someone could add comment on Trashgod's code ?</li>
<li>Or if someone could give me some tricks for doing this kind of code ?</li>
<li>Or maybe someone has already done something like that ?</li>
</ul>

<p>Have a good day !</p>