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

  • Home
  • SEARCH
  • 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

Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I have created a chart using JFreeChart inside a JSP. I want to render
Using Core Data. Let's say we have models for Team and Player. Assume: -Each
I'm using an XYPlot in JFreeChart. All the lines on it are XYSeries objects.
Using online interfaces to a version control system is a nice way to have
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button
Using C#, I need a class called User that has a username, password, active
I am new to using JFreeChart and I'm sure there is a simple solution

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.