1

I am new in coding so apologise in mistakes....

I am working with the GraphView github code. I need to create line and Bar combine into a graph. here I want the max value from line and bar series show on the top of y axis. Currently it not showing as I want.

Here is a code snippet: // 12670 this is max value in bar and line series. 6

public void initGraphNew(GraphView graph) {
        String lll = "12670";[![// this is max value in bar and line series. 6 point value not touching y axis top va][1]][1]lue please check.
        LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[]{
                new DataPoint(1, (double) 6000),
                new DataPoint(2, (double) 5866),
                new DataPoint(3, (double) 7340),
                new DataPoint(4, (double) 10340),
                new DataPoint(5, (double) 1000),
                new DataPoint(6, (double) 12670),
                new DataPoint(7, (double) 3000)
        });
        series.setDrawBackground(false);
        series.setAnimated(true);
        series.setDrawDataPoints(true);
        series.setColor(Color.argb(255, 63, 174, 237));
        BarGraphSeries<DataPoint> series1 = new BarGraphSeries<DataPoint>(new DataPoint[]{
                new DataPoint(1, (double) 5544),
                new DataPoint(2, (double) 10000),
                new DataPoint(3, (double) 1000),
                new DataPoint(4, (double) 2),
                new DataPoint(5, (double) 3400),
                new DataPoint(6, (double) 12670),
                new DataPoint(7, (double) 4000)
        });
        series1.setDrawValuesOnTop(false);
        series1.setValuesOnTopColor(Color.RED);
        graph.getGridLabelRenderer().setTextSize(22f);
        series1.setDataWidth(1d);
        series1.setAnimated(true);
        series1.setColor(Color.argb(255, 247, 100, 10));
        graph.addSeries(series1);
        graph.addSeries(series);
    graph.getViewport().setMinX((double) 0);
    graph.getViewport().setMaxX((double) 7);
    graph.getGridLabelRenderer().setNumHorizontalLabels(8);
    graph.getViewport().setMinY((double) 0);
    graph.getViewport().setMaxY((double) 12670);
    graph.getGridLabelRenderer().setNumVerticalLabels(6);
    StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graph);

    String[] vLables = new String[6];
    double new_value = 12670 / 5;
    double next = 0;
    for (int i = 0; i < 6; i++) {
        if (i == 0) {
            vLables[i] = "";
        } else {
            vLables[i] = ((int) next) + "";
        }
        next = next + new_value;
    }
    staticLabelsFormatter.setVerticalLabels(vLables);
    graph.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter);
    graph.getViewport().setXAxisBoundsManual(true);
    graph.getViewport().setYAxisBoundsManual(false);
    graph.getViewport().setScrollable(true);
    graph.getLegendRenderer().setVisible(false);
    graph.getGridLabelRenderer().setHorizontalLabelsColor(Color.BLACK);
    graph.getGridLabelRenderer().setVerticalLabelsColor(Color.BLACK);
    graph.getGridLabelRenderer().setGridColor(Color.GRAY);
    graph.getGridLabelRenderer().setHighlightZeroLines(false);
    graph.getGridLabelRenderer().setGridStyle(GridLabelRenderer.GridStyle.NONE);
    graph.getViewport().setDrawBorder(true);
}

Here is screenshot: enter image description here

Devil
  • 314
  • 3
  • 13

0 Answers0