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

LineData constructor doesn't have string value entry anymore?? #1956

Closed
masoud2v opened this issue Jul 5, 2016 · 3 comments
Closed

LineData constructor doesn't have string value entry anymore?? #1956

masoud2v opened this issue Jul 5, 2016 · 3 comments

Comments

@masoud2v
Copy link

masoud2v commented Jul 5, 2016

I want to add string values as my x axis values but i cannot add string arraylist in LineData constructor

              ` LineDataSet setComp1 = new LineDataSet(valsComp1, "Company 1");
                setComp1.setAxisDependency(YAxis.AxisDependency.LEFT);
                setComp1.setColors(new int[]{Color.BLUE});
                setComp1.setCircleColor(Color.BLUE);
                setComp1.setCircleColorHole(Color.BLUE);

                belowAxis.setValueFormatter(new MyCustomXAxisValueFormatter());

                ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
                dataSets.add(setComp1);

                ArrayList<String> xVals = new ArrayList<String>();
                xVals.add("a");
                xVals.add("b");
                xVals.add("c");
                xVals.add("d");

                LineData data = new LineData(dataSets);
                chart.setData(data);
                chart.invalidate();`
@PhilJay
Copy link
Owner

PhilJay commented Jul 5, 2016

No, this is now done via AxisValueFormatter.

Example:

final String[] xValues = new String[] { "a", "b", "c" };

xAxis.setValueFormatter(new AxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                return xValues[(int) value % xValues.length];
            }

            @Override
            public int getDecimalDigits() {
                return 0;
            }
        });

@PhilJay PhilJay closed this as completed Jul 5, 2016
@plbecker
Copy link

Please update the wiki, others might run into the same issue.

@gao746700783
Copy link

it helped me,please update the wiki

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

4 participants