Hello!
I'm creating a chart with CombinedDomainXYPlot and I need repeat the DomainAxis on top and bottom, but I have problems for this.
In the combinedDomain there are one XYPlot (TimeSeries) creating with ChartFactory.createTimeSeriesChart and some XYPlots (XYIntervalSeriesCollection) with new XYPlot(dataset, null, null, renderer).
In the end I do the next:
Date Axis domainAxis = (DateAxis) cplot.getDomainAxis();
cplot.setDomainAxis(1, domainAxis);
cplot.setDomainAxisLocation(1, AxisLocation.TOP_OR_RIGHT);
but don't show top axis.
Anyone know how to do it?
Thanks!
CombinedDomainXYPlot: repeat DomainAxis
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
I took a look through the CombinedDomainXYPlot code and it seems that it assumes just a single axis. Here's a quick hack that seems to make it work, but without further testing I'm not sure if this breaks anything:
Code: Select all
### Eclipse Workspace Patch 1.0
#P jfreechart-clean
Index: source/org/jfree/chart/plot/CombinedDomainXYPlot.java
===================================================================
--- source/org/jfree/chart/plot/CombinedDomainXYPlot.java (revision 1468)
+++ source/org/jfree/chart/plot/CombinedDomainXYPlot.java (working copy)
@@ -105,14 +105,12 @@
import org.jfree.chart.LegendItemCollection;
import org.jfree.chart.axis.AxisSpace;
-import org.jfree.chart.axis.AxisState;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.event.PlotChangeEvent;
import org.jfree.chart.event.PlotChangeListener;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.data.Range;
-import org.jfree.ui.RectangleEdge;
import org.jfree.ui.RectangleInsets;
import org.jfree.util.ObjectUtilities;
@@ -357,12 +355,18 @@
}
}
else {
- ValueAxis xAxis = getDomainAxis();
- RectangleEdge xEdge = Plot.resolveDomainAxisLocation(
- getDomainAxisLocation(), orientation);
- if (xAxis != null) {
- space = xAxis.reserveSpace(g2, this, plotArea, xEdge, space);
- }
+ //AxisSpace space = new AxisSpace();
+ //space = calculateRangeAxisSpace(g2, plotArea, space);
+ //Rectangle2D revPlotArea = space.shrink(plotArea, null);
+ space = calculateDomainAxisSpace(g2, plotArea, space);
+ //return space;
+
+// ValueAxis xAxis = getDomainAxis();
+// RectangleEdge xEdge = Plot.resolveDomainAxisLocation(
+// getDomainAxisLocation(), orientation);
+// if (xAxis != null) {
+// space = xAxis.reserveSpace(g2, this, plotArea, xEdge, space);
+// }
}
Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
@@ -445,15 +449,16 @@
// set the width and height of non-shared axis of all sub-plots
setFixedRangeAxisSpaceForSubplots(space);
- // draw the shared axis
- ValueAxis axis = getDomainAxis();
- RectangleEdge edge = getDomainAxisEdge();
- double cursor = RectangleEdge.coordinate(dataArea, edge);
- AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info);
- if (parentState == null) {
- parentState = new PlotState();
- }
- parentState.getSharedAxisStates().put(axis, axisState);
+ drawAxes(g2, area, dataArea, info);
+// // draw the shared axis
+// ValueAxis axis = getDomainAxis();
+// RectangleEdge edge = getDomainAxisEdge();
+// double cursor = RectangleEdge.coordinate(dataArea, edge);
+// AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info);
+// if (parentState == null) {
+// parentState = new PlotState();
+// }
+// parentState.getSharedAxisStates().put(axis, axisState);
// draw all the subplots
for (int i = 0; i < this.subplots.size(); i++) {
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

