Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date Redundance #36

Open
hafiz013 opened this issue Jun 27, 2018 · 0 comments
Open

Date Redundance #36

hafiz013 opened this issue Jun 27, 2018 · 0 comments

Comments

@hafiz013
Copy link

Hi, their support date redundance based on picture I attach and below following code that i follow

` DateFormat fmt1 = new SimpleDateFormat("MMMM dd, yyyy", Locale.US);
Date d1 = null,d2 = null,d3 = null,d4 = null,d5 = null,d6 = null,d7 = null,
d8 = null,d9 = null,d10 = null,d11 = null, d12 = null;

    try {
        d1 = fmt1.parse("January 1,  2018");
        d2 = fmt1.parse("February 1,  2018");
        d3 = fmt1.parse("March 1,  2018");
        d4 = fmt1.parse("April 1,  2018");
        d5 = fmt1.parse("May 1,  2018");
        d6 = fmt1.parse("June 1,  2018");
        d7 = fmt1.parse("July 1,  2018");
        d8 = fmt1.parse("August 1,  2018");
        d9 = fmt1.parse("September 1,  2018");
        d10 = fmt1.parse("October 1,  2018");
        d11 = fmt1.parse("November 1,  2018");
        d12 = fmt1.parse("December 1,  2018");
    } catch (ParseException e) {
        e.printStackTrace();
    }

    graphView = (GraphView)v.findViewById(R.id.graph);

    series = new LineGraphSeries<>(new DataPoint[] {
            new DataPoint(d1, 0),
            new DataPoint(d2, 123.00),
            new DataPoint(d3, 200.00),
            new DataPoint(d4, 145.00),
            new DataPoint(d5, 150.00),
            new DataPoint(d6, 180.00),
            new DataPoint(d7, 0.00),
            new DataPoint(d8, 0.00),
            new DataPoint(d9, 0.00),
            new DataPoint(d10, 0.00),
            new DataPoint(d11, 30.00),
            new DataPoint(d12, 0.00)
    });
    series.setColor(ContextCompat.getColor(getActivity(), R.color.bgwhite));

    //series.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.bgwhite));
    graphView.addSeries(series);

    // set date label formatter
    DateFormat fmt = new SimpleDateFormat("MMM", Locale.US);
    graphView.getGridLabelRenderer().setLabelFormatter(new DateAsXAxisLabelFormatter(getActivity(), fmt));
    graphView.getGridLabelRenderer().setNumHorizontalLabels(12); // only 4 because of the space
    graphView.getGridLabelRenderer().setTextSize(20f);
    graphView.getGridLabelRenderer().setLabelHorizontalHeight(10);

    // set manual x bounds to have nice steps
    graphView.getViewport().setMinX(d1.getTime());
    graphView.getViewport().setMaxX(d12.getTime());

    graphView.getViewport().setXAxisBoundsManual(true);
    //graphView.getViewport().calcCompleteRange();

    // as we use dates as labels, the human rounding to nice readable numbers

// is not necessary
graphView.getGridLabelRenderer().setHumanRounding(false); // show line graph y
whatsapp image 2018-06-27 at 11 44 10 am
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant