Search code examples
androidprogress-baranychart

AnyChart doesn't display progressbar


Toolbar doesn't load before the chart!

After referring to this answer

AnyChartView anyChartView = x.findViewById(R.id.any_chart_view);
    pbar = x.findViewById(R.id.progressBar);
    anyChartView.setProgressBar(pbar);
    FirebaseFirestore db = FirebaseFirestore.getInstance();

    final TagCloud tagCloud = AnyChart.tagCloud();

    tagCloud.setTitle("Programming statisctics");

    OrdinalColor ordinalColor = new OrdinalColor();
    ordinalColor.setColors(new String[] {
            "#26959f", "#f18126", "#3b8ad8", "#60727b", "#e24b26"
    });
    tagCloud.setColorScale(ordinalColor);
    tagCloud.setAngles(new Double[] {-90d, 0d, 90d});

    tagCloud.getColorRange().setEnabled(true);
    tagCloud.getColorRange().setColorLineSize(15d);
   final List<Integer> list = new ArrayList<>();
    list.add(1383220000);
    list.add(1383220000);
    list.add(1316000000);
    list.add(324982000);
    list.add(263510000);
    db.collection("jobs")...
    anyChartView.setChart(tagCloud);

From what I have tried: the progress bar type doesn't matter,nor does if I set the View.Visible.

I am using TagCloud tagCloud = AnyChart.tagCloud(); Update:Layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.dell.ora.ChartFragment">

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />


    <com.anychart.anychart.AnyChartView
    android:id="@+id/any_chart_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    </com.anychart.anychart.AnyChartView>

</RelativeLayout>

If anyone has encountered this problem,please share how you solved it!


Solution

  • According to your code, the progressBar is rendered under anyChartView. All you need is to change the order of elements. Please, try the following code:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.example.dell.ora.ChartFragment">
    
        <com.anychart.anychart.AnyChartView
            android:id="@+id/any_chart_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    
      <ProgressBar
            android:id="@+id/progressBar"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    
    </RelativeLayout>