trend lines on mouse event

Discussion about JFreeChart related to stockmarket charts.
Locked
develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

trend lines on mouse event

Post by develop » Tue Oct 04, 2005 2:18 pm

Hi,

when user clicks the mouse and then drags the mouse and then release. on these events on that selected area i need to draw trendlines.

I read some of the Regression classes. but still confuse on how to draw lines on dynamically selected dataArea, My dataset is depends upon user and find out what chart he selected to draw lines. I have combinedDomainXY plot. Please any one can give me idea how to achieve this ...?? :?


Thanks

develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

Post by develop » Fri Oct 21, 2005 4:32 pm

i fixed it, basically you need to override ChartPanel and write painComponent(..)

let me know if some needs to know in detail, i can also provide the code. since it is working for me,

wzwei28
Posts: 105
Joined: Wed Mar 16, 2005 9:17 am
Location: Malaysia, Earth
Contact:

Post by wzwei28 » Tue Nov 08, 2005 3:40 am

Wow!!! Seems that someone in jfreechart had done it!!! Well done!

Becuase currently I am also need to draw a trend line beside the technical indicator & historical price.

Brother 'Develop', can u pass me some idea & code on how to drawing the trendline...

Actually I have a little workaround on this task...
I plan to create some arrow icon --------- ^ | :arrow: , then after user click them, the button will dip inside. | v
-
- --
- --
- --
- --

Next, user click on the screen, then the trendline as well as arrow icon will show on the grid. It sounds easy, but really hard to start... From the API, I only know few related class to do these stuff... like following:

a)org.jfree.chart.needle.ArrowNeedle
b)org.jfree.chart.ChartPanel
c)org.jfree.chart.annotations.CategoryTextAnnotation
d)org.jfree.chart.annotations.TextAnnotation
e)org.jfree.chart.annotations.XYImageAnnotation
f)org.jfree.chart.annotations.XYShapeAnnotation
g)org.jfree.chart.annotations.XYLineAnnotation

Brother 'Develop', can u guide to the steps... Hope can help others SE that have same needs as well. Thanks in advance.

regards,
wei wei.

develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

Post by develop » Tue Nov 08, 2005 3:48 pm

Hi,

Actually i didnt use any arrow, in my plot, but my requirement was such that, user selects button called "draw TrendLines" then chart does not show the cross hair, so now when user drags the mouse and draw lines where he wants on chart, (i also have CombinedDomainXYPlot) and user can draw lines whenever he wants, for this i override the mousePressed,mouseDragged and mouseReleased events from chartPanel.

when user pressMouse i capture the mouseClick points, convert that to java2d and store it. I have my own class called SupportLines which has all stroke and paint information. so in this class i will save my starting x1,y1 points when user presses mouse, then when user start dragging mouse (on mouseDragged) get the new points and convert that to java2d and start drawing line using Line2D.Double(....). and when user mouse released, i get the final points and again save this points in class "supportLine"

now we need to save all lines drawn by user, (vector of supportline) so we can draw these lines on paintComponent. if you dont do that, then lines will be gone on repaint events.

so now over ride the paintComponent of chartPanel. and get the line from vector and draw all lines on chart on repaint.

i have done this and its working very nice, but the only problem i am facing is when user zooms the area with trendlines, my lines does not get zoom, i know the reason, but i am looking for solution.

cause : say you have orginal start points (35,45) --- real axis co-ordinate (not java2d) ,... now you zoom this area, so your this points gets shifted to new java2D location, so you need to find new java2d and draw lines again. but i am not able to get new java2d for some reason.. but other than that everything is working.

let me knowq, if you need to see my code,

hope this help.

Guest

Post by Guest » Wed Nov 09, 2005 4:19 am

Version:<jfreechart-0.9.21>
Exactly what I am looking for...

Actually I want to develop some trendline and arrow as well.

Something like http://www.prophet.net/analyze/javachar ... false&null

Almost all the chart features already done. Now only left the draw trendline & arrow part. If u see from the Java Applet in this URL, u will find it very easy to draw line... But after I decompile the source Jar file, it already obfuscated and due to some reason, I think I override the jfreechart method is faster & more suitable then searching method inside the 'JavaChartNew.jar' (prophet.net) on how to draw trendline...(lol)

From ur fast reply, seems that we face the same problem(zooming circumstances: because the line u draw is on the x,y position but not the X(Timeseries) & Y(ValueAxis), hence zooming only apply to dataset but not the trendline)

I also saw ur conversation with DG about this issue on other topic...

If I am not mistaken, ur solution on this issue is related to these following steps:(for reference for other SE that face the same problem)

1) User Click on 'draw TrendLines' button/image

2) User Click on the grid, then the chartPanel class mousePressed events handler will get the X,Y of the mouse click position.

2) convert to java2D(???), and override the paint method to draw out the initial x,y point. (Or create a new class 'SupportLines/TrendLine' to handle the stroke, paint activities)

3)Then follow by user dragging events. Upon user release the mouse, dragging activities complete, then keep track on its last x,y position in order to draw a line from starting point to end point. (Drawing line using Line2D.Double(...). save the final points in 'SupportLine' class.

4)Save all lines drawn by user(vector of supportline) so that we can draw these lines on paintComponent. If not, the lines will be gone on repaint events (Just like when user click undo/clear all trendline-we repaint it to clear without storing any location of trendline). Or another workaround is to detect whether the user had click the clear all trendline button (Bollean flag), then if yes, the boolean is false, the repaint activities will not draw/paint on the trendline.(Virtually end user thought is that trendline is erased.)

5)Next, override paintComponent of chartPanel and get line from vector and draw all lines on chart on repaint.

6)MMM...because I am only a beginner(hope u don't laugh on my little opinion). I think the workaround to solve the zooming part is try to override the dataset/dataseries in the relevant class then use the annotation to draw the lines out using overlaid class.

plz don't laugh...this is only my little opinion...
From the documentation that I decompile the class and research on other topic in jfreechart forum...Maybe this class can work. Because annotation will no zooming problem (it will follow the data to be magnifying).

Here is the demo classes from the 'jfreechart-0.9.21-demo.jar'... ()
i)JOverlaidXYPlotDemo1.class (shown below-for ref. to whom need)
ii)JOverlaidXYPlotDemo2.class (shown below-for ref. to whom need)
iii)JRegressionDemo1.class (shown below-for ref. to whom need)
iv)JPlotOrientationDemo1.class(inlcuded in demo)
v)JPlotOrientationDemo2.class(included in demo)

JOverlaidXYPlotDemo1
---------------------------

Code: Select all

package demo;

import java.awt.Dimension;
import java.awt.Font;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.annotations.XYTextAnnotation;
import org.jfree.chart.axis.*;
import org.jfree.chart.labels.StandardXYToolTipGenerator;
import org.jfree.chart.plot.DatasetRenderingOrder;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.*;
import org.jfree.data.time.*;
import org.jfree.data.xy.IntervalXYDataset;
import org.jfree.data.xy.XYDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;

public class JOverlaidXYPlotDemo1 extends ApplicationFrame
{

    public JOverlaidXYPlotDemo1(String s)
    {
        super(s);
        JFreeChart jfreechart = createOverlaidChart();
        ChartPanel chartpanel = new ChartPanel(jfreechart, true, true, true, true, true);
        chartpanel.setMouseZoomable(true,false);
        chartpanel.setPreferredSize(new Dimension(500, 270));
        setContentPane(chartpanel);
    }

    private JFreeChart createOverlaidChart()
    {
        IntervalXYDataset intervalxydataset = createDataset1();
        XYBarRenderer xybarrenderer = new XYBarRenderer(0.20000000000000001D);
        xybarrenderer.setToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})", new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
        DateAxis dateaxis = new DateAxis("Date");
        dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
        NumberAxis numberaxis = new NumberAxis("Value");
        XYPlot xyplot = new XYPlot(intervalxydataset, dateaxis, numberaxis, xybarrenderer);
        double d = (new Day(9, 3, 2002)).getMiddleMillisecond();
        XYTextAnnotation xytextannotation = new XYTextAnnotation("Hello!", d, 10000D);
        xytextannotation.setFont(new Font("SansSerif", 0, 9));
        xyplot.addAnnotation(xytextannotation);
        XYDataset xydataset = createDataset2();
        StandardXYItemRenderer standardxyitemrenderer = new StandardXYItemRenderer();
        standardxyitemrenderer.setToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})", new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
        xyplot.setDataset(1, xydataset);
        xyplot.setRenderer(1, standardxyitemrenderer);
        xyplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
        return new JFreeChart("Overlaid Plot Example", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true);
    }

    private IntervalXYDataset createDataset1()
    {
        TimeSeries timeseries = new TimeSeries("Series 1", org.jfree.data.time.Day.class);
        timeseries.add(new Day(1, 3, 2002), 12353.299999999999D);
        timeseries.add(new Day(2, 3, 2002), 13734.4D);
        timeseries.add(new Day(3, 3, 2002), 14525.299999999999D);
        timeseries.add(new Day(4, 3, 2002), 13984.299999999999D);
        timeseries.add(new Day(5, 3, 2002), 12999.4D);
        timeseries.add(new Day(6, 3, 2002), 14274.299999999999D);
        timeseries.add(new Day(7, 3, 2002), 15943.5D);
        timeseries.add(new Day(8, 3, 2002), 14845.299999999999D);
        timeseries.add(new Day(9, 3, 2002), 14645.4D);
        timeseries.add(new Day(10, 3, 2002), 16234.6D);
        timeseries.add(new Day(11, 3, 2002), 17232.299999999999D);
        timeseries.add(new Day(12, 3, 2002), 14232.200000000001D);
        timeseries.add(new Day(13, 3, 2002), 13102.200000000001D);
        timeseries.add(new Day(14, 3, 2002), 14230.200000000001D);
        timeseries.add(new Day(15, 3, 2002), 11235.200000000001D);
        return new TimeSeriesCollection(timeseries);
    }

    private XYDataset createDataset2()
    {
        TimeSeries timeseries = new TimeSeries("Series 2", org.jfree.data.time.Day.class);
        timeseries.add(new Day(3, 3, 2002), 16853.200000000001D);
        timeseries.add(new Day(4, 3, 2002), 19642.299999999999D);
        timeseries.add(new Day(5, 3, 2002), 18253.5D);
        timeseries.add(new Day(6, 3, 2002), 15352.299999999999D);
        timeseries.add(new Day(7, 3, 2002), 13532D);
        timeseries.add(new Day(8, 3, 2002), 12635.299999999999D);
        timeseries.add(new Day(9, 3, 2002), 13998.200000000001D);
        timeseries.add(new Day(10, 3, 2002), 11943.200000000001D);
        timeseries.add(new Day(11, 3, 2002), 16943.900000000001D);
        timeseries.add(new Day(12, 3, 2002), 17843.200000000001D);
        timeseries.add(new Day(13, 3, 2002), 16495.299999999999D);
        timeseries.add(new Day(14, 3, 2002), 17943.599999999999D);
        timeseries.add(new Day(15, 3, 2002), 18500.700000000001D);
        timeseries.add(new Day(16, 3, 2002), 19595.900000000001D);
        TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries);
        return timeseriescollection;
    }

    public static void main(String args[])
    {
        JOverlaidXYPlotDemo1 JOverlaidXYPlotDemo1 = new JOverlaidXYPlotDemo1("Overlaid XYPlot Demo");
        JOverlaidXYPlotDemo1.pack();
        RefineryUtilities.centerFrameOnScreen(JOverlaidXYPlotDemo1);
        JOverlaidXYPlotDemo1.setVisible(true);
    }
}

JOverlaidXYPlotDemo2
--------------------------

Code: Select all

package demo;

import java.awt.Dimension;
import java.awt.Font;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.annotations.XYTextAnnotation;
import org.jfree.chart.axis.*;
import org.jfree.chart.labels.StandardXYToolTipGenerator;
import org.jfree.chart.plot.*;
import org.jfree.chart.renderer.xy.*;
import org.jfree.data.time.*;
import org.jfree.data.xy.IntervalXYDataset;
import org.jfree.data.xy.XYDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;

public class JOverlaidXYPlotDemo2 extends ApplicationFrame
{

    public JOverlaidXYPlotDemo2(String s)
    {
        super(s);
        JFreeChart jfreechart = createOverlaidChart();
        ChartPanel chartpanel = new ChartPanel(jfreechart, true, true, true, true, true);
        chartpanel.setMouseZoomable(true,false);
        chartpanel.setPreferredSize(new Dimension(500, 270));
        setContentPane(chartpanel);
    }

    private JFreeChart createOverlaidChart()
    {
        DateAxis dateaxis = new DateAxis("Date");
        dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
        NumberAxis numberaxis = new NumberAxis("Value");
        IntervalXYDataset intervalxydataset = createDataset1();
        XYBarRenderer xybarrenderer = new XYBarRenderer(0.20000000000000001D);
        xybarrenderer.setToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})", new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
        XYPlot xyplot = new XYPlot(intervalxydataset, dateaxis, numberaxis, xybarrenderer);
        double d = (new Day(9, 3, 2002)).getMiddleMillisecond();
        XYTextAnnotation xytextannotation = new XYTextAnnotation("Hello!", d, 10000D);
        xytextannotation.setFont(new Font("SansSerif", 0, 9));
        xyplot.addAnnotation(xytextannotation);
        NumberAxis numberaxis1 = new NumberAxis("Value 2");
        xyplot.setRangeAxis(1, numberaxis1);
        XYDataset xydataset = createDataset2A();
        StandardXYItemRenderer standardxyitemrenderer = new StandardXYItemRenderer();
        standardxyitemrenderer.setToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})", new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
        xyplot.setDataset(1, xydataset);
        xyplot.setRenderer(1, standardxyitemrenderer);
        XYDataset xydataset1 = createDataset2B();
        xyplot.setDataset(2, xydataset1);
        xyplot.setRenderer(2, new StandardXYItemRenderer());
        xyplot.mapDatasetToRangeAxis(2, 1);
        xyplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
        xyplot.setOrientation(PlotOrientation.VERTICAL);
        return new JFreeChart("Overlaid Plot Example", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true);
    }

    private IntervalXYDataset createDataset1()
    {
        TimeSeries timeseries = new TimeSeries("Series 1", org.jfree.data.time.Day.class);
        timeseries.add(new Day(1, 3, 2002), 12353.299999999999D);
        timeseries.add(new Day(2, 3, 2002), 13734.4D);
        timeseries.add(new Day(3, 3, 2002), 14525.299999999999D);
        timeseries.add(new Day(4, 3, 2002), 13984.299999999999D);
        timeseries.add(new Day(5, 3, 2002), 12999.4D);
        timeseries.add(new Day(6, 3, 2002), 14274.299999999999D);
        timeseries.add(new Day(7, 3, 2002), 15943.5D);
        timeseries.add(new Day(8, 3, 2002), 14845.299999999999D);
        timeseries.add(new Day(9, 3, 2002), 14645.4D);
        timeseries.add(new Day(10, 3, 2002), 16234.6D);
        timeseries.add(new Day(11, 3, 2002), 17232.299999999999D);
        timeseries.add(new Day(12, 3, 2002), 14232.200000000001D);
        timeseries.add(new Day(13, 3, 2002), 13102.200000000001D);
        timeseries.add(new Day(14, 3, 2002), 14230.200000000001D);
        timeseries.add(new Day(15, 3, 2002), 11235.200000000001D);
        TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries);
        return timeseriescollection;
    }

    private XYDataset createDataset2A()
    {
        TimeSeries timeseries = new TimeSeries("Series 2", org.jfree.data.time.Day.class);
        timeseries.add(new Day(3, 3, 2002), 16853.200000000001D);
        timeseries.add(new Day(4, 3, 2002), 19642.299999999999D);
        timeseries.add(new Day(5, 3, 2002), 18253.5D);
        timeseries.add(new Day(6, 3, 2002), 15352.299999999999D);
        timeseries.add(new Day(7, 3, 2002), 13532D);
        timeseries.add(new Day(8, 3, 2002), 12635.299999999999D);
        timeseries.add(new Day(9, 3, 2002), 13998.200000000001D);
        timeseries.add(new Day(10, 3, 2002), 11943.200000000001D);
        timeseries.add(new Day(11, 3, 2002), 16943.900000000001D);
        timeseries.add(new Day(12, 3, 2002), 17843.200000000001D);
        timeseries.add(new Day(13, 3, 2002), 16495.299999999999D);
        timeseries.add(new Day(14, 3, 2002), 17943.599999999999D);
        timeseries.add(new Day(15, 3, 2002), 18500.700000000001D);
        timeseries.add(new Day(16, 3, 2002), 19595.900000000001D);
        TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries);
        timeseriescollection.setXPosition(TimePeriodAnchor.MIDDLE);
        return timeseriescollection;
    }

    private XYDataset createDataset2B()
    {
        TimeSeries timeseries = new TimeSeries("Series 2B", org.jfree.data.time.Day.class);
        timeseries.add(new Day(3, 3, 2002), 43.899999999999999D);
        timeseries.add(new Day(4, 3, 2002), 72.599999999999994D);
        timeseries.add(new Day(5, 3, 2002), 89.400000000000006D);
        timeseries.add(new Day(6, 3, 2002), 23.800000000000001D);
        timeseries.add(new Day(7, 3, 2002), 45D);
        timeseries.add(new Day(8, 3, 2002), 65.799999999999997D);
        timeseries.add(new Day(9, 3, 2002), 92.099999999999994D);
        timeseries.add(new Day(10, 3, 2002), 84.700000000000003D);
        timeseries.add(new Day(11, 3, 2002), 77.200000000000003D);
        timeseries.add(new Day(12, 3, 2002), 65.099999999999994D);
        timeseries.add(new Day(13, 3, 2002), 78.5D);
        timeseries.add(new Day(14, 3, 2002), 75.299999999999997D);
        timeseries.add(new Day(15, 3, 2002), 69.900000000000006D);
        timeseries.add(new Day(20, 3, 2002), 56.600000000000001D);
        TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries);
        timeseriescollection.setXPosition(TimePeriodAnchor.MIDDLE);
        return timeseriescollection;
    }

    public static void main(String[] args)
    {
        JOverlaidXYPlotDemo2 JOverlaidXYPlotDemo2 = new JOverlaidXYPlotDemo2("Overlaid XYPlot Demo");
        JOverlaidXYPlotDemo2.pack();
        RefineryUtilities.centerFrameOnScreen(JOverlaidXYPlotDemo2);
        JOverlaidXYPlotDemo2.setVisible(true);
    }
}

JRegressionDemo1
----------------------

Code: Select all

package demo;

import java.awt.Color;
import java.awt.Container;
import javax.swing.JTabbedPane;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.*;
import org.jfree.data.function.LineFunction2D;
import org.jfree.data.function.PowerFunction2D;
import org.jfree.data.general.DatasetUtilities;
import org.jfree.data.statistics.Regression;
import org.jfree.data.xy.*;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;

public class JRegressionDemo1 extends ApplicationFrame
{

    private XYDataset data1;

    public JRegressionDemo1(String s)
    {
        super(s);
        data1 = createSampleData1();
        getContentPane().add(createContent());
    }

    private JTabbedPane createContent()
    {
        JTabbedPane jtabbedpane = new JTabbedPane();
        jtabbedpane.add("Linear", createChartPanel1());
        jtabbedpane.add("Power", createChartPanel2());
        return jtabbedpane;
    }

    private ChartPanel createChartPanel1()
    {
        NumberAxis numberaxis = new NumberAxis("X");
        numberaxis.setAutoRangeIncludesZero(false);
        NumberAxis numberaxis1 = new NumberAxis("Y");
        numberaxis1.setAutoRangeIncludesZero(false);
        StandardXYItemRenderer standardxyitemrenderer = new StandardXYItemRenderer(1);
        standardxyitemrenderer.setShapesFilled(true);
        XYPlot xyplot = new XYPlot(data1, numberaxis, numberaxis1, standardxyitemrenderer);
        double ad[] = Regression.getOLSRegression(data1, 0);
        LineFunction2D linefunction2d = new LineFunction2D(ad[0], ad[1]);
        XYDataset xydataset = DatasetUtilities.sampleFunction2D(linefunction2d, 2D, 11D, 100, "Fitted Regression Line");
        xyplot.setDataset(1, xydataset);
        DefaultXYItemRenderer defaultxyitemrenderer = new DefaultXYItemRenderer();
        defaultxyitemrenderer.setSeriesPaint(0, Color.blue);
        xyplot.setRenderer(1, defaultxyitemrenderer);
        JFreeChart jfreechart = new JFreeChart("Linear Regression", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true);
        ChartPanel chartpanel = new ChartPanel(jfreechart, false);
        chartpanel.setMouseZoomable(true,false);
        return chartpanel;
    }

    private ChartPanel createChartPanel2()
    {
        NumberAxis numberaxis = new NumberAxis("X");
        numberaxis.setAutoRangeIncludesZero(false);
        NumberAxis numberaxis1 = new NumberAxis("Y");
        numberaxis1.setAutoRangeIncludesZero(false);
        StandardXYItemRenderer standardxyitemrenderer = new StandardXYItemRenderer(1);
        standardxyitemrenderer.setShapesFilled(true);
        XYPlot xyplot = new XYPlot(data1, numberaxis, numberaxis1, standardxyitemrenderer);
        double ad[] = Regression.getPowerRegression(data1, 0);
        PowerFunction2D powerfunction2d = new PowerFunction2D(ad[0], ad[1]);
        XYDataset xydataset = DatasetUtilities.sampleFunction2D(powerfunction2d, 2D, 11D, 100, "Fitted Regression Line");
        DefaultXYItemRenderer defaultxyitemrenderer = new DefaultXYItemRenderer();
        defaultxyitemrenderer.setSeriesPaint(0, Color.blue);
        xyplot.setDataset(1, xydataset);
        xyplot.setRenderer(1, defaultxyitemrenderer);
        JFreeChart jfreechart = new JFreeChart("Power Regression", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true);
        ChartPanel chartpanel = new ChartPanel(jfreechart, false);
        chartpanel.setMouseZoomable(true,false);
        return chartpanel;
    }

    private XYDataset createSampleData1()
    {
        XYSeries xyseries = new XYSeries("Series 1");
        xyseries.add(2D, 56.270000000000003D);
        xyseries.add(3D, 41.32D);
        xyseries.add(4D, 31.449999999999999D);
        xyseries.add(5D, 30.050000000000001D);
        xyseries.add(6D, 24.690000000000001D);
        xyseries.add(7D, 19.780000000000001D);
        xyseries.add(8D, 20.940000000000001D);
        xyseries.add(9D, 16.73D);
        xyseries.add(10D, 14.210000000000001D);
        xyseries.add(11D, 12.44D);
        XYSeriesCollection xyseriescollection = new XYSeriesCollection(xyseries);
        return xyseriescollection;
    }

    public static void main(String args[])
    {
        JRegressionDemo1 JRegressionDemo1 = new JRegressionDemo1("Regression Demo 1");
        JRegressionDemo1.pack();
        RefineryUtilities.centerFrameOnScreen(JRegressionDemo1);
        JRegressionDemo1.setVisible(true);
    }
}


These 3 classes can be founded in the 'jfreechart-0.9.21-demo.jart',
unzip it and decompile the classes: JOverlaidXYPlotDemo1,JOverlaidXYPlotDemo2, JRegressionDemo1

Develop, if possible, can u provide me a simple demo class along with the few override class like chartPanel.class, supportLine.class and etc. I hope I can contribute in modifying the code to solve the zooming fault, then I will republish a new simple demo on this trendline program demo for other SE to use it...

Thanks in advance.
regards,
wei wei.

wzwei28
Posts: 105
Joined: Wed Mar 16, 2005 9:17 am
Location: Malaysia, Earth
Contact:

Post by wzwei28 » Wed Nov 09, 2005 4:21 am

lol... forget to login...

develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

Post by develop » Wed Nov 09, 2005 4:15 pm

i also dont have idea about annotation and stuff. I think i will have to digg into details, but for now i will make demo whatever i have and give it to you,

then i will look into the annotation code, also, i am using latest version of jfreechart which is rc1. so i will make demo for that version.

give me some time, and i will make the code ready.

wzwei28
Posts: 105
Joined: Wed Mar 16, 2005 9:17 am
Location: Malaysia, Earth
Contact:

Post by wzwei28 » Mon Nov 14, 2005 2:20 pm

Version:jfreechart-1.0.0-rc1

HaHaHa,

Finally I had complete a simple sample of icon mapping / map / binding into the grid. This thing had made me mad because I am not a good developer. Luckily on the forum http://www.jfree.org/phpBB2/viewtopic.php?t=14854 that joined by DG, cdr, develop & skunk let me open my eye. Before that I am overriding / refer to the classes such as ChartPanel, ChartRenderingInfo, ChartEntity, EntityCollection, XYTextAnnotation, ValueAxis , XYPlot, PlotOrientation, xyimageannotation, and etc... Because I am not quite understand how the x, y on mouseClicked/Pressed to search for data inside the dataset. So, I keep on searching how the drawback is... After test and error, still not close to success... Luckily tonight I found the forum on 'Fri Oct 21. 2005' that open my eye....The complicated solved easily...HaHaHa.

Following is my code. Due to the reason, I haven't upload image to server, therefore the icon image will not available to download, but u guys can download it from the internet or draw urself. If u want, also can email me to request the up, down & sustain arrow icon created by me.

* Well, the program is designed to let the user map the icon exactly inside the grid by simply click on the grid, then it will received its x,y coordinate and searching for the x&y axis value inside the chart. Finally, using 'XYImageAnnotation' to map in just like a text annotation image into ur grid. Therefore, it can zoom in and out without any problem. Following is my demo code. Hope it helps.... remind that the 'img/arrowUp.PNG' image is the image where u put inside the WEB-INF\classes\img folder. That's all, (the demo class put in the WEB-INF\classes.

* For the 'C:\\ant\\img\\ArrowInChart.PNG' path to store ur image, u can put any directory inside ur server.

Hahaha... luckily can solved it within 2 days.

*** The workaround to this icon mapping/binding is to combine the 'JMouseListenerDemo4.class' way mouse detecting coorodinate & 'XYImageAnnotation' like I imagined before... Still Can't believe it works well(^0^)...

Now my next task is to include 'undo' & 'delete' to delete the arrow icon in the chart. Next, I will continue to do the trendline part...

Hi, 'develop' how is ur progress, any sample demo done?If completed, can u share it to all of us so that we can make use of it(knowledge sharing)?Hope can hear good new from u.

Code: Select all

/* 
 * (C) Copyright 2000-2005, by N2NConnect Berhad.
 *
 *
 * Original Author	:  	Wei Wei(WZW);
 * Contributor(s)	:  	-;
 * 
 * Version 1.0.1    :	14/11/05	(WZW)
 *
 * Error Code		: 	CAD001:Generate PNG Error
 */

package org.jfree.chart.demo;

import java.awt.Point; 
import java.awt.geom.Point2D; 
import java.awt.geom.Rectangle2D; 
//------------------------------------------
//@@ jfreechart-1.0.0-rc1
import org.jfree.chart.ChartFactory; 
import org.jfree.chart.ChartMouseEvent; 
import org.jfree.chart.ChartMouseListener; 
import org.jfree.chart.ChartPanel; 
import org.jfree.chart.JFreeChart; 
import org.jfree.chart.axis.ValueAxis; 
import org.jfree.chart.plot.PlotOrientation; 
import org.jfree.chart.plot.XYPlot; 
import org.jfree.data.xy.XYDataset; 
import org.jfree.data.xy.XYSeries; 
import org.jfree.data.xy.XYSeriesCollection; 
import org.jfree.ui.ApplicationFrame; 
import org.jfree.ui.RectangleEdge; 
import org.jfree.ui.RefineryUtilities; 
//---------------------------------------

import javax.swing.ImageIcon;		//ImageIcon, jfreechart 0.9.21
import java.awt.Image;
import org.jfree.chart.annotations.XYImageAnnotation;
import org.jfree.data.time.Day;
import org.jfree.data.time.Month;
import org.jfree.chart.axis.DateTickMarkPosition;
import java.io.File;
import java.io.FileOutputStream;
import org.jfree.chart.ChartUtilities;

import java.awt.Color;
import java.text.SimpleDateFormat;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
//#import org.jfree.chart.Spacer;							//(Deprecated)jfreechart 0.9.16
import org.jfree.chart.axis.AxisSpace;						//(unused class)jfreechart 0.9.21
//$import org.jfree.chart.StandardLegend;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.XYPlot;
//#import org.jfree.chart.renderer.StandardXYItemRenderer;	//jfreechart 0.9.16
import org.jfree.chart.renderer.xy.StandardXYItemRenderer;	//jfreechart 0.9.21
//#import org.jfree.chart.renderer.XYItemRenderer;			//jfreechart 0.9.16
import org.jfree.chart.renderer.xy.XYItemRenderer;			//jfreechart 0.9.21	
//#import org.jfree.data.XYDataset;							//jfreechart 0.9.16
import org.jfree.data.xy.XYDataset;							//jfreechart 0.9.21
import org.jfree.data.time.Month;				
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;

public class ChartArrowDemo extends ApplicationFrame 
									implements ChartMouseListener{

	private JFreeChart chart; 
	private ChartPanel chartPanel; 
	private XYPlot plot;
	
	private int m_iChartWidth = 800;
	private int m_iChartHeight = 400;
	
	public ChartArrowDemo(String title) {
		super(title);
		XYDataset dataset = createDataset();
		chart = createChart(dataset);
		chartPanel = new ChartPanel(chart);
		chartPanel.setMouseZoomable(true,false);
		chartPanel.setPreferredSize(new java.awt.Dimension(m_iChartWidth, m_iChartHeight));
		chartPanel.setMouseZoomable(true, false);
		chartPanel.addChartMouseListener(this);	
		setContentPane(chartPanel);
		genPNG(chart);	//generate PNG file
	}
	
	private void genPNG(JFreeChart chart){
		String sChartName = "IntradayChart";
		String sChartType = ".PNG";
		File fFile = new File("C:\\ant\\img\\ArrowInChart.PNG");
		try{			
			FileOutputStream fout = new FileOutputStream(fFile); 
			ChartUtilities.writeChartAsPNG (fout, chart, m_iChartWidth, m_iChartHeight);
			fout.close(); 
		}catch(Exception exc){
			System.out.println("ErrorCode[CAD001]:exc=["+exc+"]");
		}		
	}
	
    private JFreeChart createChart(XYDataset dataset) {
		JFreeChart chart = ChartFactory.createTimeSeriesChart(
		"Bursa Malaysia Index Comparison",
		"Date", "Percentage %",
		dataset,
		true,
		true,
		false
		);
		
		chart.setBackgroundPaint(Color.white);
			
	//	StandardLegend sl = (StandardLegend) chart.getLegend();
	//	sl.setDisplaySeriesShapes(true);
		plot = chart.getXYPlot();
		//#plot.setBackgroundPaint(Color.lightGray);
		plot.setBackgroundPaint(Color.black);
		plot.setDomainGridlinePaint(Color.white);
		plot.setRangeGridlinePaint(Color.white);
		
		//=====================================================================
		//@@ Modify as Spacer class had deprecated.Version(0.9.16->0.9.21)
		//#plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
		//=====================================================================
			
		//=================================================
		//@@ set Watermark Background Image
		//@@ Bind the watermark for the background of white space.
	//$	ImageIcon icon = new ImageIcon("img/arrowUp2.PNG");
	//$	Image image = icon.getImage(); 
	//$	plot.setBackgroundImage(image);
	//-------------------------------------------------------------------------
	//@@ Plz prepare an image (any thing and store in img folder on the same level with classes folder)
		double dArrowTime = 0;
		double dArrowTime2 = 0;
		double dArrowTime3 = 0;
		XYImageAnnotation xyimageannotation,xyimageannotation2,xyimageannotation3;
		ImageIcon icArrowUp = new ImageIcon("img/arrowUp.PNG");
		ImageIcon icArrowDw = new ImageIcon("img/arrowDw.PNG");
		ImageIcon icArrowSt = new ImageIcon("img/arrowSt.PNG");
		Image imgArrowUp = icArrowUp.getImage();
		Image imgArrowDw = icArrowDw.getImage();
		Image imgArrowSt = icArrowSt.getImage();
		//double dArrowTime = (new Day(9, 9, 2004)).getMiddleMillisecond();
			
		dArrowTime = (new Month(7, 2004)).getMiddleMillisecond();
		xyimageannotation = new XYImageAnnotation(dArrowTime, -5.0, imgArrowUp);
	    plot.addAnnotation(xyimageannotation);
	    System.out.println("@ dArrowTime=["+dArrowTime+"]");
		        
		dArrowTime2 = (new Month(11, 2004)).getMiddleMillisecond();
		xyimageannotation2 = new XYImageAnnotation(dArrowTime2, 9.0, imgArrowDw);
	    plot.addAnnotation(xyimageannotation2);
	    
		dArrowTime3= (new Month(5, 2004)).getMiddleMillisecond();
		xyimageannotation3 = new XYImageAnnotation(dArrowTime3, 2.5, imgArrowSt);
	    plot.addAnnotation(xyimageannotation3);
		//===================================================
			
		plot.setDomainCrosshairVisible(true);
		plot.setRangeCrosshairVisible(true);
		XYItemRenderer renderer = plot.getRenderer();
		
		if (renderer instanceof StandardXYItemRenderer) {
		StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
		rr.setPlotShapes(true);
		rr.setShapesFilled(true);
		}
			
	//================================================	
		final double dRangeMin = 2.0;	
		final double dRangeHalf = dRangeMin/2;	
		double dUpperRange = 0;
		double dLowerRange = 0;
		double dCenterPoint = 0;
		double dHighest = 8.8;
		double dLowest = -13.6;	
			
		DateAxis axis = (DateAxis) plot.getDomainAxis();
		axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
		axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);	//set bar chart to middle
			
		dUpperRange = dHighest + dRangeHalf;
		dLowerRange = dLowest - dRangeHalf;
		System.out.println("dUpperRange=["+dUpperRange+"],dLowerRange=["+dLowerRange+"]");
		ValueAxis rangeAxis = (ValueAxis) plot.getRangeAxis();
		rangeAxis.setRangeWithMargins(dLowerRange,dUpperRange);
			
		return chart;
  	}

  	private XYDataset createDataset() {
		
		//#TimeSeries s1 = new TimeSeries("L&G European Index Trust", Month.class);
		TimeSeries s1 = new TimeSeries("Composite Index", Month.class);
		
		s1.add(new Month(3, 2004), 3.3);
		s1.add(new Month(4, 2004), 1.8);
		s1.add(new Month(5, 2004), 0.6);
		s1.add(new Month(6, 2004), -0.8);
		s1.add(new Month(7, 2004), -2.3);
		s1.add(new Month(8, 2004), 0.0);
		s1.add(new Month(9, 2004), 1.7);
		s1.add(new Month(10, 2004), 5.2);
		s1.add(new Month(11, 2004), 8.8);
		s1.add(new Month(12, 2004), 2.6);
		s1.add(new Month(1, 2005), -4.9);
		s1.add(new Month(2, 2005), -5.7);
		s1.add(new Month(3, 2005), -11.3);
			
		//#TimeSeries s2 = new TimeSeries("L&G UK Index Trust", Month.class);
		TimeSeries s2 = new TimeSeries("Finance Index", Month.class);
	
		s2.add(new Month(3, 2004), 4.2);
		s2.add(new Month(4, 2004), 2.2);
		s2.add(new Month(5, 2004), 1.1);
		s2.add(new Month(6, 2004), -1.6);
		s2.add(new Month(7, 2004), -4.2);
		s2.add(new Month(8, 2004), 1.5);
		s2.add(new Month(9, 2004), 0.4);
		s2.add(new Month(10, 2004), 0.0);
		s2.add(new Month(11, 2004), 6.1);
		s2.add(new Month(12, 2004), 8.3);
		s2.add(new Month(1, 2005), 2.7);
		s2.add(new Month(2, 2005), 0.7);
		s2.add(new Month(3, 2005), -4.6);
			
		TimeSeries s3 = new TimeSeries("Industrial Products Index", Month.class);
		
		s3.add(new Month(3, 2004), 3.2);
		s3.add(new Month(4, 2004), -0.2);
		s3.add(new Month(5, 2004), -2.1);
		s3.add(new Month(6, 2004), 0.6);
		s3.add(new Month(7, 2004), -1.2);
		s3.add(new Month(8, 2004), -2.5);
		s3.add(new Month(9, 2004), 0.7);
		s3.add(new Month(10, 2004), -1.5);
		s3.add(new Month(11, 2004), 4.1);
		s3.add(new Month(12, 2004), 1.3);
		s3.add(new Month(1, 2005), -2.7);
		s3.add(new Month(2, 2005), -8.0);
		s3.add(new Month(3, 2005), -13.6);
		
		TimeSeriesCollection dataset = new TimeSeriesCollection();
		dataset.addSeries(s1);
		dataset.addSeries(s2);
		dataset.addSeries(s3);
		dataset.setDomainIsPointsInTime(true);
		return dataset;

  	}
	
	public void mapIcon(double vs_dChartX, double vs_dChartY){
		
		double dArrowTime = 0;
		double dArrowTime2 = 0;
		double dArrowTime3 = 0;
		XYImageAnnotation xyimageannotation,xyimageannotation2,xyimageannotation3;
	
		ImageIcon icArrowUp = new ImageIcon("img/arrowUp.PNG");
		ImageIcon icArrowDw = new ImageIcon("img/arrowDw.PNG");
		ImageIcon icArrowSt = new ImageIcon("img/arrowSt.PNG");
		Image imgArrowUp = icArrowUp.getImage();
		Image imgArrowDw = icArrowDw.getImage();
		Image imgArrowSt = icArrowSt.getImage();
		
		dArrowTime = (new Month(7, 2004)).getMiddleMillisecond();
		xyimageannotation = new XYImageAnnotation(vs_dChartX, vs_dChartY, imgArrowUp);
	    plot.addAnnotation(xyimageannotation);	  

	//@@ Generate PNG Chart after every map
		//@ U may disable it if u don't want to refresh the image do frequent, 
		//@ or u may create a button to generate when u need it.
		genPNG(chart);                      
	}


	/** 
     * Receives chart mouse click events. 
     * 
     * @param event  the event. 
     */ 
    public void chartMouseClicked(ChartMouseEvent event) { 
        int mouseX = event.getTrigger().getX(); 
        int mouseY = event.getTrigger().getY(); 
        System.out.println("x = " + mouseX + ", y = " + mouseY);        
        Point2D p = chartPanel.translateScreenToJava2D( 
                new Point(mouseX, mouseY)); 
        XYPlot plot = (XYPlot) chart.getPlot(); 
        //Rectangle2D plotArea = chartPanel.getScreenDataArea(); 
        Rectangle2D plotArea = this.chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea();
        ValueAxis domainAxis = plot.getDomainAxis(); 
        RectangleEdge domainAxisEdge = plot.getDomainAxisEdge(); 
        ValueAxis rangeAxis = plot.getRangeAxis(); 
        RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge(); 
        double chartX = domainAxis.java2DToValue(p.getX(), plotArea, 
                domainAxisEdge); 
        double chartY = rangeAxis.java2DToValue(p.getY(), plotArea, 
                rangeAxisEdge); 
        System.out.println("Chart: x = " + chartX + ", y = " + chartY); 
        
        //@@ Mapping Icon on the chart
        mapIcon(chartX, chartY);
    } 

    /** 
     * Receives chart mouse moved events. 
     * 
     * @param event  the event. 
     */ 
    public void chartMouseMoved(ChartMouseEvent event) { 
        // ignore 
    } 
	
	public static void main(String[] args) {
		ChartArrowDemo demo = new ChartArrowDemo("Time Series Demo 1");
		demo.pack();
		RefineryUtilities.centerFrameOnScreen(demo);
		demo.setVisible(true);
	}
	
}

** Following class is no need for the icon mapping but it developed by DG on Fri Oct 21, 2005 (not yet inside the demo version-14/11/05), so it might be a good reference class for all of ur... Thanks a lot! (DG,cdr,develop & skunk)

JMouseListenerDemo4.class
--------------------------------------------------------

Code: Select all

/* ----------------------- 
 * JMouseListenerDemo4.java 
 * ----------------------- 
 * (C) Copyright 2005, by Object Refinery Limited. 
 * 
 */ 

package demo; 

import java.awt.Point; 
import java.awt.geom.Point2D; 
import java.awt.geom.Rectangle2D; 

import org.jfree.chart.ChartFactory; 
import org.jfree.chart.ChartMouseEvent; 
import org.jfree.chart.ChartMouseListener; 
import org.jfree.chart.ChartPanel; 
import org.jfree.chart.JFreeChart; 
import org.jfree.chart.axis.ValueAxis; 
import org.jfree.chart.plot.PlotOrientation; 
import org.jfree.chart.plot.XYPlot; 
import org.jfree.data.xy.XYDataset; 
import org.jfree.data.xy.XYSeries; 
import org.jfree.data.xy.XYSeriesCollection; 
import org.jfree.ui.ApplicationFrame; 
import org.jfree.ui.RectangleEdge; 
import org.jfree.ui.RefineryUtilities; 

/** 
 * An example showing how to convert the mouse location to chart coordinates. 
 */ 
public class JMouseListenerDemo4 extends ApplicationFrame  
                                implements ChartMouseListener { 

    private JFreeChart chart; 
    
    private ChartPanel chartPanel; 
    
    /** 
     * A demonstration application showing how to pick up mouse clicks on the 
     * legend. 
     * 
     * @param title  the frame title. 
     */ 
    public JMouseListenerDemo4(String title) { 
        super(title); 
        String chartTitle = "Mouse Listener Demo 4"; 
        XYDataset dataset = createDataset(); 
        this.chart = ChartFactory.createXYLineChart(chartTitle, "X", "Y", 
                dataset, PlotOrientation.VERTICAL, true, true, false); 
        chartPanel = new ChartPanel(this.chart); 
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); 
        chartPanel.setMouseZoomable(true, false); 
        chartPanel.addChartMouseListener(this); 
        setContentPane(chartPanel); 
    } 

    /** 
     * Creates a sample dataset. 
     * 
     * @return The dataset. 
     */ 
    public XYDataset createDataset() { 
        XYSeries series = new XYSeries("Series 1"); 
        series.add(12.5, 11.0); 
        series.add(15.0, 9.3); 
        series.add(20.0, 21.0); 
        XYSeriesCollection dataset = new XYSeriesCollection(); 
        dataset.addSeries(series); 
        return dataset; 
    } 

    /** 
     * Receives chart mouse click events. 
     * 
     * @param event  the event. 
     */ 
    public void chartMouseClicked(ChartMouseEvent event) { 
        int mouseX = event.getTrigger().getX(); 
        int mouseY = event.getTrigger().getY(); 
        System.out.println("x = " + mouseX + ", y = " + mouseY);        
        Point2D p = chartPanel.translateScreenToJava2D( 
                new Point(mouseX, mouseY)); 
        XYPlot plot = (XYPlot) chart.getPlot(); 
        //Rectangle2D plotArea = chartPanel.getScreenDataArea(); 
        Rectangle2D plotArea = this.chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea();
        ValueAxis domainAxis = plot.getDomainAxis(); 
        RectangleEdge domainAxisEdge = plot.getDomainAxisEdge(); 
        ValueAxis rangeAxis = plot.getRangeAxis(); 
        RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge(); 
        double chartX = domainAxis.java2DToValue(p.getX(), plotArea, 
                domainAxisEdge); 
        double chartY = rangeAxis.java2DToValue(p.getY(), plotArea, 
                rangeAxisEdge); 
        System.out.println("Chart: x = " + chartX + ", y = " + chartY); 
    } 

    /** 
     * Receives chart mouse moved events. 
     * 
     * @param event  the event. 
     */ 
    public void chartMouseMoved(ChartMouseEvent event) { 
        // ignore 
    } 
    
    /** 
     * Starting point for the demonstration application. 
     * 
     * @param args  ignored. 
     */ 
    public static void main(String[] args) { 
        JMouseListenerDemo4 demo = new JMouseListenerDemo4( 
            "Mouse Listener Demo 4"); 
        demo.pack(); 
        RefineryUtilities.centerFrameOnScreen(demo); 
        demo.setVisible(true); 
    } 

} 
regards,
Happy wei wei.

develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

Post by develop » Mon Nov 14, 2005 10:17 pm

hey wzwei28,

can you give me your email address. so that i can send you code?
its like 3 files and long.

sorry it took time to make demo, actually i was caught up with some other work :(

wzwei28
Posts: 105
Joined: Wed Mar 16, 2005 9:17 am
Location: Malaysia, Earth
Contact:

Post by wzwei28 » Tue Nov 15, 2005 3:15 am

Is ok, brother. Because last week I also busy with other project too. :P

My Yahoo Email is wzwei28@yahoo.com
Hope can have a win win situation...(^0^)

regards,
wei wei.

waisalima
Posts: 1
Joined: Tue Feb 08, 2011 11:45 pm
antibot: No, of course not.

Re: trend lines on mouse event

Post by waisalima » Tue Feb 08, 2011 11:48 pm

Hi develop,

I know it was a long time ago that you did these posts but I'm just starting work on some chart development and was wondering if you still have code you wrote for drag-n-drop trendlines?

If you could post it or email it to me at christian@waisalima.com that would be great and would save me some development time and re-invention of the wheel so to speak.

Thankyou in advance for your assistance.

Regards,


Christian

seess
Posts: 2
Joined: Mon Mar 14, 2011 12:58 pm
antibot: No, of course not.

Re:

Post by seess » Mon Mar 14, 2011 1:01 pm

develop wrote:i also dont have idea about annotation and stuff. I think i will have to digg into details, but for now i will make demo whatever i have and give it to you,

then i will look into the annotation code, also, i am using latest version of jfreechartr4 which is rc1. so i will make demo for that version.

give me some time, and i will make the code ready.
That sounds good, but it is a little difficult to do it. I have similar experience.

tomiu
Posts: 4
Joined: Mon Jun 06, 2011 6:49 pm
antibot: No, of course not.

Re: trend lines on mouse event

Post by tomiu » Mon Dec 26, 2011 1:23 pm

Hello develop,

if you still have the code can you mail it to me too please?

my mail: tomislav11978[at]yahoo.com

Since develop doesn't react, has anyone else he's code???
Thx in advance,
tomiu

zenigata
Posts: 1
Joined: Sun Jun 02, 2013 2:47 pm
antibot: No, of course not.

Re: trend lines on mouse event

Post by zenigata » Sun Jun 02, 2013 2:52 pm

develop wrote:Hi,

when user clicks the mouse and then drags the mouse and then release. on these events on that selected area i need to draw trendlines.

I read some of the Regression classes. but still confuse on how to draw lines on dynamically selected dataArea, My dataset is depends upon user and find out what chart he selected to draw lines. I have combinedDomainXY plot. Please any one can give me idea how to achieve this ...?? :?


Thanks
just override ChartPanel and write painComponent.

@waisalima never, NEVER post your email on the Internet. You are going to receive thousands of phishing/scam emails

@princelee1019 If you still need help with this pm me I am going to send you the source code

maheshlak
Posts: 1
Joined: Tue Sep 22, 2015 8:05 am
antibot: No, of course not.

Re: trend lines on mouse event

Post by maheshlak » Tue Sep 22, 2015 8:20 am

Can someone send me the code
@zenigata: Don't know how to send a message. How can I send you my email?

Locked