PhilJay / MPAndroidChart

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.
Other
37.54k stars 9.01k forks source link

How to set x axis labels at fixed interval #3000

Open imsanjaysah opened 7 years ago

imsanjaysah commented 7 years ago

I am displaying realtime chart which should display values as per second. My X axis is time in second. But I am not able to display fixed time interval in x axis ie. 0,1,2,... so on. X axis value is automatically calculated and time interval between two x values goes to 20 seconds which I don't want. I need your help to fix this.

Any help would be greatly appreciated.

RKGG commented 7 years ago

Do you want to set a fixed interval in x axis? I set my linechart with a fixed interval in x axis by the follow code. ArrayList<String> xValues = new ArrayList<String>(); for (int i = WLstartpoint; i <= WLendpoint; i+=WLspace) { xValues.add("" + i); } The WLspace is my fixed interval. I hope it can help you.

JCLaHoot commented 7 years ago

did this work? I have a similar issue where I need to set the interval for my labels...

RKGG commented 7 years ago

Yes. It worked for me. It just uses this code " i+=WLSpace" . And you need to kown where is the starting and ending of x axis firstly so you can difine the fixed interval what you want. I hope it can help you! @JCLaHoot