codeandtheory / YCharts

YCharts is a graph library for Android.
Apache License 2.0
604 stars 56 forks source link
android androidchart androidcharts androidgraph androidlibrary barchart chart charts composechart donutchart graph graphs groupchart jetpack-compose jetpack-compose-charts kotlin linecharts pie-chart

YCharts

YCharts is a Jetpack-compose based charts library which enables developers to easily integrate various types of charts/graphs into their existing ui to visually represent statistical data. YCharts supports both cartesian(XY-charts) and polar charts(Radial charts), which include:

A. Cartesian charts:

  1. Line chart

  2. Bar chart

  3. Wave chart

  4. Bubble chart

  5. Combined chart

B.Radial charts:

  1. Pie chart
  2. Donut chart

    It comprises two main modules:

Adding YCharts to your project:

You can add the library via Maven:

Gradle:

implementation 'co.yml:ycharts:2.1.0'

Modules

The following table outlines the modules included in this library:

Artifact Description
axis Includes the horizontal and vertical axis components along with the math engines.
charts Includes the all the chart components i.e: Line, Bar, Combined, Pie & Donut etc. also the math engines
chartcontainer Provides the base container to draw any chart inside it with scroll tap feature etc out of the box.
piechart Includes all the 360' chart components i.e Pie, Donut charts etc.

Sample app

Included in this repository is a sample app with multiple charts with different styling in each section. Studying the source code of the app will give you a deep understanding of how to use YCharts, including customizing and styling the charts. All of the charts i.e line, bar, groupedBar, pie & donut are implemented in the sample app.

Examples

Let's see how we can use the chart components and style them with available customization options.

1. Line Chart:

2. Bar Chart:

3. Grouped Bar Chart:

4. Pie Chart:

5. Donut Chart:

6. Combined Chart:

7. Wave Chart:

8. Bubble Chart:

Accessibility Support

To interact with your device with touch and spoken feedback, you can turn on the TalkBack screen reader. TalkBack describes the graphs/charts when tapped on the graph container. Compose views by deafult supports accessibility services, but for views drawn using canvas has no straight forward approach as of now, hence all our graph components supports an accessibility popup out of the box that will be shown over the graph with tapped on the container, with all the values described in an order to support accessibility services. User will be able to scroll the popup and find all the points, bars, slices or combined values in a descriptive manner, where user can tap and talkback would read it out loud.

fig (a)

fig (b)

Here fig(a) represents the line graph with the container being highlighted & fig(b) represents the accessibility sheet with all values laid out in detail so that talkback can describe the graph values.

Note: All the descriptions that are visible in the accessibility popup can be customized to the required string.

KMM Support.

Changes in version 2.0

License

    Copyright 2022 YCharts

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.