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 6208891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:53:04+00:00 2026-05-24T05:53:04+00:00

I need to graph some statistical data inside of someone’s class which extends a

  • 0

I need to graph some statistical data inside of someone’s class which extends a JPanel. Right now the plan is to use paintComponent and the Graphics class as follows:

public void paintComponent(Graphics g) {
    super.paintComponent(g);

    //create a rectangle to represent the outline of the graph
    g.drawRect(300, 50, 400, 350);

    //set up the datapoints
    for(int i = 0; i < data.size(); i++) {
        //put the datapoints where ever they need to go within this rectangle
        g.drawOval(x, y, width, height);
    }
}

Is this terrible for some reason? More importantly, is there some awesome, easy-to-use graphing library I could use but don’t know about?

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-24T05:53:04+00:00Added an answer on May 24, 2026 at 5:53 am

    Your code looks OK to me, other than perhaps placing your x and y points at

    for(int i = 0; i < data.size(); i++) {
        g.drawOval(data.get(i).getX() - width/2, data.get(i).getY() - height/2, 
          width, height);
    }
    

    so that the ovals are centered.

    Also, you might want to consider transforming the data such that the points plotted remain within the boundaries of your graph’s domain and range. Otherwise you could have ovals outside of your rectangle.

    You might want to check out JFreeChart for graphing libraries.

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

Sidebar

Related Questions

I need to show some information in a graph, the data is held in
I need to read some data from an input file and plot a graph
I need some sort of node-graph editor, that hopefully works on both Mac and
I need to have a linked text inside a svg graph. Here is what
Hi I need to graph some arrays to analyse signals, I have a cocoa
I need infinite value to set for some edges in graph that do not
I'm using a simple DirectShow graph to convert some videos to WMV format, which
I have some code that creates a graph using the Bitmap class. The quality
Graph databases store data as nodes, properties and relations. If I need to retrieve
We need to build the javascript-based visual editor (on jQuery) which should edit some

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.