Skip to content

Inconsistent behavior with date series #34

Description

@nicolabeghin

Hi everyone
I'm very pleased with the library, great works!

Problem is, I don't understand why it behaves inconsistently, meaning that one time it shows like this (without date X labels and incorrect Y axis rounding)

image
image

in place of the correct display
image

image

I'm following the example Dates.java
https://github.com/jjoe64/GraphView-Demos/blob/master/app/src/main/java/com/jjoe64/graphview_demos/examples/Dates.java

if (story.getId().equals(storyId)) {
    GraphView graph = (GraphView) findViewById(R.id.graph);
    DataPoint[] dataPoints = new DataPoint[story.getMetrics().size()];
    int i = 0;
    for (Story.Metric metric : story.getMetrics()) {
        dataPoints[i] = new DataPoint(metric.getDate(), (int)metric.getConversations());
        i++;
    }
    LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(dataPoints);
    series.setAnimated(true);
    graph.addSeries(series);
    graph.getGridLabelRenderer().setLabelFormatter(new DateAsXAxisLabelFormatter(graph.getContext(), new SimpleDateFormat(LABEL_DATE_FORMAT)));
    graph.getGridLabelRenderer().setNumHorizontalLabels(dataPoints.length);
    // as we use dates as labels, the human rounding to nice readable numbers
    // is not nessecary
    graph.getGridLabelRenderer().setHumanRounding(false);

    // set manual x bounds to have nice steps
    graph.getViewport().setMinX(story.getMetrics().get(0).getDate().getTime());
    graph.getViewport().setMaxX(story.getMetrics().get(story.getMetrics().size() - 1).getDate().getTime());
    graph.getViewport().setXAxisBoundsManual(true);

}

I'm really puzzled..

thanks
nicola

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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