Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnyChartView doesnot show at all in UI #219

Open
androidDev2016 opened this issue Mar 5, 2024 · 1 comment
Open

AnyChartView doesnot show at all in UI #219

androidDev2016 opened this issue Mar 5, 2024 · 1 comment

Comments

@androidDev2016
Copy link

When I add this in my layout file of a Fragment in Android Studio:

<com.anychart.AnyChartView
android:id="@+id/anyChartView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
the whole XML file shows blank in the IDE, remove it, all UI components show as expected. Though, I don't get error when adding the above component in the XML file. But when running it, the Pie Chart is not shown at all in screen. Here's the setting in

app/build.gradle:

implementation 'com.github.AnyChart:AnyChart-Android:**1.1.2**'
//implementation('androidx.multidex:multidex:2.0.1') // with or without this line, Pie Chart is not shown in screen

(I noticed it's 1.1.5 in this link: https://github.com/AnyChart/AnyChart-Android/wiki/Getting-started, but my Android Studio is Electric Eel which is on Java 11 instead of 17, so I used 1.1.2)

I have to put "maven { url 'https://jitpack.io' }" in settings.gradle instead of allprojects{ } in root build.gradle to make it build successfully:

include ':app'
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
jcenter()
mavenCentral()
maven {
maven { url 'https://jitpack.io' }
}
}
}

This is how I draw the Pie Chart, pretty much copy from Getting Start link:

private void drawPieChart() {
AnyChartView anyChartView = getActivity().findViewById(R.id.anyChartView);

    Pie pie = AnyChart.pie();

    List<DataEntry> data = new ArrayList<>();
    data.add(new ValueDataEntry("Apples", 6371664));
    data.add(new ValueDataEntry("Pears", 789622));
    data.add(new ValueDataEntry("Bananas", 7216301));
    data.add(new ValueDataEntry("Grapes", 1486621));
    data.add(new ValueDataEntry("Oranges", 1200000));

    pie.data(data);
    anyChartView.setChart(pie);
}

It sounds like it's caused by the fact : the component
<com.anychart.AnyChartView
android:id="@+id/anyChartView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
is not shown in xml layout in design view.

Not sure where to go at this point... Documentation is so limited and ambiguous, searching in web doesn't provide any helpful results at all.

@androidDev2016
Copy link
Author

it looks like I have to set absolute height like this:

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

though the layout file is still blank, but Pie Chart appears when running the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant