开发者

Anychart Line chart for Android does not show the line

I am using Anychart for Android to display the total per sub category of grocery items. However, I am having trouble regarding with displaying the line in the line chart. When I hover my mouse, I can see that there were data, but the line is invisible. The data in the chart was from firebase.

Here's my code:

itemList = new ArrayList<>();

Cartesian cartesian = AnyChart.line();

DatabaseReference spendingReference = FirebaseDatabase.getInstance().getReference().child("Customers").child("Inventories").child(FirebaseAuth.getInstance().getUid());

spendingReference.addValueEventListener(new ValueEventListener() {
    @Override
    public void onDataChange(@NonNull DataSnapshot snapshot) {
        List<DataEntry> seriesData = new ArrayList<>();

        int facialTotal = 0;

        for (DataSnapshot yearSnap : snapshot.getChildren()) {

            for (DataSnapshot monthSnap : yearSnap.getChildren()) {

                String monthKey = monthSnap.getKey();

                if (monthKey.equalsIgnoreCase("December")) {

                    for (DataSnapshot cartSnap : monthSnap.getChildren()) {

                        for (DataSnapshot categorySnap : cartSnap.getChildren()) {

                            String categoryKey = categorySnap.getKey();

                            if (categoryKey.equalsIgnoreCase("Beauty & Personal Care")) {

                                for (DataSnapshot subCategorySnap : categorySnap.getChildren()) {

                                    String subCategoryKey = subCategorySnap.getKey();

                                    if (subCategoryKey.equalsIgnoreCase("Facial Products")) {
                                        itemList.clear();

                                        for (DataSnapshot snap : subCategorySnap.getChildren()) {

                                            GroceryItemModelCart groceryItemModelCart = snap.getValue(GroceryItemModelCart.class);
                                            itemList.add(groceryItemModelCart);

                                        }

                                        float totalAve = 0;
                                        for (int i = 0; i < itemList.size(); i++) {
                                            totalAve += Float.parseFloat(itemList.get(i).getGroceryTotalItemPrice());
                                        }

                                        facialTotal = (int) totalAve;

                                    }

                                }

                                seriesData.add( new CustomDataEntry(monthKey, facialTotal));

                            }

                        }

                    }

                }

            }

        }

        cartesian.animation(true);

        cartesian.padding(10d, 20d, 5d, 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("Spending per Beauty & Personal Care Sub-Category");

        cartesian.yAxis(0).title("Expenses in Peso(₱))");
        cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);

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

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

    }

    @Override
    public void onCancelled(@NonNull DatabaseError error) {

    }
});

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

foodSubCategoryAnychart.setChart(cartesian);

}

private class CustomDataEntry extends ValueDataEntry {

CustomDataEntry(String x, Number value) {
    super(x, value);
    //setValue("value2", value2);
}

}

Here's the screenshot of my chart enter i开发者_如何学Cmage description here

As you can see on the image, it does not draw the line on the chart

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜