Workaround for Error in area charts w/stairs w/origin
Workaround for Error in area charts w/stairs w/origin
Hello
Some weeks ago I found a bug and reported to TeeCharts, they are working on it but I need a workaround, the problem is as follows: If you create an area chart with stairs and set the origin on the max value (to see it up side down) the chart doesn't shows fine.
What could be a workaround for this problem? I need an upside down stairs chart, or something like it
Thanks in advance
Some weeks ago I found a bug and reported to TeeCharts, they are working on it but I need a workaround, the problem is as follows: If you create an area chart with stairs and set the origin on the max value (to see it up side down) the chart doesn't shows fine.
What could be a workaround for this problem? I need an upside down stairs chart, or something like it
Thanks in advance
Re: Workaround for Error in area charts w/stairs w/origin
Hi Miguel,
You could use a Bar3D serie sinstead of using an Area series with stairs:
You could use a Bar3D serie sinstead of using an Area series with stairs:
Code: Select all
private void initChart() {
tChart1.getAspect().setView3D(false);
com.steema.teechart.styles.Area area1 = new com.steema.teechart.styles.Area(tChart1.getChart());
area1.fillSampleValues();
area1.setUseOrigin(false);
area1.setOrigin(area1.getMinYValue() + Math.round((area1.getMaxYValue() - area1.getMinYValue()) / 2));
area1.setUseOrigin(true);
area1.setStairs(true);
com.steema.teechart.styles.Bar3D bar1 = new com.steema.teechart.styles.Bar3D(tChart1.getChart());
bar1.setDataSource(area1);
bar1.getMarks().setVisible(false);
bar1.setBarWidthPercent(100);
for (int i=0; i<bar1.getCount(); i++)
{
bar1.getOffsetValues().setValue(i, area1.getOrigin());
}
area1.setActive(false);
tChart1.getAxes().getLeft().setMinMax(bar1.getYValues().getMinimum() - tChart1.getAxes().getLeft().getMinimumOffset(), bar1.getYValues().getMaximum() + tChart1.getAxes().getLeft().getMaximumOffset());
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Workaround for Error in area charts w/stairs w/origin
Hi Yeray, I have a problem with this solution, when I zoom horizontally the first (most left) Bar doesn't show up, do you know how to fix that?
Thanks for the workaround though
Thanks for the workaround though
Re: Workaround for Error in area charts w/stairs w/origin
Hi Miguel,
I've seen that, if you scroll a chart with a Bar series, each bar disappears when half bar is out of the bar (only in the left side of the chart). I've added it to the wish list to be enhanced in future releases (TJ71015425).
To reproduce it you only need a Bar series and scroll a little bit:
could you please confirm if this is what you are experiencing?
I've seen that, if you scroll a chart with a Bar series, each bar disappears when half bar is out of the bar (only in the left side of the chart). I've added it to the wish list to be enhanced in future releases (TJ71015425).
To reproduce it you only need a Bar series and scroll a little bit:
Code: Select all
tChart1.getAspect().setView3D(false);
com.steema.teechart.styles.Bar bar1 = new com.steema.teechart.styles.Bar(tChart1.getChart());
bar1.fillSampleValues(6);
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Workaround for Error in area charts w/stairs w/origin
Hello Yeray
Yes, that's what I'm experiencing
My problem is that I can't wait for a future release Is there another way to get an up side down stairs area chart? or to add the feature myself by editing the source code? maybe regarding the bug TJ71015368 (the source of all of the conversation
Thanks again!
Yes, that's what I'm experiencing
My problem is that I can't wait for a future release Is there another way to get an up side down stairs area chart? or to add the feature myself by editing the source code? maybe regarding the bug TJ71015368 (the source of all of the conversation
Thanks again!
Re: Workaround for Error in area charts w/stairs w/origin
Hi Miguel,
In the meanwhile, a workaround could be to draw manually the hidden portion of the bar:
The code above works for a Bar Series with BarWidhPercent = 100.
In the meanwhile, a workaround could be to draw manually the hidden portion of the bar:
Code: Select all
tChart1.addChartPaintListener(new ChartPaintListener() {
@Override
public void axesPainting(ChartDrawEvent e) {
}
@Override
public void chartPainted(ChartDrawEvent e) {
for(int i=0;i<bar1.getCount()-1;i++)
{
int right = bar1.calcXPos(i+1);
if (tChart1.getAxes().getBottom().getMinimum()>bar1.getXValues().getValue(i) && (right > tChart1.getChart().getChartRect().getLeft()))
{
tChart1.getGraphics3D().getBrush().setColor(bar1.getColor());
tChart1.getGraphics3D().getPen().setColor(bar1.getPen().getColor());
int left = tChart1.getChart().getChartRect().getLeft();
int top = Math.max(bar1.calcYPos(i), tChart1.getChart().getChartRect().getTop());
int bottom = tChart1.getAxes().getLeft().calcPosValue(bar1.getOffsetValues().getValue(0));
tChart1.getGraphics3D().rectangle(left, top, right, bottom);
break;
}
}
}
@Override
public void chartPainting(ChartDrawEvent e) {
}
@Override
public void seriesPainting(ChartDrawEvent e) {
}
@Override
public void seriesPainted(ChartDrawEvent e) {
}
});
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Workaround for Error in area charts w/stairs w/origin
Hi Yeray, the last code doesn't work for me (maybe because I'm using Bar3D)
Do you know where, on the source code, can I deactivate the default 'half out bar disappearance' ?
Do you know where, on the source code, can I deactivate the default 'half out bar disappearance' ?
Re: Workaround for Error in area charts w/stairs w/origin
Hi Miguel,
The workaround proposed works for me in the example I posted some posts above.
The complete example would be this:
If you still have problems with it don't hesitate to let us know.
The workaround proposed works for me in the example I posted some posts above.
The complete example would be this:
Code: Select all
com.steema.teechart.styles.Bar3D bar1;
private void initChart() {
tChart1.getAspect().setView3D(false);
com.steema.teechart.styles.Area area1 = new com.steema.teechart.styles.Area(tChart1.getChart());
area1.fillSampleValues();
area1.setUseOrigin(false);
area1.setOrigin(area1.getMinYValue() + Math.round((area1.getMaxYValue() - area1.getMinYValue()) / 2));
area1.setUseOrigin(true);
area1.setStairs(true);
bar1 = new com.steema.teechart.styles.Bar3D(tChart1.getChart());
bar1.setDataSource(area1);
bar1.getMarks().setVisible(false);
bar1.setBarWidthPercent(100);
for (int i=0; i<bar1.getCount(); i++)
{
bar1.getOffsetValues().setValue(i, area1.getOrigin());
}
area1.setActive(false);
tChart1.getAxes().getLeft().setMinMax(bar1.getYValues().getMinimum() - tChart1.getAxes().getLeft().getMinimumOffset(), bar1.getYValues().getMaximum() + tChart1.getAxes().getLeft().getMaximumOffset());
tChart1.addChartPaintListener(new ChartPaintListener() {
@Override
public void axesPainting(ChartDrawEvent e) {
}
@Override
public void chartPainted(ChartDrawEvent e) {
for(int i=0;i<bar1.getCount()-1;i++)
{
int right = bar1.calcXPos(i+1);
if (tChart1.getAxes().getBottom().getMinimum()>bar1.getXValues().getValue(i) && (right > tChart1.getChart().getChartRect().getLeft()))
{
tChart1.getGraphics3D().getBrush().setColor(bar1.getColor());
tChart1.getGraphics3D().getPen().setColor(bar1.getPen().getColor());
int left = tChart1.getChart().getChartRect().getLeft();
int top = Math.max(bar1.calcYPos(i), tChart1.getChart().getChartRect().getTop());
int bottom = tChart1.getAxes().getLeft().calcPosValue(bar1.getOffsetValues().getValue(0));
tChart1.getGraphics3D().rectangle(left, top, right, bottom);
break;
}
}
}
@Override
public void chartPainting(ChartDrawEvent e) {
}
@Override
public void seriesPainting(ChartDrawEvent e) {
}
@Override
public void seriesPainted(ChartDrawEvent e) {
}
});
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Workaround for Error in area charts w/stairs w/origin
Hi Yeray, I implemented the code with another series plotted (as I have several on my project) and the result is the attachment, it doesn't work for me the fisrt left bar doesn't show up
- Attachments
-
- Example
- Sin título.png (18.75 KiB) Viewed 27307 times
Re: Workaround for Error in area charts w/stairs w/origin
Yeray, the rectangle shows up when I keep the mouse pressed down on the plot :s that's weird
Re: Workaround for Error in area charts w/stairs w/origin
Any ideas for get this to work?
Re: Workaround for Error in area charts w/stairs w/origin
Hi Miguel,
I've only set the Brush and the Pen color to draw the bar portions manually. Assigning the whole bar brush could fix the problem.
Change the following in the example above:
I've only set the Brush and the Pen color to draw the bar portions manually. Assigning the whole bar brush could fix the problem.
Change the following in the example above:
Code: Select all
tChart1.getGraphics3D().setBrush(bar1.getBrush());
//tChart1.getGraphics3D().getBrush().setColor(bar1.getColor());
//tChart1.getGraphics3D().getPen().setColor(bar1.getPen().getColor());
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Workaround for Error in area charts w/stairs w/origin
Hello,
This issue, id TJ71015368, is resolved for inclusion in the next maintenance release.
The problem does not occur in SWT but does occur in Swing although the same underlying graphics calls/libraries are used.
If you wish to apply the fix pending receipt of the maintenance release this is the required modification:
In TeeChart's Graphics3DAWT.java unit, replace the following line:
with
Regards,
Marc Meumann
This issue, id TJ71015368, is resolved for inclusion in the next maintenance release.
The problem does not occur in SWT but does occur in Swing although the same underlying graphics calls/libraries are used.
If you wish to apply the fix pending receipt of the maintenance release this is the required modification:
In TeeChart's Graphics3DAWT.java unit, replace the following line:
Code: Select all
/**
* Draws a Rectangle (Rectangle r).
*
* @param r Rectangle
*/
public void rectangle(Rectangle r) {
Code: Select all
private Rectangle invertNegativeRect(Rectangle r)
{
if (r.width < 0)
{
int tmpL=r.getLeft();
r.setLeft(r.getRight());
r.setRight(tmpL);
}
if (r.height < 0)
{
int tmpT=r.getTop();
r.setTop(r.getBottom());
r.setBottom(tmpT);
}
return r;
}
/**
* Draws a Rectangle (Rectangle r).
*
* @param r Rectangle
*/
public void rectangle(Rectangle r) {
r=invertNegativeRect(r); //TJ71015368
Marc Meumann
Steema Support