#99 Unaligned (right) y axis when two graphs are synchronized

open
UI (33)
5
2014-10-19
2011-10-23
No

See attached files , look a the right axis, they re not aligned (ignore the yellow rectangle, it is me playing with the api :) ).
The cause is simple, when graphs are synchronized, the Graph2D code computes a Graph2D.negociateXChart, which calls calculateXChartStart that updates setPixelXRight of the axe, BUT ONCE the "solution" is found (i.e. the m_xChartEnd) the setPixelXRight is NOT called as it should be.

A fast and ugly fix looks like this (I created a updateSynchronized method), but that gives you the general idea :

private void negociateXChart(final Graphics g2d) {
if (this.m_synchronizedXStartChart != null) {
this.m_xChartStart = Math.max(this.calculateXChartStart(g2d), this.m_synchronizedXStartChart
.calculateXChartStart(g2d));
this.m_xChartEnd = Math.max(this.calculateXChartEnd(g2d), this.m_synchronizedXStartChart
.calculateXChartEnd(g2d));
synchronized (this.m_synchronizedXStartChart) {
this.m_synchronizedXStartChart.m_xChartStart = this.m_xChartStart;
this.m_synchronizedXStartChart.m_xChartEnd = this.m_xChartEnd;
updateSynchronized(this.m_synchronizedXStartChart, this.m_xChartEnd);
}
} else {
if (!this.m_synchronizedXStart) {
this.m_xChartStart = this.calculateXChartStart(g2d);
this.m_xChartEnd = this.calculateXChartEnd(g2d);
}
}
}

private void updateSynchronized(Chart2D other, int value) {
if (other.m_axesYRight.size() > 0) {
IAxis currentAxis;
int axisWidth;
ListIterator<IAxis> it = this.m_axesYRight.listIterator(this.m_axesYRight.size());
while (it.hasPrevious()) {
currentAxis = it.previous();
// axisWidth = currentAxis.getWidth(g2d);
currentAxis.setPixelXRight(value);
// if (currentAxis.isVisible()) {
// result = result - axisWidth;
// }
currentAxis.setPixelXLeft(value);
}
}
}

Moreover, I don't know if this bug appears on other situations (e.g. y axis on the left).

Discussion

  • mmunoztlsefr

    mmunoztlsefr - 2011-10-23
     
  • Achim Westermann

    Hi,
    sorry for the late answer.
    Could you please first submit code to reproduce this... or even better a testcase that shows this (e.g. some method in class TestChartOperatonsVisual)? I won't fix problems I cannot see.

    kind regards,
    Achim

     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks