3

When I try to setup a LineGraph containing day/value pairs. The legend gets cropped on the right side. Ie the last ~3 values are shown in the graph but have no entries in the legend.

Is this a bug in the library or am I missing something?

Below is a screenshot of the activity and the code I use for creating the graph

screenshot

        GraphView graph = (GraphView) findViewById(R.id.graph);
        LineGraphSeries<DataPoint> series = new LineGraphSeries<>(points);
        graph.addSeries(series);

        // set date label formatter
        // graph.getGridLabelRenderer().setLabelFormatter(new DateAsXAxisLabelFormatter(HRVViewer.this));
        final DateFormat dateTimeFormatter = DateFormat.getDateInstance();
        graph.getGridLabelRenderer().setLabelFormatter(new DefaultLabelFormatter() {
          @Override
          public String formatLabel(double value, boolean isValueX)
          {
            if( isValueX ) // dateTimeFormatter.format(new Date((long) value));
              return dateTimeFormatter.format(new Date((long) value)); // super.formatLabel(value, isValueX);
            else
              return super.formatLabel(value, isValueX);
          }
        });

        graph.getGridLabelRenderer().setHumanRounding(true);

        // graph.getGridLabelRenderer().setNumHorizontalLabels(Math.min(8, points.length)); // only 4 because of the space
        graph.getGridLabelRenderer().setNumHorizontalLabels(points.length); // only 4 because of the space
        graph.getGridLabelRenderer().setHorizontalLabelsAngle(90);
        graph.getGridLabelRenderer().setTextSize(12);

        // set manual x bounds to have nice steps
        graph.getViewport().setMinX(min_d);
        graph.getViewport().setMaxX(max_d+1);
        graph.getViewport().setXAxisBoundsManual(true);
Goldorak84
  • 3,714
  • 3
  • 38
  • 62
user2912328
  • 171
  • 10

0 Answers0