• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 package com.github.mikephil.charting.components;
3 
4 import com.github.mikephil.charting.utils.Utils;
5 
6 /**
7  * Class representing the x-axis labels settings. Only use the setter methods to
8  * modify it. Do not access public variables directly. Be aware that not all
9  * features the XLabels class provides are suitable for the RadarChart.
10  *
11  * @author Philipp Jahoda
12  */
13 public class XAxis extends AxisBase {
14 
15     /**
16      * width of the x-axis labels in pixels - this is automatically
17      * calculated by the computeSize() methods in the renderers
18      */
19     public int mLabelWidth = 1;
20 
21     /**
22      * height of the x-axis labels in pixels - this is automatically
23      * calculated by the computeSize() methods in the renderers
24      */
25     public int mLabelHeight = 1;
26 
27     /**
28      * width of the (rotated) x-axis labels in pixels - this is automatically
29      * calculated by the computeSize() methods in the renderers
30      */
31     public int mLabelRotatedWidth = 1;
32 
33     /**
34      * height of the (rotated) x-axis labels in pixels - this is automatically
35      * calculated by the computeSize() methods in the renderers
36      */
37     public int mLabelRotatedHeight = 1;
38 
39     /**
40      * This is the angle for drawing the X axis labels (in degrees)
41      */
42     protected float mLabelRotationAngle = 0f;
43 
44     /**
45      * if set to true, the chart will avoid that the first and last label entry
46      * in the chart "clip" off the edge of the chart
47      */
48     private boolean mAvoidFirstLastClipping = false;
49 
50     /**
51      * the position of the x-labels relative to the chart
52      */
53     private XAxisPosition mPosition = XAxisPosition.TOP;
54 
55     /**
56      * enum for the position of the x-labels relative to the chart
57      */
58     public enum XAxisPosition {
59         TOP, BOTTOM, BOTH_SIDED, TOP_INSIDE, BOTTOM_INSIDE
60     }
61 
XAxis()62     public XAxis() {
63         super();
64 
65         mYOffset = Utils.convertDpToPixel(4.f); // -3
66     }
67 
68     /**
69      * returns the position of the x-labels
70      */
getPosition()71     public XAxisPosition getPosition() {
72         return mPosition;
73     }
74 
75     /**
76      * sets the position of the x-labels
77      *
78      * @param pos
79      */
setPosition(XAxisPosition pos)80     public void setPosition(XAxisPosition pos) {
81         mPosition = pos;
82     }
83 
84     /**
85      * returns the angle for drawing the X axis labels (in degrees)
86      */
getLabelRotationAngle()87     public float getLabelRotationAngle() {
88         return mLabelRotationAngle;
89     }
90 
91     /**
92      * sets the angle for drawing the X axis labels (in degrees)
93      *
94      * @param angle the angle in degrees
95      */
setLabelRotationAngle(float angle)96     public void setLabelRotationAngle(float angle) {
97         mLabelRotationAngle = angle;
98     }
99 
100     /**
101      * if set to true, the chart will avoid that the first and last label entry
102      * in the chart "clip" off the edge of the chart or the screen
103      *
104      * @param enabled
105      */
setAvoidFirstLastClipping(boolean enabled)106     public void setAvoidFirstLastClipping(boolean enabled) {
107         mAvoidFirstLastClipping = enabled;
108     }
109 
110     /**
111      * returns true if avoid-first-lastclipping is enabled, false if not
112      *
113      * @return
114      */
isAvoidFirstLastClippingEnabled()115     public boolean isAvoidFirstLastClippingEnabled() {
116         return mAvoidFirstLastClipping;
117     }
118 }
119