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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:16:11+00:00 2026-06-13T16:16:11+00:00

I want to rescale a chart but I don’t really know to do it.

  • 0

I want to rescale a chart but I don’t really know to do it. I set to zoom but it is solving my problem.
In fact the data on the plot is displayed in small data.
The code looks like:

public class DrawChart {

private static final Random random = new Random();
RefreshGraph refresh;

public DrawChart(JPanel panel){
    this.refresh = new RefreshGraph();
    this.displayChart (panel);
}

private void displayChart(JPanel jpanel){
    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    Timer timer = new Timer(1000, new ActionListener(){
        @Override
        public void actionPerformed(ActionEvent e){
            refresh.getRefresh (dataset);
        }
    });
    timer.start ();

    JFreeChart chart = createChart(dataset);

    ChartPanel panel=new ChartPanel(chart);
    panel.setPreferredSize (new Dimension(700,300));
    jpanel.setLayout(new java.awt.BorderLayout());
    jpanel.add (panel, BorderLayout.CENTER);
    jpanel.setVisible(true);
}

private JFreeChart createChart(final CategoryDataset dataset){
    final JFreeChart result = ChartFactory.createLineChart ("", null, null, dataset, PlotOrientation.VERTICAL, true, true, false);

    //Set the background color for the chart
    result.setBackgroundPaint (Color.white);

    //get the plot for customization
    final CategoryPlot plot = result.getCategoryPlot ();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.zoom (0.5);

    CategoryAxis domainAxis = plot.getDomainAxis ();
    final IntervalMarker target = new IntervalMarker(0.25, 1.0);

    //This thread will read the tempory file every minutes and refresh the graph
    Timer timer = new Timer(5000, new ActionListener(){
        public void actionPerformed(ActionEvent e){
            boolean eof_=false;
            try{
                File labelingraph = new File(System.getProperty("user.dir")+"\\period.in");
                if(labelingraph.exists ()){
                    BufferedReader readPeriod = new BufferedReader(new FileReader(labelingraph));
                    while(eof_!=true){
                        String _line = readPeriod.readLine ();
                        if(_line!=null){
                            target.setLabel("Period : "+_line);
                        }else{eof_=true;}
                    }
                }
            }
            catch(IOException io){System.out.println ("Error while accessing the file : "+io.getMessage());}
        }
    });
    timer.start ();

    target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11));
    target.setLabelAnchor(RectangleAnchor.LEFT);
    target.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    target.setPaint(new Color(222, 222, 255, 128));
    plot.addRangeMarker(target, Layer.BACKGROUND);

    return result;
}}

The zoom only zooms out the y-axis values and the line graph itself remains steady.
How can I rescale the graph to make have a good visibility ?
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-06-13T16:16:12+00:00Added an answer on June 13, 2026 at 4:16 pm

    I solved this by using these lines of codes

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setRange (1.200, 1.320);
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits ());
    rangeAxis.setTickUnit (new NumberTickUnit(0.005, df, 0));
    

    especially the last line.

    Thanks to all

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

Sidebar

Related Questions

want to know why String behaves like value type while using ==. String s1
Want the function to sort the table by HP but if duplicate HPs then
want to ask user to input something but not want to wait forever. There
I want to achieve the following outcomes: Rescale the size of the bubbles such
I have seen how to draw a shape in Android, but what I want
Want to attach an Event Handler/Listener to some links using the delegate() method, but
Want to know in detail about the purpose of the info Command in redis
I want to use the currency data provided by https://raw.github.com/currencybot/open-exchange-rates/master/latest.json As an initial test,
Want to create web sites with data on Dynamics AX. We want not to
Want to know which CSS styles are currently being used on a web page.

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.