AnyChart-Android icon indicating copy to clipboard operation
AnyChart-Android copied to clipboard

Graph not showng

Open usama143-dev opened this issue 5 years ago • 2 comments

    anyChartView.setProgressBar(prograss);
    Cartesian cartesian = AnyChart.line();

    cartesian.animation(true);

    cartesian.padding(10d, 20d, 35d, 20d);

    cartesian.crosshair().enabled(true);
    cartesian.crosshair()
            .yLabel(true)
            .yStroke((Stroke) null, null, null, (String) null, (String) null);

    cartesian.tooltip().positionMode(TooltipPositionMode.POINT);

    cartesian.title("");

    cartesian.yAxis(0).title("Profit");
    cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);

    List<DataEntry> seriesData = new ArrayList<>();

    for (int g=(data.get(pos).getDays_data().size()-1);g>=0;g--){

        Log.d(TAG, "setupGraph:date "+data.get(pos).getDays_data().get(g).getDate());
        Log.d(TAG, "setupGraph:amount "+Float.parseFloat(data.get(pos).getDays_data().get(g).getAmount()));

        seriesData.add(new CustomDataEntry(data.get(pos).getDays_data().get(g).getDate(), Float.parseFloat(data.get(pos).getDays_data().get(g).getAmount())));
    }

    Log.d(TAG, "setupGraph:graph "+seriesData.size());

    Set set = Set.instantiate();
    set.data(seriesData);
    Mapping series1Mapping = set.mapAs("{ x: 'x', value: 'value' }");

    Line series1 = cartesian.line(series1Mapping);
    series1.name("Hawk SAVE");
    series1.hovered().markers().enabled(true);
    series1.hovered().markers()
            .type(MarkerType.CIRCLE)
            .size(6d);
    series1.tooltip()
            .position("right")
            .anchor(Anchor.LEFT_CENTER)
            .offsetX(5d)
            .offsetY(5d);

    cartesian.legend().enabled(true);
    cartesian.legend().fontSize(15d);
    cartesian.legend().padding(10d, 10d, 10d, 10d);

    cartesian.background().fill("#2b3358");

    anyChartView.setChart(cartesian);
    anyChartView.setBackgroundColor("#2b3358");

my code but its not showing graph.

usama143-dev avatar Apr 11 '20 17:04 usama143-dev

@usama143-dev The chart configuration code is okay, but there's no definition of CustomDataEntry and the resulting data. Please, try to load the chart with dummy data applied manually from the code. Like this:

seriesData.add(new CustomDataEntry("A",  10));
seriesData.add(new CustomDataEntry("B",  12));
// etc

Shestac92 avatar Apr 13 '20 03:04 Shestac92

I tried this simple piece of code but didn't work.

fun prepareChart() { APIlib.getInstance().setActiveAnyChartView(chart) var lineChart = AnyChart.line() val list = ArrayList<DataEntry>() list.add(ValueDataEntry("1", 1)) list.add(ValueDataEntry("2", 3)) list.add(ValueDataEntry("3", 63)) list.add(ValueDataEntry("4", 1326)) list.add(ValueDataEntry("5", 2059)) list.add(ValueDataEntry("6", 7598)) lineChart.data(list) chart.setChart(lineChart) }

Can anyone help

aayum avatar Apr 22 '20 09:04 aayum