MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

Implement tick marks on axis

Open Silvia4 opened this issue 6 years ago • 10 comments
trafficstars

Hi, is it possible to add tick marks on axis in correspondence of the labels? Something like this: image Maybe they can be simply an extension of the grid lines.

I have a similar problem, a graph with a lot of values so I have to show only some labels on the x axis. Without tick marks it's very difficult to understand which value match the label. Thanks

Silvia4 avatar Jul 04 '19 09:07 Silvia4

Facing same Issue. Any answer ?

hugoabreu1002 avatar Oct 17 '19 20:10 hugoabreu1002

I'm just learning, but I seem to have managed to add tick marks to the line chart. Here is a link to the cloned library https://github.com/spirit0fcom/MPAndroidChart/tree/57aaf9a415b6068a07e920ce9ea0d94a1b7516be

You should add something like this:

xAxis = chart.getXAxis();
xAxis.setDrawTickMarks(true);

yAxis = chart.getAxisLeft();
yAxis.setDrawTickMarks(true);

Maybe it can be usefull)

forGit

spirit0fcom avatar Dec 12 '19 19:12 spirit0fcom

Is this possible for bar charts?

kungpaogao avatar Jan 26 '20 02:01 kungpaogao

Okay, I've been working on an implementation for tick marks for the x-axis that involves extending the XAxisRenderer class. In particular, I created a new function that just draws a dashed line (using DashPathEffect). I'll try to release some code after I clean it up and if people are interested.

kungpaogao avatar Jan 29 '20 03:01 kungpaogao

Okay, I've been working on an implementation for tick marks for the x-axis that involves extending the XAxisRenderer class. In particular, I created a new function that just draws a dashed line (using DashPathEffect). I'll try to release some code after I clean it up and if people are interested.

I would be very interested in seeing how you managed to do that, do you think you could release some code? I'm currently trying to add tick marks to a line graph but the methods used in this post do not work.

acramer11 avatar Aug 10 '20 21:08 acramer11

I would be very interested in seeing how you managed to do that, do you think you could release some code? I'm currently trying to add tick marks to a line graph but the methods used in this post do not work.

Yah, of course! You can find the code here.

Unfortunately, this was sort of an experiment of rewriting an app, which I ended up abandoning because of other priorities. So, I haven't looked at the code in a bit. I'll try to find some time to clean up the code again.

Please let me know if you have any suggestions, or think of a better way of creating the ticks!

EDIT: the code also includes an "accent tick" line (currently for every 3rd tick or something), which doesn't really align perfectly

kungpaogao avatar Aug 12 '20 03:08 kungpaogao

I'm just learning, but I seem to have managed to add tick marks to the line chart. Here is a link to the cloned library https://github.com/spirit0fcom/MPAndroidChart/tree/57aaf9a415b6068a07e920ce9ea0d94a1b7516be

I suppose it's not gonna be up to date with the original library

oth-libs avatar Feb 23 '21 16:02 oth-libs

Would be great to have tick marks.

m-melis avatar Mar 31 '21 08:03 m-melis

same issue works with LabelRotationAngle

dtboy1995 avatar Apr 11 '21 11:04 dtboy1995

@Silvia4 Did you find any solution for this

Hi, is it possible to add tick marks on axis in correspondence of the labels? Something like this: image Maybe they can be simply an extension of the grid lines.

I have a similar problem, a graph with a lot of values so I have to show only some labels on the x axis. Without tick marks it's very difficult to understand which value match the label. Thanks

sawantpragnesh2014 avatar Nov 16 '22 07:11 sawantpragnesh2014