Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set axis number to Text in column chart? #542

Open
Himani75 opened this issue Jun 22, 2020 · 1 comment
Open

How to set axis number to Text in column chart? #542

Himani75 opened this issue Jun 22, 2020 · 1 comment

Comments

@Himani75
Copy link

No description provided.

@joyrajak
Copy link

I used this library. I had to add the month name below the column. I saw there is no option to add string. Below I am sharing my code--(Here my activity name is VisitsActivity )

public class VisitsActivity extends AppCompatActivity {
ColumnChartView chart;
ColumnChartData data;
List axisValueList = new ArrayList<>();

char[] month1 = {'J', 'a', 'n'};
char[] month2 = {'F', 'e', 'b'};
char[] month3 = {'M', 'a', 'r'};
char[] month4 = {'A', 'p', 'r'};
char[] month5 = {'M', 'a', 'y'};
char[] month6 = {'J', 'u', 'n'};
char[] month7 = {'J', 'u', 'l'};
char[] month8 = {'A', 'u', 'g'};
char[] month9 = {'S', 'e', 'p'};
char[] month10 = {'O', 'c', 't'};
char[] month11 = {'N', 'o', 'v'};
char[] month12 = {'D', 'e', 'c'};
List<char[]> month_list =new ArrayList<>();


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_visits);

    MethodClass.initialize_loader(this);
    MethodClass.initialize_SweetAlertDialog(this, SweetAlertDialog.ERROR_TYPE);

    chart = findViewById(R.id.chart);
    chart.setInteractive(true);
    chart.setZoomType(ZoomType.HORIZONTAL_AND_VERTICAL);
    chart.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL);

    month_list.add(month1);
    month_list.add(month2);
    month_list.add(month3);
    month_list.add(month4);
    month_list.add(month5);
    month_list.add(month6);
    month_list.add(month7);
    month_list.add(month8);
    month_list.add(month9);
    month_list.add(month10);
    month_list.add(month11);
    month_list.add(month12);


    List<Column> columns = new ArrayList<Column>();
    List<SubcolumnValue> values;
    for (int i = 0; i < 12; ++i) {
        axisValueList.add(new AxisValue(i, month_list.get(i)));
        values = new ArrayList<SubcolumnValue>();
        for (int j = 0; j < 1; ++j) {
            values.add(new SubcolumnValue((float) Math.random() * 50f + 5, ChartUtils.pickColor()));
        }

        Column column = new Column(values);
        column.setHasLabels(true);
        //column.setHasLabelsOnlyForSelected(true);
        columns.add(column);


    }

    data = new ColumnChartData(columns);
    Axis axisX = new Axis().setValues(axisValueList);
    data.setAxisXBottom(axisX);
    chart.setColumnChartData(data);


}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants