|
1px gap on line mark |
Posted by djschorn on May-06-2015 17:25 |
|
Hi,
I have a bar chart with a baseline defined on value 100.
I draw a mark on value 100. In some generated charts, the mark is not exactly (see picture in attachment).
aValue = 100;
Mark m = myAxis().addMark(aValue, aColor);
m.setDrawOnTop(false);
myBarLayer.setBaseLine(aValue);
Is this a bug or should I do something to solve my problem ?
Thanks by advance,
|
Re: 1px gap on line mark |
Posted by Peter Kwan on May-07-2015 01:41 |
|
Hi djschorn,
This is a known issue. It is due to the line being exact at a half-pixel boundary, which can
be rounded either way (towards the top or towards the bottom). Due to the inexact nature
of floating point computation, sometimes the rounding become inconsistent.
For your case, one way to work around is to use a trend layer instead of a mark line. The
code is like:
c.addTrendLayer(new double[] {aValue, aValue}, aColor);
Hope this can help.
Regards
Peter Kwan |
Re: 1px gap on line mark |
Posted by djschorn on May-07-2015 21:08 |
|
Thanks for your reply, but this solution doesn't work too.
|
Re: 1px gap on line mark |
Posted by Peter Kwan on May-08-2015 01:31 |
|
Hi djschorn,
I think of another method which should work. You may try to create a bar layer where the
bars is 0.01 in value, and configure the bar to TouchBar, and the border color to the color
you want to use. This should create a horizontal line consistent with the other bar layer.
This "horizontal line" bar layer should be added before your real bar layer so it stays on top.
Hope this can help.
Regards
Peter Kwan |
Re: 1px gap on line mark |
Posted by djschorn on May-11-2015 22:31 |
|
Indeed, it works.
The side effect of this solution is that a new elements appears in the legends..
That's not a real problem for the moment, but in the future probably.
If you have a solution....
Thanks. |
Re: 1px gap on line mark |
Posted by Peter Kwan on May-11-2015 23:09 |
|
Hi djschorn,
When you add the dummy bar layer, please do not provide a name to the data set. If the
name is empty, it should not affect the legend box.
Regards
Peter Kwan |
Re: 1px gap on line mark |
Posted by djschorn on May-12-2015 22:04 |
|
Perfect.
Thanks |
|