Coder Social home page Coder Social logo

View Axis data about hellocharts-android HOT 15 CLOSED

lecho avatar lecho commented on July 3, 2024
View Axis data

from hellocharts-android.

Comments (15)

lecho avatar lecho commented on July 3, 2024

Ok, I managed to reproduce that behavior.

When name of axis is displayed but without values that means that none of axis values are within viewport.

When neither name of axis nor axis values are displayed means that list of axis values is empty or null. Please, check if axisValuesForY is not empty. If you want axis to be auto-generated don't set values at all.

Btw. I'll try to improve AxesRenderer implementation to display axis name even when there is no axis value.

from hellocharts-android.

thomaslc66 avatar thomaslc66 commented on July 3, 2024

Ok so i ve looked into both axis value and they are not empty. I play a bit with the viewport to se if i Can make it. But I m usine column chart and no matte what i do i Can t see axisX value on the botom of my activity. I m just tryin to display the Day (1,2,3) exactly like the screenshot you used for the presentation of your library. I see Day but then nothing no number. Maybe is there something specific to do with column or maybe, it's just the size of each column.

Don't know.

from hellocharts-android.

thomaslc66 avatar thomaslc66 commented on July 3, 2024

https://github.com/lecho/hellocharts-android/blob/master/screens/scr-column1.png

This one

from hellocharts-android.

thomaslc66 avatar thomaslc66 commented on July 3, 2024

...

from hellocharts-android.

lecho avatar lecho commented on July 3, 2024

One more thing that comes to my mind. In column chart you cannot set column X value, by default columns are automatically indexed from 0 to numberOfColumns-1. To display custom X label under first column you need AxisValue with value 0, under second column you need AxisValue with value 1 etc.

Maybe that is the problem. In my demo project I create custom X labels with months names in for-loop which looks like this:

List<AxisValue> axisValues = new ArrayList<AxisValue>();
for (int i = 0; i < numColumns; ++i) {
    ...
    axisValues.add(new AxisValue(i, months[i].toCharArray()));
    ...
}

from hellocharts-android.

thomaslc66 avatar thomaslc66 commented on July 3, 2024

ok i manage to display all graph data, but now as you can see all the columns are displayed on the left and i want each column under 1,2,3,4,5,6,7,8 etc.. i can't figure out how i can set a specific day for wach column

screenshot_2014-12-13-18-52-43

i've made this

        //List of columns
         List<ColumnValue> listOfColumns = new ArrayList<ColumnValue>();

        //values of the axeY
         List<AxisValue> axisValuesForX = new ArrayList<AxisValue>();
        //values of the axeY
        List<AxisValue> axisValuesForY = new ArrayList<AxisValue>();

        for (int i = 1,y = 0; i < nbrRow; i++, y+=5){
             Jours jour = jourdb.getJoursWithID(i);

                  //if Total is different than 0, that's mean that the sum has been saved and the day is done.
          if(jour.getTotal() != 0){

              //add value to the x axis
              axisValuesForX.add(new AxisValue(jour.getJours()));
              //add value to the Y axis
              axisValuesForY.add(new AxisValue(y));

              //get the amount of pull ups
              ColumnValue col_ = new ColumnValue(jour.getTotal(),green);
              listOfColumns.add(col_);
          }
      }

    //Gestion of the two axes for the graphic
    Axis axeX = new Axis(axisValuesForX);
    Axis axeY = new Axis(axisValuesForY);

and when i had this i have an unable to start activity error
axisValues.add(new AxisValue(i, months[i].toCharArray()));

from hellocharts-android.

lecho avatar lecho commented on July 3, 2024

Check samples project, in particular ColumnChartActivit.java.

There are columns and sub-columns. Every column can have one or more sub-columns. It looks like you want one sub-column for every column but instead you put all your values into single column. Try to create single ColumnValue for single Column, so one Columns will hold on ColumnValue which will hold single jour.total value.

Another thing, AxisValue holds value of X index, columns have indexes from 0 to n-1 so AxisValues should hold values from 0 to n-1 and probably not jour.getJours(). If you want custom axis label use AxisValue.setLabel(char[]) or AxisValue.setForrmater(ValueFormatter) methods. Examples are available in samples project.

from hellocharts-android.

lecho avatar lecho commented on July 3, 2024

I've just renamed ColumnValue into SubcolumnValue, maybe this will be less confusing.

from hellocharts-android.

thomaslc66 avatar thomaslc66 commented on July 3, 2024

I've done this, but when i start it i get an error on graph.setColumnChartData(data)

    int green = getResources().getColor(R.color.bg);

    ColumnChartData data = new ColumnChartData();

    dayFromDB jourdb = new dayFromDB(Statistiques.this);
    jourdb.open();

    DatabaseUtils dataUtils = new DatabaseUtils();
    nbrRow = dataUtils.queryNumEntries(jourdb.getBDD(),TABLE);

    ColumnChartView graph = (ColumnChartView) findViewById(R.id.chart);

    List<SubcolumnValue> listOfColumns = new ArrayList<SubcolumnValue>();


    List<AxisValue> axisValuesForX = new ArrayList<AxisValue>();

    List<AxisValue> axisValuesForY = new ArrayList<AxisValue>();

    for (int i = 1,y = 0; i < nbrRow; i++, y+=5) {
        Jours jour = jourdb.getJoursWithID(i);

        if(jour.getTotal() != 0){

            axisValuesForY.add(new AxisValue(y));

            SubcolumnValue col_ = new SubcolumnValue(jour.getTotal(),green);
            listOfColumns.add(col_);
        }
    }

    jourdb.close();

    Axis axeX = new Axis();
    Axis axeY = new Axis(axisValuesForY);


    data.setAxisXBottom(axeX.setHasLines(true));
    data.setAxisYLeft(axeY.setHasLines(true));

    Column column = new Column();
    column.setValues(listOfColumns);

    column.setHasLabels(true);

    List<Column> columns = new ArrayList<Column>();
    columns.add(column);

    data.setColumns(columns);

    axeX.setName("Jours");
    axeY.setName("Tractions");

    graph.setColumnChartData(data);

from hellocharts-android.

thomaslc66 avatar thomaslc66 commented on July 3, 2024

Here is my xml

    <?xml version="1.0" encoding="utf-8"?>
  <RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<lecho.lib.hellocharts.view.ColumnChartView
  android:id="@+id/chart" 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent" />

    </RelativeLayout>

from hellocharts-android.

lecho avatar lecho commented on July 3, 2024

What error message you get?

from hellocharts-android.

thomaslc66 avatar thomaslc66 commented on July 3, 2024

I Will give you the exact error tonight. But I realy don't un der stand why! My code doesnt seems wrong

Envoyé depuis mon smartphone Samsung Galaxy.

-------- Message d'origine --------
De : Leszek Wach [email protected]
Date :29/01/2015 20:18 (GMT+01:00)
À : lecho/hellocharts-android [email protected]
Cc : thomaslc66 [email protected]
Objet : Re: [hellocharts-android] View Axis data (#16)

What error message you get?


Reply to this email directly or view it on GitHub.

from hellocharts-android.

thomaslc66 avatar thomaslc66 commented on July 3, 2024

Hi, Here is the error i've got
erreur_01

ligne 81 is the call to my method generateColum()
And line 192 is graph.setColumnChartData(data) into my generateColumn method

from hellocharts-android.

lecho avatar lecho commented on July 3, 2024

There is nothing related to library, you just have NPE in your code. Check if graph is not null.

from hellocharts-android.

MrNdokist avatar MrNdokist commented on July 3, 2024

how to add data to ColumnChartView

from hellocharts-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.