fthzkrtn / jofc2

Automatically exported from code.google.com/p/jofc2
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Scientific Notation on Big Numbers Breaks Charts #28

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use a very large number as a Y value or call
XAxisLabels.setMat(verylargenumber).

What is the expected output? What do you see instead?
I expect that number to be passed through to the JSON.  Technically, I do.
 But the scientific notation used to represent the number breaks OFC2.

What version of the product are you using? On what operating system?
Using latest jofc2 on Ubuntu.

Please provide any additional information below.
To fix the Y value issue I overrode ScatterChartPointConverter.convert() with:
public void convert(Point o, PathTrackingWriter writer, MarshallingContext
mc) {
        Object xOut = o.getX();
        if (o.getX() instanceof Number){
            String myFormat = ".000";
            DecimalFormat df = new DecimalFormat(myFormat);
            xOut = df.format(o.getX());
        }

        Object yOut = o.getY();
        if (o.getY() instanceof Number){
            String myFormat = ".000";
            DecimalFormat df = new DecimalFormat(myFormat);
            yOut = df.format(o.getY());
        }

        writeNode(writer, "x", xOut, false);
        writeNode(writer, "y", yOut, false);
    }

I haven't yet spent any time fixing the XAxisLabels issue.  For what it's
worth, the issue with both of these arises when I send a date/time to the
chart in unix millis format.  Big numbers.

Original issue reported on code.google.com by reg...@gmail.com on 8 Jun 2009 at 2:49

GoogleCodeExporter commented 9 years ago
I've made a patch to treat bigdecimal values. Just apply this patch and change 
from double/float to bigdecimal

Original comment by edua...@wiseinformatica.com on 14 Jun 2012 at 12:22

Attachments:

GoogleCodeExporter commented 9 years ago
Also you have to enable drop_root_mode on jsonwriter. Patch attached...

Original comment by edua...@wiseinformatica.com on 14 Jun 2012 at 7:24

Attachments: