Skip to content

Entry(x,y) doesn't handle correctly x as milliseconds (unix time) #4024

@pwireless

Description

@pwireless

Entry(x,y) doesn't handle correctly x as milliseconds (unix time)

Did the following simple lines:

        long l1 = System.currentTimeMillis();
        long l2 = l1 + 500;
        Entry e1 = new Entry(l1, 10);
        Entry e2 = new Entry(l2, 10);
        long e1long = (long)e1.getX();
        long e2long = (long)e2.getX();
        Log.d("MEEE2", String.format(Locale.US, "l1 = %d -- e1long = %d,    l2 = %d -- e2long = %d", l1, e1long, l2, e2long));

and the result was :

l1 = 1525979109063 -- e1long = 1525979152384,
l2 = 1525979109563 -- e2long = 1525979152384

i.e. the Entry doesn't handle milliseconds correctly, due to the float being 32-bit FP format.

The LineChartTime class in the MPAndroidChart example, has the example with hours, which then converts to milliseconds in the value formatter. It would be great to have the example with milliseconds instead of hours, as it is more generic.

Entry should be able to accept correctly milliseconds.

A new Entry constructor would be ideal :

Entry e = new Entry(long x, float y);

(in the previous library versions, the addXValue would save the situation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions