add a line to a chart ( ajouter une ligne sur un graphique )

Discussion about JFreeChart related to stockmarket charts.
Locked
TNT

add a line to a chart ( ajouter une ligne sur un graphique )

Post by TNT » Wed Feb 11, 2004 8:08 pm

HI


I create a jfreechart with many lines, a candelstick .. ( by program )

I whish to know if a can a draw line with my mouse .. inside the graph.
a shape or another things .

like a single application of drawing ..

How can i do ??

Question may i extends our framework or another solution ??

thanks

----------------------

Bonjour a tous

j'ai concu un graphique avec de nombreuses courbes ( graph de bourse ).
je souhaite ajouter une ligne sur le graphique a la souris . un cercle ou un texte ..

Merci.

zorro

Post by zorro » Tue Feb 17, 2004 10:03 am

Hello,

Deja avec la librairie c'est impossible, car comme beaucoup elle travaille du cote serveur et non client, donc pour pouvoir tracer et ajouter des lignes a la souris, il te faut pouvoir recuperer les infos des points que tu souhaites grace a quelque chose, et ce quelque est a mon avis le javascript.

Voila

TNT
Posts: 3
Joined: Sun Feb 15, 2004 1:41 pm

Post by TNT » Thu Feb 19, 2004 6:25 pm

Hello .. bon ami français

( English at the end )

je ne suis pas en architecture client serveur ..

je suis en train de concevoir une application stand alone ..
j'ai les infos sur les points .. etc ..

je crois qu'il faut que je regarde la gestion de la souris dans jgraph et les listener souris ... :+((

j'ai vu l'application de zoom, je pense qu'il faut que je m'inspire ..
Il me faut du temps ... pour comprendre tout ca ..

Sinon, je limite l'affichage de ma courbe à 3 mois .. ( plage visible) sur 2 ans. J'ai un probleme avec les axes y .. et la plage de visibilité ( voir Jscrollbar )..

je cherche des sources dans ces deux domaines .. et je partage aussi des sources ..

@++

Sorry , for my poor english .. i try too translate..

I work with a stand alone application with jfreegraph.
I have two main problems ..

First , add a line beetween two points with mouse. ( after creation of the chat, maybe like the mouse zoom example )

Second, I add the jscrollbar in my application. The main problem is the visibility of the values in the Y axis ( not domain ).
My visibles values are include in 12 to 14 and the application display the range of all values ( 4 to 50 ). How to restrict the display to visible values ?? )..

Thanks bye*
TNT

Denis Ballant
Posts: 1
Joined: Fri Feb 20, 2004 11:02 am
Location: Brussels, Belgium

Did you find an answer to your question ?

Post by Denis Ballant » Fri Mar 19, 2004 12:21 pm

I got the same question.

So I would really appreciate if you would share here the solution that you might have found to that question.

Thanks.

Denis
Brussels.

TNT
Posts: 3
Joined: Sun Feb 15, 2004 1:41 pm

Post by TNT » Sat Mar 20, 2004 5:50 pm

I read your request.

You need to change some features in my source..
the creation of the TimesSeries .. and the Main().

My source is base in the mousezoom demo found in the jfreechart demo directory and i adapt it to my software.

I found two other way to do a program ..

Search " ChartScrollBar " .java in the forum ..
and
"PanScrollZoomDemo" .java in the forum


the source ..

package Wbourse.Conslist.graph;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.MovingAverage;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
import org.jfree.data.time.*;
import org.jfree.data.XYDataset;
import java.awt.BorderLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JPanel;
import javax.swing.JCheckBox;
import org.jfree.chart.JFreeChart;
import java.io.*;
import java.util.*;
import Wbourse.Conslist.*;
import Wbourse.Conslist.Prep.*;
import Wbourse.filtre.*;
import Wbourse.structure.*;
import javax.swing.*;

/**
* A timeseries ForceIndex chart.
*
* @author Duarte TERENCIO
* 20/09/2003
*/

public class ForceIndex extends ApplicationFrame {

public static ResourceBundle texte;
public String repdatabourse;
/** The chart panel. */
private ChartPanel chartPanel;

/** X zoom. */
private JCheckBox xzoom;

/** Y zoom. */
private JCheckBox yzoom;

/**
* A demonstration application showing how to create a simple time series chart.
*
* @param title the frame title.
*/
public ForceIndex(String title, DArrayList mla, String cle) {

super(title);
String chartTitle = "FORCE INDEX de " + cle;

int lataille = mla.size() ;
int debut = lataille - 120;

ForceI fi = new ForceI();
float[] forceindex = fi.calcluleleforceindex(mla );
float[] mme2fi = fi.calculelamme2duforceindex();

prepgraph pgraph = new prepgraph(mla);
pgraph.setDebut(debut);
TimeSeries lforceindex = pgraph.createunetimesSerie("Force Indes", forceindex );
TimeSeries lmme2fi = pgraph.createunetimesSerie("MMEFI", mme2fi );
// ********* Important *****
// You will need to change the way to build the TimeSeries..
// ************************

TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(lforceindex);
dataset.addSeries(lmme2fi);


JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Date", "Value", dataset, true, true, false);


XYPlot plot = chart.getXYPlot();
ValueAxis rangeAxis = plot.getRangeAxis();

chartPanel = new ChartPanel(chart);
chartPanel.setHorizontalZoom(false);
chartPanel.setVerticalZoom(false);
chartPanel.setHorizontalAxisTrace(false);
chartPanel.setVerticalAxisTrace(false);
chartPanel.setFillZoomRectangle(true);
chartPanel.setPreferredSize(new java.awt.Dimension(1000, 540));

JPanel main = new JPanel(new BorderLayout());
JPanel checkpanel = new JPanel();
xzoom = new JCheckBox("Horizontal Mouse Zooming");
xzoom.setSelected(false);
yzoom = new JCheckBox("Vertical Mouse Zooming");
yzoom.setSelected(false);
CheckListener clisten = new CheckListener();
xzoom.addItemListener(clisten);
yzoom.addItemListener(clisten);
checkpanel.add(xzoom);
checkpanel.add(yzoom);
main.add(checkpanel, BorderLayout.SOUTH);
main.add(chartPanel,BorderLayout.CENTER);
setContentPane(main);

}


/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) {

String repdatabourse;
// create a title...
Properties properties = System.getProperties();

String s = properties.getProperty("user.dir") + '/';
// si pas netbeans alors sinon utilise le home code en dure
if(s.indexOf("netbeans") < 0) {
repdatabourse = "d:/bourse/data/";
System.out.println("Dans le cas netbeans" + s);
}
else {
texte = ResourceBundle.getBundle("conf");
repdatabourse = texte.getString("databourse" );
}

System.out.println("databourse =" + repdatabourse );

String cle = "12533";

File ff = new File(repdatabourse+ cle +".txt");
containerdata cdata = new containerdata();
loaddata ldata = new loaddata(cdata.getMap() );

DArrayList mla = ldata.litunfichierdata(ff,cle);

System.out.println("Charge les data de cap gemini -->ok");

ForceIndex demo = new ForceIndex("FORCE INDEX", mla,cle );
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);

}
/**
* An item listener.
*
* @author VR
*/
class CheckListener implements ItemListener {



CheckListener() {
}

/**
* Receives change events.
*
* @param e the event.
*/
public void itemStateChanged(ItemEvent e) {
Object source = e.getItemSelectable();
if (source == xzoom) {
if (e.getStateChange() == ItemEvent.DESELECTED) {
chartPanel.setHorizontalZoom(false);
chartPanel.setHorizontalAxisTrace(false);
chartPanel.repaint();
}
else {
chartPanel.setHorizontalZoom(true);
chartPanel.setHorizontalAxisTrace(true);
}
}
else if (source == yzoom) {
if (e.getStateChange() == ItemEvent.DESELECTED) {
chartPanel.setVerticalZoom(false);
chartPanel.setVerticalAxisTrace(false);
chartPanel.repaint();
}
else {
chartPanel.setVerticalZoom(true);
chartPanel.setVerticalAxisTrace(true);
}
}
}
}
}

@ bye ..

Locked