You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 20 Next »

This is example of how we have implemented the android mobile app in BellaDati using BellaDati-android-views library. You can use the native components of this library to visualize charts, kpis and tables.

 

The data to visualize are from BellaDati reports. See the Report section.

 

 

First of all you have to use android-sdk to make xAuth. See section Java SDK --> Android.

 

How to use the BellaDati-android-views library

  1. To your build.gradle(project) add these two lines to repositories section. It should looks like:

    allprojects {
        repositories {
            jcenter()
            maven { url "https://dl.bintray.com/ktafsi46/belladati-android-views" }
            maven { url "https://jitpack.io" }
        }
    }
  2. Than to your build.gradle(app) add one line to dependencies section.

    compile 'com.belladati:belladati-android-views:1.2'
  3. After this you can do xAuth to BellaDati cloud. It is in this section. The xAuth returns BellaDatiService so you can use the BellaDati-android-views library.
  4. Add to your layout.xml component which you want to use. For example I would like to use StackedBarChart, see below.
  5. So I added com.belladati.android.views.StackedBarChart and set it height, width and id.
  6. In code behind java class , I have to implement this component. In onCreateView method implement chart.

    StackedBarChart myChart=(StackedBarChart) rootView.findViewById(R.id.chart);
  7. So you can use methods of StackedBarChart. First of all you have to set BellaDatiService and id chart.  Service returns xAuth so you can use it. Id chart is API id from BellaDati cloud. Here is example of my StackedBarChart id.

    myChart.setService(service);
    myChart.setIdChart(“47892-Opjy5zwHvO”);
  8. Also you can use MultiValueFilter for set filter to your report view. For example:

    Filter.MultiValueFilter fUserId;
    fUserId = FilterOperation.IN.createFilter(getAttribute("L_DRIVER", "32531"));
    fUserId.addValue(new FilterValue("D1654"));
     
    ObjectNode filterNode = new ObjectMapper().createObjectNode();
    filterNode.setAll(fUserId.toJson());
     
    mChart.setFilterNode(filterNode);

    Below is method getAttribute

    private Attribute getAttribute(String filter, String idDataset) {
        for (Attribute aa : service.loadDataSet(idDataset).getAttributes()) {
            if (filter.equalsIgnoreCase(aa.getCode())) {
                return aa;
            }
        }
        return null;
    }

     

    First parameter of getAttribute is name of param in dataset which you want to filter and second is Id of dataset. See below. FilterValue parameter is value what do you want to filter. You can also filter for more parameters like date etc. 


  9. The last step is call method createStackedBarChart().

    try {
        mChart.createStackedBarChart();
    } catch (Exception e) {
        Log.e("error",e.getMessage());
    }
  10. Now you have chart in your mobile app. There are more options to setup your chart maybe: Axes text colour, Legend text colour, ValueTextColor etc. 

    Charts are zoomable and you can move on x-axis and y-axis.




  • No labels