Charting on Mobile

By pjain      Published Dec. 30, 2019, 7:23 a.m. in blog AI-Analytics-Data   

==== WebView Friendly Others --> REVIEW OF HTML5/JS

JS in WebView

I've also considered using a WebView to use a JavaScript graphing library, but that's just a thought.

  • Also, if you want to get your hands dirty a bit if you don't know JS, you can try http://g.raphaeljs.com/ which has some great charts.

mWeb ---> Sencha Charts

Getting Started

To get started with Sencha Touch Charts download and unzip the Touch Charts package. Touch Charts builds on Sencha Touch, but includes a copy of it so you can get started right away. Once the package has been unzipped, open the index.html file inside of the folder to view the documentation and complete working examples. Any samples that use Ajax will need to be on a web server. Please visit our new Learning Center for product essentials, screencasts, demos, and documentation.

Axes, Titles

http://www.sencha.com/forum/showthread.php?154036-How-to-give-explicit-values-on-Chart-axes

http://www.sencha.com/forum/showthread.php?179802-Set-chart-axes-title-on-create&s=921e36c41bf505ab5cf4e641a8a7c4c6

http://www.sencha.com/forum/showthread.php?173869-Problem-with-Chart-Time-Axis&mode=hybrid

Line Chart, Multiple Y Axis

http://www.sencha.com/forum/showthread.php?127687-Does-Extjs-charts-have-support-for-multiple-y-axis&s=921e36c41bf505ab5cf4e641a8a7c4c6

http://www.sencha.com/forum/showthread.php?72557-Ext-JS-Charts-Second-Y-Axis-Scale&s=921e36c41bf505ab5cf4e641a8a7c4c6

Gauge-Chart

http://www.sencha.com/forum/showthread.php?134940-ExtJS-4-Gauge-Chart-Axes

Remove decimal values on axes

If you have decimal values in numeric axes, if you specify maximum and minimum on axes.

minimum: 0,
maximum: 100,
majorTickSteps :5,
minorTickSteps :5

Here minimum defines minimum allowed value and maximum defines maximum allowed value on axes. Axes will not have value more than maximum. majorTickSteps defines number of steps on axes for example if you specify minimum to 0 and maximum to 100, 0 to 100 are divided in equal five steps according to axes data.

So if you have data in store which can not be distributed equally on axes. It will display decimal values with 10 decimal points. This is annoying when you are crating an application like dashboard and you are displaying more than one charts at a time in panel.

To overcome this problem, override Ext.chart.axis.Axis class method drawAxis as follow.

Ext.override(Ext.chart.axis.Axis, {
    drawAxis: function (init) {
    }
});

Search code of this function in touch-charts-debug.js and paste the same code here and do the following modifications.

Search for the following line in code

me.labels.push(+(me.labels[me.labels.length - 1] + step).toFixed(10));

Change parameter in toFixed function to 0

me.labels.push(+(me.labels[me.labels.length - 1] + step).toFixed(0));

That's it and you will have integer values in charts.

Setting Axis, Chart Title

How do I dynamically change a chart's axis title? I would like to change the title on the bottom axis of a column chart. I would like to do this when a user clicks on a column in the chart. I have a listener set up but what code do I put in there to update the title?

axes: [{
        type: 'Numeric',
        position: 'left',
        fields: ['total'],
        title: false,
        grid: true
}, {
        type: 'Category',
        position: 'bottom',
        fields: ['title'],
        title: 'Title to be Changed Dynamically'                       
}],
series: [{
    type: 'column',
    axis: 'left',    
    listeners: {
        itemmousedown: function(o){
            //what goes here to update title of bottom axis?
        }
    }
}]

//ANSWER .. 
var ba = this.chart.axes.get('bottom');
ba.setTitle('new title');

Dash, Gauge

  • Basics
  • http://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/charts/Gauge.html

Ext.require(['Ext.chart.', 'Ext.chart.axis.Gauge', 'Ext.chart.series.', 'Ext.Window']);

Ext.onReady(function () {

Ext.create('Ext.Window', {
    width: 800,
    height: 250,
    minWidth: 650,
    minHeight: 225,
    title: 'Gauge Charts',
    tbar: [{
        text: 'Reload Data',
        handler: function() {
            store1.loadData(generateData(1));
            store3.loadData(generateData(1));
            store4.loadData(generateData(1));
        }
    }],
    layout: {
        type: 'hbox',
        align: 'stretch'
    },
    items: [{
        xtype: 'chart',
        style: 'background:#fff',
        animate: {
            easing: 'elasticIn',
            duration: 1000
        },
        store: store1,
        insetPadding: 25,
        flex: 1,
        axes: [{
            type: 'gauge',
            position: 'gauge',
            minimum: 0,
            maximum: 100,
            steps: 10,
            margin: -10
        }],
        series: [{
            type: 'gauge',
            field: 'data1',
            donut: false,
            colorSet: ['#F49D10', '#ddd']
        }]
    }, {
        xtype: 'chart',
        style: 'background:#fff',
        animate: true,
        store: store3,
        insetPadding: 25,
        flex: 1,
        axes: [{
            type: 'gauge',
            position: 'gauge',
            minimum: 0,
            maximum: 100,
            steps: 10,
            margin: 7
        }],
        series: [{
            type: 'gauge',
            field: 'data1',
            donut: 30,
            colorSet: ['#82B525', '#ddd']
        }]
    }, {
        xtype: 'chart',
        style: 'background:#fff',
        animate: {
            easing: 'bounceOut',
            duration: 500
        },
        store: store4,
        insetPadding: 25,
        flex: 1,
        axes: [{
            type: 'gauge',
            position: 'gauge',
            minimum: 0,
            maximum: 100,
            steps: 10,
            margin: 7
        }],
        series: [{
            type: 'gauge',
            field: 'data1',
            donut: 80,
            colorSet: ['#3AA8CB', '#ddd']
        }]
    }]
}).show();

});

Display Options

Put label in base of chart - to appear in donut

  • http://www.sencha.com/forum/showthread.php?198698-Set-size-of-axes-title-using-chart-gauge

I would like to; 1) Increase the size of the title and numeric indexes on the gauge. 2) Append a number from ['calls'] to the end of the axes title and refresh each time the store is reloaded via ajax. 3) Append the value from ['calls'] (What the gauge is based on) to the axes title.

Ext.create('Ext.Window', { width: 400, height: 250, maximizable: true, title: '<?=$CCTrimmed?>', renderTo: Ext.getBody(), layout: { type: 'hbox', align: 'stretch' }, items: [{ xtype: 'chart', style: 'background:#B3D2FF', animate: { easing: 'elasticIn', duration: 1000 }, store: cc<?=$CCTrimmed?>Store, insetPadding: 25, flex: 1, axes: [{ type: 'gauge', position: 'gauge', minimum: 0, maximum: 10, steps: 10, margin: -10, title: '<?=$CCTrimmed?>' }], series: [{ type: 'gauge', title: '<?=$CCTrimmed?>', field: ['calls'], donut: false, colorSet: ['#3AA8CB', '#ddd'], label: { field: '<?=$CCTrimmed?>', display: 'middle', renderer: Ext.util.Format.numberRenderer('0'), color: '#333', 'text-enchor': 'middle' } }] }] }).show();

Gauge Chart Step Labels

  • don't display properly and if you resize the chart the labels appear all over the place and multiply.

Event Handling

Did you try using interactions for charts/?

Tap event caputre

  • How to catch "tap" event for chart "gauge"

Ext.define("TBB.util.gaugeChart", {
extend: "Ext.chart.Chart",
xtype: "gaugechart",
config: {
xtype: 'gaugechart', id: 'gaugechart', style: 'background:#F3F4E7', height: 180, insetPadding: 20, animate: { easing: 'elasticIn', duratuion: 5000 }, store: 'TbbPs2Store', axes: [ { type: 'gauge', position: 'gauge', title: '', steps: 10, minimum: 0, maximum: 100, margin: -16, label: { font: "0.7em 'Helvetica Neue', HelveticaNeue, Helvetica-Neue, Helvetica, 'BBAlpha Sans', sans-serif", contrast: true } } ], series: [ { type: 'gauge', angleField: 'ps', donut: 90, colorSet: ['#3FFF00', '#ddd'], listener:{ itemtap: function(){ debugger; } } } ] }, initialize: function() { this.callParent(arguments); } });

Ext.define("TBB.view.kontod.KontodMain",{ extend: 'Ext.Panel', xtype: 'KontodMainPanel',

config: {
    locales : {
        title : 'kontod.toolbarTitle',
        loadingText : 'loadmask.text'
    },
        style: 'background:#F3F4E7',
    scrollable: true,
    items: [
        {
            xtype: 'panel',
            flex: 1,
            margin: '15 0 0 0', 
           style: 'background:#F3F4E7',
           items: [
                {
                        xtype:'gaugechart'
                    } ,
                    {
                        xtype: 'image', 
                       src: "resources/images/tbb-logo-s@2x.png",
                        centered: true,
                        style: 'background-size: 100% 100%;',
                        width: 70,
                        height: 70,
                        margin: '85 0 0 0',
                    }
                ]
        },
        {
            xtype: 'list',
            id: 'kontodMainList',
            flex:1,
            loadingText: '',
            masked: false,
            disableSelection: true,
            scrollable      : false,
            itemTpl: new Ext.XTemplate(
                '&lt;tpl if="order[0] == \'A\'"&gt;',
                    '&lt;div style="display: none;"&gt;{ps}%&lt;/div&gt;',
                '&lt;tpl else&gt;',
                    '&lt;div style="text-align:center;"&gt;{ps}%&lt;br /&gt;&lt;span style="font-size:0.5em"&gt;{nickname}&lt;/span&gt;&lt;/div&gt;',
                '&lt;/tpl&gt;'
            )
        }
    ]
},
initialize: function() {
    this.callParent(arguments);
    this.down('list').setStore(Ext.create('TBB.store.Pss'));
    var store = this.down('list').getStore();
    store.removeAll(true);
    store.sync();
}

});

=== Android Charting

Andr mpChart- MAJOR

Mp Android Chart

PhilJay/MPAndroidChart: A powerful Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging and animations. Date on X axis. · Issue #789 · PhilJay/MPAndroidChart Android | Study Tutorial Android Pie Chart using MpAndroid Library Tutorial | Study Tutorial Android Bar Chart or Bar Graph using MpAndroid Library Tutorial | Study Tutorial android - DateTime axis in MPAndroidChart - Stack Overflow android - MPAndroidChart LineChart: Using dates instead of Strings for X-axis - Stack Overflow

MpAndroid

MAIN: https://github.com/PhilJay/MPAndroidChart https://github.com/PhilJay/MPAndroidChart/wiki/Getting-Started good code.tutsplus.com/tutorials/add-charts-to-your-android-app-using-mpandroidchart--cms-23335 Android Beginner Tutorial #17 – Graphing With An Android Chart Library Creating a Simple Bar Graph for your Android Application (part 1/2) Creating a Simple Bar Graph for your Android Application (part 2/2) Creating a Line Graph with multiple data sets in Android Studio Creating a Simple Pie Chart in Android Studio

MpAndroid Realm

MPAndroidChart-Realm

Custom GraphView in Android

Creating a Simple Graph in Android Studio with GraphView https://www.youtube.com/watch?v=zbTvJZX0UDk Changing the View Window with Androids GraphView Library https://www.youtube.com/watch?v=U8tSRB_DwB4 Plotting Multiple Data Sets and Adding Focus Points with GraphView https://www.youtube.com/watch?v=KIWLVSqugJo Making a Scatter Plot (Android GraphView Lib) https://www.youtube.com/watch?v=DmUBnD2MQ6c OnClickListener Scatter Plot (Android GraphView Lib) https://www.youtube.com/watch?v=Ih6YV4GRXOM Adding Data Points in REAL-TIME to a Graph (Android GraphView Lib) https://www.youtube.com/watch?v=XwAmzQtGnTE

Android NATIVE CHARTS

Open source Android chart library with line chart, graph (fillable), histogram, pie chart, radar map, a total of 5 kinds of chart types. And can combine charts. https://github.com/Idtk/SmallChart https://github.com/Idtk/PieChart

achartengine - MAJOR

Achartengine of the line chart --- simple usage - AexLinda column - CSDN blog Achartengin use - AexLinda's column - CSDN blog

  • https://github.com/ddanny/achartengine
  • Flot https://github.com/dengn/flot-android-chart

https://acadgild.com/blog/achartengine-android-application/

Flotr2 - MAJOR

  • shape diagram https://github.com/liuzc/Flotr2Demo_Android

GChart

  • PHP - https://github.com/segy/GoogleChart

Charting Custom

https://github.com/hotpro/InteractiveChart-AS

  • Point/Line series .. https://github.com/JesusM/ChartView

  • !IMP Gfit like Circurlar

  • https://github.com/bmarrdev/fauxfit-decoview-sample
  • https://github.com/txusballesteros/fit-chart

  • Polar https://github.com/aurelhubert/polarchart/issues

MPAndroidChart - MAJOR

  • 5/16 RECENT MPAndroidChart - A powerful Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging and animations. https://github.com/PhilJay/MPAndroidChart

Add Charts to Your Android App Using MPAndroidChart Updated on Feb 15, 2015 https://github.com/tutsplus/Android-MPAndroidChart

https://github.com/PhilJay/MPAndroidChart

AChartEngine

  • This is a charting software library for Android applications HoloGraphLibrary - Newer graphing library

Others

EazeGraph - Another newer library with potential AndroidCharts - Easy to use charts AndroidGraphView - library to create flexible and nice-looking diagrams. AndroidPlot - plotting library for Android WilliamChart - Flexible charting library with useful motion capabilities. HelloCharts - Charts/graphs library for Android with support for scaling, scrolling and animations.

OceanLife v2.2 is out! Flashier charts, faster syncs, a load of refactoring, bug fixes & missed sleep. @JakeWharton's Dagger retrofit next. - v2.2 swell-period chart. - Tidal curve interpolation in OceanLife v2.2.

Custom Charting

  • SIMPLE DRAW
  • http://www.androidhub4you.com/2013/05/custom-bar-chart-in-android-dynamic.html http://www.androidhub4you.com/2013/05/bar-chart-example-in-android-simple-bar.html

Charting

  • https://github.com/ecgreb/hello-pizza-chart
  • https://github.com/sujith551/googlecharts
  • https://github.com/gilsomanfredi/graficos-android-google-charts
  • JS
  • https://github.com/muthuprabhu-kp/AndroidGoogleChartlib

MPAndroidChart Code

rOS Andr Charting, Dashboard

Android native Charting

!ok ~Andr/charting/MPAndroidChart !ok All rages - fragments & gridview ~zAndr/aCoreUIFragments/AllTheRages !ok ~zAndr/MaterialUXDTabs/MaterialTabs

  • mpandroid - disabled due to versions
  • Bar

MPAndroidChart/LineChartTime.java at master · PhilJay/MPAndroidChart MPAndroidChart/LineChartActivity2.java at 3398cf4462bc7f49bb1156ef22040e8a0d63369f · PhilJay/MPAndroidChart MPAndroidChart/LineChartActivity1.java at 23e0178dbbf873f4dcc99f94a77b8fa2af7aa224 · PhilJay/MPAndroidChart MPAndroidChart/MainActivity.java at a3c1fe6bbf7d48b79b42b3a447f946af850d86f0 · PhilJay/MPAndroidChart mpandroid time series example - Google Search android - Timeseries chart in MPAndroidChart - Stack Overflow android - Handling the timeseries graph in MPAndroid Chart - Stack Overflow .java Highest Voted 'mpandroidchart' Questions - Stack Overflow Plot time series on android - Google Search android - Timeseries chart in MPAndroidChart - Stack Overflow Androidplot Building a streaming chart in Android | shinobicontrols java - How to plot a graph with Time in x-axis and value on the other in android? - Stack Overflow Android Graph View plotting library appsthatmatter/GraphView: Android Graph Library for creating zoomable and scrollable line and bar graphs. GraphView Demos - Android Apps on Google Play

  • GraphView - line,bar .. https://github.com/appsthatmatter/GraphView

Core Examples, Tutes

Resources, Official

Official

  • Andr Core: github.com/PhilJay/MPAndroidChart https://github.com/PhilJay/MPAndroidChart/wiki https://jitpack.io/com/github/PhilJay/MPAndroidChart/v3.0.2/javadoc/ https://stackoverflow.com/search?q=mpandroidchart

  • IOS Version Tips

  • https://github.com/danielgindi/Charts

Realm.io Interation

MPAndroidChart-Realm allows to directly plot / draw data from Realm.io mobile database. https://github.com/PhilJay/MPAndroidChart-Realm

Conceptual

  • Include

  • https://www.studytutorial.in/android-line-chart-or-line-graph-using-mpandroid-library-tutorial

DISPLAY OPTIONS

  • LineDataSet dataset = new LineDataSet(entries, "# of Calls"); LineData data = new LineData(labels, dataset);

    dataset.setColors(ColorTemplate.COLORFUL_COLORS); dataset.setDrawCubic(true); dataset.setDrawFilled(true);

    LineChart lc = ..; lc.setData(data); lc.animateY(5000); //ACTUALLY DRAW

  • Animations

  • Y Axis animation - bottom to up in 5 secs lc.animateY(5000); //ACTUALLY DRAW duration (in milliseconds) of the animation

  • X Axis animation - lc.animateX(2500, Easing.EasingOption.EaseInOutQuart);

  • animateXY method is used to animate both axes of the chart

Data Techniques

  • Upper & Lower Limit on YAxis given a LineChart lc

    LimitLine upper_limit = new LimitLine(130f, "Upper Limit"); upper_limit.setLineWidth(4f); upper_limit.enableDashedLine(10f, 10f, 0f); upper_limit.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_TOP); upper_limit.setTextSize(10f);

    LimitLine lower_limit = new LimitLine(-30f, "Lower Limit"); lower_limit.setLineWidth(4f); lower_limit.enableDashedLine(10f, 10f, 0f); lower_limit.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_BOTTOM); lower_limit.setTextSize(10f);

    YAxis leftAxis = lc.getAxisLeft(); // reset all limit lines to avoid overlapping lines leftAxis.removeAllLimitLines(); leftAxis.addLimitLine(upper_limit); leftAxis.addLimitLine(lower_limit); leftAxis.setAxisMaxValue(220f); leftAxis.setAxisMinValue(-50f); //leftAxis.setYOffset(20f); leftAxis.enableGridDashedLine(10f, 10f, 0f); leftAxis.setDrawZeroLine(false); leftAxis.setDrawLimitLinesBehindData(true); // limit lines are drawn behind data (and not on top)

    lc.getAxisRight().setEnabled(false);

  • Make Chart full screen

    onCreate getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_main);

Abstracting & Separting drawing from Model Data

  • FindView & Link to chart - pass it in t

    private LineChart mChart; onCreate super.onCreate(savedInstanceState); mChart = (LineChart) findViewById(R.id.linechart); //-- DailyHealthLog.weightSu ArrayList yentries = new ArrayList<>(); yentries.add(new Entry(4f, 0)); yentries.add(new Entry(8f, 1)); yentries.add(new Entry(6f, 2)); yentries.add(new Entry(2f, 3)); yentries.add(new Entry(18f, 4)); yentries.add(new Entry(9f, 5));

    ArrayList&lt;String&gt; xlabels = new ArrayList&lt;String&gt;();
    xlabels.add("January");
    xlabels.add("February");
    xlabels.add("March");
    xlabels.add("April");
    xlabels.add("May");
    xlabels.add("June");
    wtLineChart(mChart,yentries,xlabels);
    

    public void wtLineChart(LineChart lc, ArrayList entries,ArrayList labels) { //Simple weight chart with ALL data ..

    LineDataSet dataset = new LineDataSet(entries, "# of Calls");
    LineData data = new LineData(labels, dataset);
        //DISPLAY OPTIONS
        dataset.setColors(ColorTemplate.COLORFUL_COLORS); //
        dataset.setDrawCubic(true);
        dataset.setDrawFilled(true);
    
    lc.setData(data);
    lc.animateY(5000); //ACTUALLY DRAW
    

    }

MPAndroidChart Code Examples

MPAndroidChart A+ - IOS also, Realm.io

If motion takes an important role in your app design. In other hand if you want featured charts, then go for MPAndroidChart.

Also available for iOS: Charts (API works the same way) https://github.com/danielgindi/Charts

To powerful Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging and animations.Use this. https://github.com/PhilJay/MPAndroidChart

comprehensive charting, zooming, animating features. (but not so fancy name)

  • DEMOS Example Project (code for demo-application) Google-PlayStore Demo Application

  • https://play.google.com/store/apps/details?id=com.xxmassdeveloper.mpchartexample CODE FOR DEMO APP: https://github.com/PhilJay/MPAndroidChart/tree/master/MPChartExample ABOUT: https://code.tutsplus.com/tutorials/add-charts-to-your-android-app-using-mpandroidchart--cms-23335

TUTES

  • CORE: https://github.com/PhilJay/MPAndroidChart/wiki/Getting-Started https://dzone.com/articles/mpandroidchart-library-charts

  • LINE: dnumetriclabz.com/android-line-chart-using-mpandroidchart-tutorial/ https://www.reddit.com/r/androiddev/comments/340417/create_a_real_time_line_graph_in_android_with/ http://stackoverflow.com/questions/25418438/android-line-chart-issue-using-mpandroidchart-and-androidplot-api

  • COMBINED http://stackoverflow.com/questions/31056095/mpandroidchart-combined-chart

LineChart, BarChart (vertical, horizontal, stacked, grouped), PieChart, ScatterChart, CandleStickChart (for financial data), RadarChart (spider web chart), BubbleChart Combined Charts (e.g. lines and bars in one) Scaling on both axes (with touch-gesture, axes separately or pinch-zoom) Dragging / Panning (with touch-gesture) Separate (dual) y-axes Highlighting values (with customizeable popup-views) Support for dynamic & realtime data plotting Save chart to SD-Card (as image) Predefined color templates Legends (generated automatically, customizeable) Customizeable Axes (both x- and y-axis) Animations (build up animations, on both x- and y-axis) Limit lines (providing additional information, maximums, ...) Listeners for touch, gesture & selection callbacks Fully customizeable (paints, typefaces, legends, colors, background, dashed lines, ...) Smooth rendering for up to 30.000 data points in Line- and BarChart Lightweight (method count ~1.4K) Available as .jar file (only 500kb in size) Available as gradle dependency and via maven Good documentation Widely used, great support on both GitHub and stackoverflow - mpandroidchart

Realm.io

mobile database support via MPAndroidChart-Realm library https://realm.io/ https://github.com/PhilJay/MPAndroidChart-Realm

Line Chart Examples

Bar Chart - works - no db connection

public void createRandomBarGraph(String Date1, String Date2){
    barChart = (BarChart) findViewById(R.id.bargraph);
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");
    try {
        Date date1 = simpleDateFormat.parse(Date1);
        Date date2 = simpleDateFormat.parse(Date2);

        Calendar mDate1 = Calendar.getInstance();
        Calendar mDate2 = Calendar.getInstance();
        mDate1.clear();
        mDate2.clear();

        mDate1.setTime(date1);
        mDate2.setTime(date2);

        dates = new ArrayList&lt;&gt;();
        dates = getList(mDate1,mDate2);

        barEntries = new ArrayList&lt;&gt;();
        float max = 0f;
        float value = 0f;
        random = new Random();
        for(int j = 0; j&lt; dates.size();j++){
            max = 100f;
            value = random.nextFloat()*max;
            barEntries.add(new BarEntry(value,j));
        }

    }catch(ParseException e){
        e.printStackTrace();
    }

    BarDataSet barDataSet = new BarDataSet(barEntries,"Dates");
    BarData barData = new BarData(dates,barDataSet);
    barChart.setData(barData);
    barChart.setDescription("My First Bar Graph!");

}

Line Chart - crashes

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.charts.BarChart;
import com.github.mikephil.charting.data.BarData;
import com.github.mikephil.charting.data.BarDataSet;
import com.github.mikephil.charting.data.BarEntry;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.utils.ColorTemplate;
LineChart lineChart = (LineChart) findViewById(R.id.bgchart);

        // creating list of entry
    ArrayList&lt;Entry&gt; entries = new ArrayList&lt;&gt;();
    entries.add(new Entry(4f, 0));
    entries.add(new Entry(8f, 1));
    entries.add(new Entry(6f, 2));
    entries.add(new Entry(2f, 3));
    entries.add(new Entry(18f, 4));
    entries.add(new Entry(9f, 5));
    LineDataSet dataset = new LineDataSet(entries, "# of Calls");
    dataset.setColors(ColorTemplate.COLORFUL_COLORS); //
    // dataset.setDrawCubic(true);
    dataset.setDrawFilled(true);
  LineData data = new LineData(dataset); // was new LineData(labels, dataset);
    lineChart.setData(data);
    // lineChart.animateY(5000);
    //lineChart.invalidate(); // refresh

Android OTHERS

rost OTHERS

  • SOURCES & Comparisons - A+ https://android-arsenal.com/tag/40

http://rpiesnikowski.blogspot.in/2011/03/android-candlestick-chart-with-google.html

http://www.appbrain.com/stats/libraries/tag/chart/chart-libraries MPAndroidChart 1.7% of installs AChartengine 0.53% AndroidPlot 0.1% ooking at the usage metrics on http://appbrain.com, currently AChartEngine is used by 0.61% of the 700K applications while AndroidPlot is used by 0.17%. All the other metrics show an even higher difference in usage. Hmmmm.... http://www.appbrain.com/stats/libraries/details/achartengine http://www.appbrain.com/stats/libraries/details/androidplot

PhilJay/MPAndroidChart: A powerful Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging and animations. mpandroidchart LineData api change - Google Search Setting Data · PhilJay/MPAndroidChart Wiki Adding Entries or DataSets dynamically (real time graph) · Issue #87 · PhilJay/MPAndroidChart Getting Started · PhilJay/MPAndroidChart Wiki DataSet classes in detail · PhilJay/MPAndroidChart Wiki How to add String label to x and y axes? · Issue #234 · PhilJay/MPAndroidChart LineData constructor doesn't have string value entry anymore?? · Issue #1956 · PhilJay/MPAndroidChart

Passing value from activity to Android webview for Javascript method Passing data between activities Android JSON Parser Intent.getByteArrayExtra Android code examples | Codota android webview Best way to pass array data - Google Search Collecting and Processing Barcode Data in an Android WebView Using the EPX Barcode Scanning Framework and a JavascriptInterface - SDG Blog Bridge Android WebView with native Mobile Engagement Android SDK | Microsoft Docs Calling Objective-C code from JavaScript in iOS applications | Ram\'s Blog Using Web Content | The Android Developer's Cookbook: Networking | InformIT Using Web View in Android and Loading Data Over network | Technology Portal Advanced Uses of WebView javascript - Passing array from js to android - Stack Overflow android - Passing Array from Activity to Javascript - Stack Overflow java - Passing a JavaScript object using addJavascriptInterface() on Android - Stack Overflow : Recipe Exchanging Array Data between Java and JavaScript (Recipe 4426, Revision 4427) | Android Tutorial Pass complex object or array to WebView to be used in JavaScript — Xamarin Forums Using XML and JSON with Android, Part 2: Deliver hybrid Android applications with JSON Building Web Apps in WebView | Android Developers java - Webview with JavaScript interface - Stack Overflow java - Passing an array of values from Android Activity to JavaScript in a WebView - Stack Overflow Pass an array from android to JavaScript - Stack Overflow

r Data VIZ Native Android <-- MpCharts + Custom

Data Visualization with Python and JavaScript: ProQuest Tech Books

AChart Engine

Android Drawing Time Chart with TimeSeries in AChartEngine | Knowledge by Experience

achartengine.org

  • Line chart with cubic curve fit EX: http://code.google.com/p/achartengine/

  • it supports all kinds of graphs (line, bar, pie etc.) and provides a sample demo which makes it pretty easy to start off with.

Lots of Functionality to make better. Pan Enable of both side. XYMultipleSeriesRenderer support lots of method various option to set the graph method to set style

  • PIE Chart tutre
  • http://stackoverflow.com/questions/20835628/how-to-draw-a-pie-chart-in-android

  • Simple Bar http://www.appbrain.com/stats/libraries/tag/chart/chart-libraries

  • Stacked http://code.google.com/p/achartengine/source/browse/trunk/achartengine/demo/org/achartengine/chartdemo/demo/chart/SalesStackedBarChart.java I suggest you download the AChartEngine demo source code and take a look at SalesStackBarChart. Then, on the last line, you can change Type.STACKED to Type.HEAP for an even better stacked bar charts experience.

LineChart - Shows but not connected to DB

/this is for achartEndinge Line Chart // private String[] mMonth = new String[] { "Jan", "Feb" , "Mar", "Apr", "May", "Jun", "Jul", "Aug" , "Sep", "Oct", "Nov", "Dec" }; private void drawChart(){ int[] x_values = { 1,2,3,4,5,6,7,8 }; int[] y_values = { 1000,1500,1700,2000,2500,3000,3500,3600}; // Creating an XYSeries for Expense XYSeries expenseSeries = new XYSeries("Expense"); // Adding data to Expense Series for(int i=0;i<x_values.length;i++){ expenseSeries.add(x_values[i], y_values[i]); } // Creating a dataset to hold each series XYMultipleSeriesDataset xyMultipleSeriesDataset = new XYMultipleSeriesDataset(); // Adding Expense Series to the dataset xyMultipleSeriesDataset.addSeries(expenseSeries); // Creating XYSeriesRenderer to customize expenseSeries XYSeriesRenderer renderer = new XYSeriesRenderer(); renderer.setColor(Color.RED); renderer.setPointStyle(PointStyle.CIRCLE); renderer.setFillPoints(true); renderer.setLineWidth(3); renderer.setDisplayChartValues(true); // Creating a XYMultipleSeriesRenderer to customize the whole chart XYMultipleSeriesRenderer multiRenderer = new XYMultipleSeriesRenderer(); multiRenderer.setXLabels(0); multiRenderer.setChartTitle("Expense Chart"); multiRenderer.setXTitle("Year 2016"); multiRenderer.setYTitle("Amount in Dollars"); multiRenderer.setZoomButtonsVisible(true); for(int i=0;i<x_values.length;i++){ multiRenderer.addXTextLabel(i+1, mMonth[i]); } // Adding expenseRenderer to multipleRenderer multiRenderer.addSeriesRenderer(renderer); // Getting a reference to LinearLayout of the MainActivity Layout LinearLayout chartContainer = (LinearLayout) findViewById(R.id.bgchart); // Creating a Line Chart View chart = ChartFactory.getLineChartView(getBaseContext(), xyMultipleSeriesDataset, multiRenderer); // Adding the Line Chart to the LinearLayout chartContainer.addView(chart); }

Androidplot A

It is really simple and straightforward to use; Supports zooming (pinch-and-zoom); It is fully customizable; Supports many kinds of graphs/plotting (e.g. multiple bars, pie); Supports dynamic plotting (which comes in hand if you are trying to develop any sensor-related app); Documentation includes easy-to-follow tutorials covering the basics.

http://androidplot.com/ https://play.google.com/store/apps/details?id=com.androidplot.demos&hl=en http://androidplot.com/docs/quickstart/

ChartDroid B

github.com/kostmo/chartdroid

Custom Canvas drawing

  • http://mindtherobot.com/blog/272/android-custom-ui-making-a-vintage-thermometer/

http://android.appstorm.net/roundups/utilities-roundups/35-android-apps-to-monitor-usage-stats-and-tweak-system-utilities/ They are probably using custom views overrinding the onDraw method to plot lines, shapes and paths using the canvas or the surface of the view. I stumbled upon this site today and found it quite intriguing.. Some of these apps have really stunning display of data, especially the norton mobile utilities. I want to graphically represent the information in my android application. I have researched a lot about graph librarioes available for android and have used chartdroid and achartengine, but still am not satisfied with the end result.

GraphView B?

http://android.arnodenhond.com/components/graphview http://www.android-graphview.org/download--getting-started.html https://github.com/blackfizz/EazeGraph

aFreeChart B?

https://github.com/johnjohndoe/AFreeChart

https://github.com/diogobernardino/WilliamChart

DroidDiagram

http://www.mindfusion.eu/droid-diagram.html

WilliamChart C

https://github.com/diogobernardino/WilliamChart http://www.mindfusion.eu/droid-diagram.html

OS Can Try

Sort

$? Syncfusion Chart for Android is a visually stunning charting component that is also easy to use. It includes all the common chart types ranging from line charts to financial charts. http://www.syncfusion.com/products/android/Chart

Holo Graph Librar https://bitbucket.org/danielnadeau/holographlibrary/wiki/Home ChartView https://github.com/nadavfima/ChartView/ charts4j https://github.com/julienchastang/charts4j Drawing the 3D piechart Using Google chart Api http://androidtutorials60.blogspot.in/2013/06/drawing-3d-piechart-using-google-chart.html HelloCharts https://github.com/lecho/hellocharts-android https://github.com/handstudio/HzGrapher

Incomplete

https://github.com/marshallino16/PacPieChart-Android

github.com/Zomato/DR-charts

The charting library created by me is easy to use, highly customizable and interactive with easy installation using Cocoa Pods.

JBChartView OS, uses cocoaPods

https://github.com/Jawbone/JBChartView RVW:http://maniacdev.com/2013/12/open-source-ios-library-for-line-and-bar-charts-with-a-uitableview-like-syntax

Jawbone's iOS-based charting library for both line and bar graphs. It is easy to set-up, and highly customizable.

Drop-in UIView subclass supported across all devices.
Lie and bar graph support.
Simple to use protocols modeled after a UITableView.
Highly customizable.
Expand &amp; collapse animation support.

Disadvantage : Requires iOS 7 or later. Requires Automatic Reference Counting (ARC)

SM2DGraphView OS http://developer.snowmintcs.com/frameworks/sm2dgraphview/index.html

github.com/honcheng/iOSPlot/tree/master/iOSPlot

code.google.com/p/s7graphview/

  • x GraphX http://blog.oofn.net/projects/graphx/ > I've used this one, and it'll work, but for very basic data sets. Some of the issues I ran into though was it's inability to plot values below zero, and it had a tendency to round any non-integer values.

  • PowerPlot http://powerplot.nua-schroers.de/ which is available under a dual-license model. You can just follow the above link to install the demo app which shows off several sample charts. You can also download the GPL-version of the library and check out if it fits your needs. With the exception of horizontal bar charts it has the features requested - specifically, bar charts, stacked bar charts, various axis label positions and orientations.

    This is a phenomenal library

  • Pie Chart 3D library. 3D charts which you can rotate and scale with fingers + protocol for getting information about tapped slice http://iphone.orpi.pl/?p=20

  • slightly less sophisticated ECGraph, bhttp://code.google.com/p/ecgraph/

  • demo projects for line, pi, bar chart from below link https://www.dropbox.com/s/w8uzqybimsvg9k7/Graph.zip

--- IOS Chart Frameworks

Swift OS

  • SwiftCharts is open source, easy to use and highly customisable. It comes with many examples. https://github.com/i-schuetz/SwiftCharts https://www.youtube.com/watch?v=bD6uDF-KckM

chart-plot OS

Core Plot : https://github.com/core-plot/core-plot

Core Plot is a plotting framework for OS X and iOS. It provides 2D visualisation of data, and is tightly integrated with Apple technologies like Core Animation, Core Data, and Cocoa Bindings.

Advantage: Core Plot is a free, open source charting library available under the New BSD License.

Example Graphs : https://github.com/core-plot/core-plot/wiki/Example-Graphs#wiki-dropplot-example-app

After a bit of googling , i have found that Core-plot is one of most flexible libraries and free of cost .

Examples

http://tech.pro/tutorial/939/using-core-plot-in-an-iphone-application

piechart http://www.raywenderlich.com/13269/how-to-draw-graphs-with-core-plot-part-1

http://www.johnwordsworth.com/2011/10/adding-charts-to-your-iphone-ipad-app-using-core-plot/

http://www.gilthonwe.com/2012/06/09/stacked-bar-chart-coreplot-ios/

Line Chart with Movable Points http://stackoverflow.com/a/7833210/966351 - etecting user touch on screen -(BOOL)plotSpace:(CPTXYPlotSpace *)space shouldHandlePointingDeviceDraggedEvent:(id)event atPoint:(CGPoint)point{ NSLog(@"point.x=%lf,point.y=%lf",point.x,point.y); return YES; } - this will handle drag points... http://blog.essencework.com/post/9413676170/put-some-touch-interactive-to-corep‌​lot-on-ipad-part-2

Customizing

  • Core Plot is highly customizable. Both of those charts can be made (and possibly were) using that framework. Just because the default charts in the sample applications weren't to your liking doesn't mean that's all you can do with the framework. Look through the highly customized charts in some of the applications using the framework, for example: http://code.google.com/p/core-plot/wiki/AppsUsingCorePlot

SO, Support

  • FORUM - http://groups.google.com/group/coreplot-discuss?hl=en

  • Does CorePlot support zooming and panning of Charts? >> YES: you have to set the allowsUserInteraction bool of your plot space to YES. Also, if you want to test zooming in the simulator, you can do this by pressing the alt button and click+drag with your mouse. Panning is just normal click+drag. See: http://florent.clairambault.fr/downloads/iPhone/core-plot-doc/interface_c_p_plot_space.html#a6c8fcf5db07950c3e84304180e9cd9d6

    just to refresh my mind, you zoom in on the simulator by double clicking, and zoomn out by right clicking using the mouse ? Double tapping DID NOT WORK!

    no, that does not seem to work (at least in my app). But the other ways should work perfectly fine.

  • how to set touch event, when user click the CandleStick on the chart, then it can show the Candle X and Y Value? stackoverflow.com/questions/7872416/coreplot-how-to-set-touch-event-when-user-click-the-candlestick-on-the-chart

  • You can still use Core Plot in your project even though it's manual reference counting. In your Target -> Buld Phases -> Compile Sources you can add a compiler flag to disable ARC on Core Plot related files. Core Plot should now work in your ARC enabled project.

    Navigate to Target -> Build Phases -> Compile Sources Select your desired files Add the compiler flag -fno-objc-arc

You can turn ARC off for CorePlot by setting this -fno-objc-arc flag to it's source files by selecting your project file in XCode, selecting your target, going to 'Build Phases'->'Compile Sources'.

I would really suggest you use Core Plot and simply disable ARC for those files, or link the project as a reference. ARC binaries are compatible with non-ARC binaries.

In your .h files you can declare properties using @property (strong) in an ARC project, in a MRC project you can't use that, you need to use retain.

property declarations simply direct the compiler on what to do. If the compiler has already done the work (as in the case of a static binary), they have no meaning. Also, I would suggest you read up on strong vs retain. Your ARC enabled project will work with both. – Paul de Lange Sep 26 '12 at 9:21

Yes I know that, but for Core Plot you need to copy a folder with uncompiled header files to your project, even if you're using the binary, for some reason. I have had issues with declaring properties in a way that wasn't supported in an ARC project, possibly it wasn't because of using retain, I don't remember exactly. But having ARC enabled does have some impact on uncompiled header files surely?

  • Custom labels on the x-axis for bar charts so: http://stackoverflow.com/questions/12770403/core-plot-custom-labels-on-the-x-axis-for-bar-charts?rq=1

Comments

  • Jan'13> I think the generated charts look poor.

  • Mar'13> CorePlot is ok feature-wise, but it is painfully slow. Mutli touch interactions are very sluggish. Totally spoils the experience in an otherwise slick iPhone or iPad app. - shinobi guy

  • Jul'10> Now it is possible to do a stacked bar chart by rendering multiple bar charts on top of eachother and adding the height of the frontmost values to the rear values (hope that made some sense, search the Core Plot google group for more details)

  • I used Core-Plot in one of my apps, and it was easy enough to use, but I have to agree that it isn't the prettiest. – Josh Dec 10 '10

  • Feb'10> To counter the lack of good plotting frameworks on the iPhone. Core Plot also encompases many other use cases including desktop systems, but its design has included iPhone support from the beginning. It's getting pretty close to useable and is currently in use in several shipping iPhone and OS X applications. Core Plot has come a long way since I first posted the summary. The framework now has bar charts (including horizontal bar charts, I believe), axis labels (including aribrarty rotations), and fills and backgrounds for graphs. I'm not sure about stacked bar charts, but it wouldn't be hard to add to the CPBarPlot class that implements bar charts. As for annotations, there is a CPAnotation class which you could subclass to add your annotations, if there isn't the exact functionality you need.

  • Dec'09> many features have been added to Core Plot, including bar charts, horizontal bar charts, custom plot labels, angled labels, and themes (including custom backgrounds).

Core Plot

(core-plot - Cocoa plotting framework for OS X and iOS - Google Project Hosting https://code.google.com/p/core-plot/

The documentation isn't that great and there may be a decent amount of code to get up and going, but it seems to be the most flexible (both visually and feature wise) and most popular native framework that I've used.

core-plot's API is a hideous maze of delegates and it's default rendering is tacky

iOS Charts API

How to Use iOS Charts API to Create Beautiful Charts in Swift. iOS Charts API: How to Use iOS Charts API to Create Beautiful Charts in Swiftappcoda.com.


0 comments

There are no comments yet

Add new comment

Similar posts

Markov Models Quickstart

Monte Carlo Models, Chains and Monte Carlo Simulation

Datascience, Big Data, Analytics and Visualization Learning Guide

Sales, Marketing and AI