Pie chart android kotlin

Pie chart android kotlin

Android Pie Chart library, supported with Kotlin DSL.

Step 1. Add the JitPack repository to your build file

Step 2. Add the dependency

Also you can use Kotlin DSL for building your chart.

To setup with legend you need an root layout for legend.

Or use with custom legend adapter by inheriting from LegendAdapter

Sample Custom Adapter can be found here

XML Attribute Format Description
app:popupText string Shows text after the slice data value in popup.
app:centerColor color Center color of pie chart.
app:showPopup boolean Show popup when user clicks on pie chart.
app:showPercentage boolean Show percentage of slice beside popupText.
app:animationDuration integer Animation duration with milliseconds.

About

Android Pie Chart library, supported with Kotlin DSL.

Topics

Resources

License

Releases 10

Packages 0

Contributors 3

Languages

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Источник

Line Chart Tutorial using MpAndroidChart in Kotlin

Introduction:

This is a simple LineChart Tutorial. In this tutorial you are going to learn , How to implement LineChart in android using kotlin, For charts we will use awesome library i.e MPAndroidChart for our android app . First start with some dummy data and then use a dynamic one.

Final Preview

Step 1:

Open your build.gradle(app-level) ,and add MpAndroidChart dependency

after that open build.gradle(project-level)

Step 2

Now open your xml file , and add LineChart to it

Step 3

To add data to LineChart, First there is class Entry which represents single entry in the chart with x- and y-coordinate,

As a next step, you need to add the List you created to a LineDataSet object. DataSet objects hold data which belongs together, and allow individual styling of that data.

As a last step, you need to add the LineDataSet object (or objects) you created to a LineData object. This object holds all data that is represented by a Chart instance and allows further styling. After creating the data object, you can set it to the chart and refresh it:

Also to add Dynamic data create a model class Score

Go to your Activity/Fragment file, and add following code ,

Here first we are calling initLineChart() method , It handling the basic settings or we can say preferences for LineChart. After that we are calling setDataToLineChart(). Here we are creating scoreList using Score model as type of list and adding data to list and then pass this data to LineChart.

Источник

Pie chart android kotlin









There is the link of Java version of AAChartCore-Kotlin as follow

AAInfographics is the Kotlin language version of AAChartKit which is object-oriented, a set of easy-to-use, extremely elegant graphics drawing controls,based on the popular open source front-end chart library Highcharts. It makes it very fast to add interactive charts to your mobile projects. It supports single touch-drag for data inspection, multi-touch for zooming, and advanced responsiveness for your apps .

  1. Support Android 、 Kotlin & Java .
  2. Powerful,support the column chart 、 bar chart 、 area chart 、 areaspline chart 、 line chart 、 spline chart 、 radar chart 、 polar chart 、 pie chart 、 bubble chart 、 pyramid chart 、 funnel chart 、 columnrange chart and other graphics.
  3. Interactive、animated, the animation effect is exquisite 、delicate、 smooth and beautiful.
  4. Support chain programming syntax like system framework.
  5. AAChartView + AAChartModel = Chart In the AAInfographics,it follows a minimalist formula: Chart view + Chart model = The chart you want . Just like the other powerful charts framework AAChartKit、AAChartKit-Swift、AAChartCore.

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

Step 2. Add the dependency

You’re all set, enjoy!

  1. Create the instance object of chart view: AAChartView
  1. Configure the properties of chart model: AAChartModel
  1. Draw the chart(This method is called only for the first time after you create an AAChartView instance object)
  1. Finally add this line to your proguard file:

🌹 🌹 🌹 Congratulations! Everything was done. You will get what you want.

Update chart content

if you want to refresh chart content,you should do something as follow.According to your actual needs, select the function that fits you.

  • Only refresh the chart data(This method is recommended to be called for updating the series data dynamically)
  • Refresh the chart, minus the chart data (this method is recommended for subsequent refreshes after the first drawing of graphics has completed. If you want to update the chart data only, you should use the function aa_onlyRefreshTheChartDataWithChartModelSeries )

special area chart one

special area chart two

special area chart three

step area chart

  • Note: The following DEMO picture is a GIF dynamic picture which has a size of around 6M. If you don’t see any dynamic preview, then this is because the picture resources were not fully loaded. In such a case please be patient and wait for the contents to finish loading. Maybe you need to reload this page.

Support user click events and move over events

you can monitor the user touch events message through implementing delegate function for AAChartView instance object

The received touch events message contain following content

Support for custom the style of chart AATooltip through JavaScript function

As we all know, AAInfographics support using HTML String. Most of time, the headerFormat 、 pointFormat 、 footerFormat HTML string is enough for customizing chart tooltip string content, However, sometimes the needs of APP is so weird to satified, in this time, you can even customize the chart tooltip style through JavaScript function.

For example, configuring AATooltip instance object properties as follow:

you can get the customized tooltip style chart like this 👇

Support value range segmentation

chart with value range segmentation bands 🎀

chart with value range segmentation lines 🧶

chart with value range segmentation zones 🧱

Support scrolling update chart data

Support data sorting with animation effect

Supported chart type for now

Supported zoom guesture types for now

Supported animation type for now

Here are the ten concrete animation types of AAInfographics

Back Bounce Circ Cubic Elastic
Expo Quad Quart Quint Sine

AAChartModel:chart basic properties instruction

Property name Description Value Range
title The chart title Any valid string
subtitle The chart subtitle Any valid string
chartType The default series type for the chart. Can be any of the chart types listed under AAChartType . AAChartType.Column,
AAChartType.Bar,
AAChartType.Area,
AAChartType.AreaSpline,
AAChartType.Line,
AAChartType.Spline,
AAChartType.Pie,
AAChartType.Bubble,
AAChartType.Scatter,
AAChartType.Pyramid,
AAChartType.Funnel,
AAChartType.Arearange,
AAChartType.Columnrange
stacking Whether to stack the values of each series on top of each other. Possible values are null to disable, «normal» to stack by value or «percent». When stacking is enabled, data must be sorted in ascending X order AAChartStackingType.None,
AAChartStackingType.Normal,
AAChartStackingType.Percent
symbol A predefined shape or symbol for the marker. When null, the symbol is pulled from options.symbols. Other possible values are «circle», «square», «diamond», «triangle» and «triangle-down» AAChartSymbolType.Circle,
AAChartSymbolType.Square,
AAChartSymbolType.Diamond,
AAChartSymbolType.Triangle,
AAChartSymbolType.TriangleDown
colorsTheme the colors theme of chart style default value is arrayOf(«#fe117c», «#ffc069», «#06caf4», «#7dffc0»)
series the series data of chart a list made of AASeriesElement instance objects ,every AASeriesElement has its own type 、name、data、color、opacity value ect

More detailed chart property setting parameters can be found in the ʻAAChartModel and ʻAAOptions files. For details, please refer to the ʻAAChartCore-Kotlin(AAInfographics)` source code.

Language Version Project Name Source Code Link
Kotlin AAInfographics https://github.com/AAChartModel/AAChartCore-Kotlin
Java AAChartCore https://github.com/AAChartModel/AAChartCore
Swift AAInfographics https://github.com/AAChartModel/AAChartKit-Swift
Objective C AAChartKit https://github.com/AAChartModel/AAChartKit

AAInfographics is available under the MIT license. See the LICENSE file for more information.

  • 🌕 🌖 🌗 🌘 WARM TIPS. 🌑 🌒 🌓 🌔
  • Please contact me on GitHub,if there are any problems encountered in use.
  • GitHub Issues : https://github.com/AAChartModel/AAChartCore-Kotlin/issues
  • And if you want to contribute for this project, please contact me as well
  • GitHub : https://github.com/AAChartModel
  • StackOverflow : https://stackoverflow.com/users/7842508/codeforu
  • JianShu : http://www.jianshu.com/u/f1e6753d4254
  • SegmentFault : https://segmentfault.com/u/huanghunbieguan
  • Support for the user to add delegate events after the graphics content loading was completed
  • Support graphics to refresh global content dynamically
  • Support graphics to refresh pure data ( series ) content dynamically
  • Support color layer gradient effects
  • Support horizontal screen (full screen) effect
  • Support setting graphics rendering animation freely
  • Support for users to configure AAOptions model object properties freely
  • Support stacking the graphics
  • Support reversing the graphics axis
  • Support rendering the scatter chart
  • Support rendering the column range map
  • Support rendering the area range graph
  • Support rendering the polar chart
  • Support rendering the step line chart
  • Support rendering the step area chart
  • Support rendering the rectangular tree hierarchy diagrams
  • Support rendering the circular progress bar chart
  • Support adding clicked event callbacks for graphics
  • Support graphics to refresh pure data in real time and scroll dynamically
  • Support rendered graphics to generate image files
  • Support generating image files saved to the system album

About

📈 📊 ⛰ ⛰ ⛰ An elegant modern declarative data visualization chart framework for Android . Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types.极其精美而又强大的 Android 数据可视化图表框架,支持柱状图、条形图、折线图、曲线图、折…

Источник

Читайте также:  Обзор whatsapp для android
Оцените статью