hellocharts-android icon indicating copy to clipboard operation
hellocharts-android copied to clipboard

How to add datetime to x axis and others

Open klaszlo8207 opened this issue 7 years ago • 3 comments

1, I have the axisXBottom, and I need to write out datetimes there, how can I do that?

2, Also I have axisYLeft with some values 0.0 to 1.0 I want to draw out something like

(0.5 - 35$ ) (0.6 - 42$ ) ...etc

I can use setAppendedText, but how can I get the formatter value back?

I need something like:

setAppendedText(" " + (formatter.value * 7) + "$" )

klaszlo8207 avatar Jan 16 '18 10:01 klaszlo8207

Set the label value.

zxdeer avatar Jan 22 '18 04:01 zxdeer

for setting Date as x axis value change the date in to string in required format and use them. Some thing like this. List<AxisValue> xAxisValues = new ArrayList<>(); for(int i= 0; i< numberOfPoints, i++) xAxisValues.add(new AxisValue(i, dates[i].toString().toCharArray())); Axis axisX = new Axis(); axisX.setValues(xAxisValues); chart.setAxisXBottom(axisX); I think you can use the same for Y axis also.

nareshkatta99 avatar Jan 24 '18 13:01 nareshkatta99

i have done those this things as per your answered but still it can't give me output for dynamic data. can you help in this case?

Here is my code sample : LineChartData data = new LineChartData();

List<AxisValue> xAxisValues = new ArrayList<>(); List<AxisValue> yAxisValues = new ArrayList<>(); for (int i = 0; i < 10; i++) {

AxisValue axisValue = new AxisValue(i); axisValue.setValue(i); axisValue.setLabel("A" + i); xAxisValues.add(axisValue);

AxisValue axisValueY = new AxisValue(i); axisValueY.setValue(i); axisValueY.setLabel("Y" + (i+2)); xAxisValues.add(axisValueY); }

Axis axisX = new Axis(); axisX.setName("Test"); axisX.setValues(xAxisValues); data.setAxisXBottom(axisX);

Axis axisY = new Axis(); axisY.setName("User"); axisY.setValues(yAxisValues); data.setAxisYLeft(axisY);

chart.setLineChartData(data);

burhansaykalvala avatar Feb 20 '18 12:02 burhansaykalvala