CombinedDomainXYPlot: repeat DomainAxis

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
cortesino
Posts: 10
Joined: Mon Aug 11, 2008 7:31 pm

CombinedDomainXYPlot: repeat DomainAxis

Post by cortesino » Wed Aug 20, 2008 7:08 pm

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!

cortesino
Posts: 10
Joined: Mon Aug 11, 2008 7:31 pm

Post by cortesino » Sun Aug 31, 2008 6:19 pm

Anything idea??

cortesino
Posts: 10
Joined: Mon Aug 11, 2008 7:31 pm

Post by cortesino » Tue Sep 30, 2008 8:43 am

up!

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue Sep 30, 2008 9:14 am

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

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

cortesino
Posts: 10
Joined: Mon Aug 11, 2008 7:31 pm

Post by cortesino » Tue Sep 30, 2008 5:28 pm

Thanks!! Work it!

Locked