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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:53:38+00:00 2026-06-09T06:53:38+00:00

When I hide number of series from a chart that is using a CombinedDomainXYPlot,

  • 0

When I hide number of series from a chart that is using a CombinedDomainXYPlot, all range axes are auto rescaled nicely. Howver, the domain axis does not get rescaled. Is there any way to manually refresh scaling, or perhaps there is a setting I am missing to enable auto scaling of a domain axis in this setting?

  • 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-09T06:53:43+00:00Added an answer on June 9, 2026 at 6:53 am

    ANSWERING MY OWN QUESTION:

    I managed to refresh the axis using a little hack:

     mainPlot.getDomainAxis().setAutoRange(false);
     mainPlot.getDomainAxis().setAutoRange(true);
    

    It is not nice but it does the trick. Nevertheless, I wish someone could post a nicer solution…

    Here is the code using non-custom data set that does not work. Please run it and then click on a big button called click multiple times to hide a few series. The domain axis is not rescaled.

    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.List;
    import java.util.Random;
    import javax.swing.*;
    import org.jfree.chart.ChartPanel;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.axis.DateAxis;
    import org.jfree.chart.axis.NumberAxis;
    import org.jfree.chart.event.ChartChangeEvent;
    import org.jfree.chart.event.ChartChangeListener;
    import org.jfree.chart.plot.CombinedDomainXYPlot;
    import org.jfree.chart.plot.PlotOrientation;
    import org.jfree.chart.plot.XYPlot;
    import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
    import org.jfree.chart.renderer.xy.XYItemRenderer;
    import org.jfree.data.xy.XYSeries;
    import org.jfree.data.xy.XYSeriesCollection;
    import org.jfree.ui.RectangleEdge;
    
    public class Runner {
    
        private static Random rand = new Random();
    
        public static void main(String[] args) {
            XYSeriesCollection data = new XYSeriesCollection();
            int max = rand.nextInt(2) + 2;
            for (int i = 0; i < max; i++) {
                data.addSeries(generateSeries("Series" + (i + 1)));
            }
            final XYItemRenderer renderer1 = new StandardXYItemRenderer();
            final XYPlot plot1 = new XYPlot(data, null, new DateAxis("Dates"), renderer1);
    
            data = new XYSeriesCollection();
            for (int i = 0; i < max; i++) {
                data.addSeries(generateSeries("Series" + (i + 1)));
            }
            final XYPlot plot2 = new XYPlot(data, null, new NumberAxis("Numbers"), renderer1);
    
            final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
            plot.setGap(10.0);
    
            // add the subplots...
            plot.add(plot1, 1);
            plot.add(plot2, 1);
            plot.setOrientation(PlotOrientation.VERTICAL);
    
            // return a new chart containing the overlaid plot...
            final JFreeChart chart = new JFreeChart("CombinedDomainXYPlot Demo",
                JFreeChart.DEFAULT_TITLE_FONT, plot, true);
            chart.getLegend().setPosition(RectangleEdge.RIGHT);
    
            chart.addChangeListener(new ChartChangeListener() {
    
                boolean changed = false;
    
                @Override
                public void chartChanged(ChartChangeEvent event) {
                    if (!changed) {
                    } else {
                        changed = false;
                    }
                }
            });
    
            ChartPanel panel = new ChartPanel(chart);
            JPanel panel2 = new JPanel(new BorderLayout(0, 10));
            panel2.add(panel, BorderLayout.CENTER);
            JButton b = new JButton("Click");
            b.addActionListener(new ActionListener() {
    
                @Override
                public void actionPerformed(ActionEvent e) {
                    CombinedDomainXYPlot plot = (CombinedDomainXYPlot) chart.getXYPlot();
                    List l = plot.getSubplots();
                    int index = rand.nextInt(plot1.getSeriesCount() + plot2.getSeriesCount());
                    boolean b = renderer1.isSeriesVisible(index);
                    renderer1.setSeriesVisible(index, false);
                }
            });
            panel2.add(b, BorderLayout.NORTH);
            panel2.setVisible(true);
    
            JFrame frame = new JFrame("dsadsa");
            frame.add(panel2);
            frame.setSize(800, 600);
            frame.setVisible(true);
        }
    
        private static XYSeries generateSeries(String key) {
            XYSeries series = new XYSeries(key);
            int points = 15;
            double val = 0.0;
            double x = 0.0;
            for (int i = 0; i < points; i++) {
                val += rand.nextDouble() * 6 - 3;
                x += rand.nextDouble() * 4;
                series.add(x, val);
            }
            return series;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to hide the number you are calling from through Android's SDK?
I want to create a number of hidden objects via jQuery, that (once all
I need to hide the number of sections and chapters within the files that
Does anyone know how to hide a number of cells from the grouped UITableView
I have a webpage that needs to selectively show or hide a substantial number
I have noticed that a number of iPad apps using an UISearchBar and a
I need to show the number of results for a given category, and hide
I'm trying to hide the Settings area in CRM 2011 such that it is
I can't hide my div using some i.e. explode effect in jquery ui, It
I want to hide the download folder location so that when the user downloads

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.