Home >Java >javaTutorial >Why Doesn't Hiding Series Rescale the Shared Domain Axis in a CombinedDomainXYPlot?

Why Doesn't Hiding Series Rescale the Shared Domain Axis in a CombinedDomainXYPlot?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-12-02 12:38:10555browse

Why Doesn't Hiding Series Rescale the Shared Domain Axis in a CombinedDomainXYPlot?

Shared Domain Axis Scaling in CombinedDomainXYPlot

When using a CombinedDomainXYPlot, which combines multiple datasets with a shared domain axis, adjusting the visibility of a series does not automatically rescale the domain axis. This behavior may seem unintuitive, given that the range axes scale accordingly.

Understanding the Issue

CombinedDomainXYPlot establishes a combined maximum range for its shared domain axis to enable axis sharing. Changing the visibility of a series does not affect this shared domain axis. However, updating the dataset triggers a reconfiguration of the shared domain axis, allowing for rescaling.

Solution

To update the shared domain axis manually, use the configure() method of the domain axis. This will force the scaling of the domain axis based on the current dataset and its combined maximum range.

Additional Considerations

  • To automatically update the shared domain axis when adding or removing series, use addSeries() and removeSeries() methods instead of toggling visibility.
  • Ensure proper initialization and packing of the chart to display the changes correctly.

Example Implementation

The code snippet below demonstrates how to manually refresh the scaling of the domain axis using the configure() method:

mainPlot.getDomainAxis().configure();

This should update the domain axis to reflect the current dataset and its combined maximum range. However, toggling setAutoRange() to true after setting the dataset may not have the desired effect since the data and its combined maximum range remain unchanged.

The above is the detailed content of Why Doesn't Hiding Series Rescale the Shared Domain Axis in a CombinedDomainXYPlot?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn