Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 501253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:10:14+00:00 2026-05-13T06:10:14+00:00

We are using JFreeChart to make XY plots and we have a feature request

  • 0

We are using JFreeChart to make XY plots and we have a feature request to do a crosshair that moves along with the mouse and highlights the data point that most closely maps to the x-value of the mouse. You can see a similar example at Google Finance – http://www.google.com/finance?q=INDEXDJX:.DJI,INDEXSP:.INX,INDEXNASDAQ:.IXIC.

Those Google charts only highlight the current value (we want to do that and also show crosshairs), but they show the live mouse interaction we are looking for.

Anyone have any elegant suggestions?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:10:15+00:00Added an answer on May 13, 2026 at 6:10 am

    I got this working using a mouse listener and the CrosshairOverlay class. After I get back from holiday travel, I will post my code. It ended up being not too difficult.


    Sorry, I forgot about this!

    First, you want to calculate the x, y values for where you want your crosshair. For me, I wanted it to move along the points of our line, so I calculated the closest x value and used that data pair for x, y.

    Then I call this method:

    protected void setCrosshairLocation(double x, Double y) {
        Crosshair domainCrosshair;
        List domainCrosshairs = crosshairOverlay.getDomainCrosshairs();
        if (domainCrosshairs.isEmpty()) {
            domainCrosshair = new Crosshair();
            domainCrosshair.setPaint(BlueStripeColors.LIGHT_GRAY_C0);
            crosshairOverlay.addDomainCrosshair(domainCrosshair);
        }
        else {
            // We only have one at a time
            domainCrosshair = (Crosshair) domainCrosshairs.get(0);
        }
        domainCrosshair.setValue(x);
    
        if (y != null) {
            Crosshair rangeCrosshair;
            List rangeCrosshairs = crosshairOverlay.getRangeCrosshairs();
            if (rangeCrosshairs.isEmpty()) {
                rangeCrosshair = new Crosshair();
                rangeCrosshair.setPaint(BlueStripeColors.LIGHT_GRAY_C0);
                crosshairOverlay.addRangeCrosshair(rangeCrosshair);
            }
            else {
                // We only have one at a time
                rangeCrosshair = (Crosshair) rangeCrosshairs.get(0);
            }
    
            rangeCrosshair.setValue(y);
        }
    }
    

    Note that crosshairOverlay is an instance of CrosshairOverlay.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make bar chart using jfreechart such that the bars which belong
I have heard of JfreeChart but is there any general steps for using data
I'm using JFreeChart to make a line graph. There are some points that I
I have a time series data which I can draw using jfreechart. the issue
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I'm using JFreeChart to create a chart that has 6 TimeSeries in it. Problem
I have downloaded the latest version of JFreeChart (1.0.14) and want to start using
I have created a chart using JFreeChart inside a JSP. I want to render
Im using netbeans gui editor and im trying to add a Jfreechart that is
Using report builder 3.0, I have a report that queries a cube. How do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.