2525public class CombinedChart extends BarLineChartBase <CombinedData > implements LineDataProvider ,
2626 BarDataProvider , ScatterDataProvider , CandleDataProvider {
2727
28- private FillFormatter mFillFormatter ;
28+ /** the fill-formatter used for determining the position of the fill-line */
29+ protected FillFormatter mFillFormatter ;
30+
31+ /** flag that enables or disables the highlighting arrow */
32+ private boolean mDrawHighlightArrow = false ;
33+
34+ /**
35+ * if set to true, all values are drawn above their bars, instead of below
36+ * their top
37+ */
38+ private boolean mDrawValueAboveBar = true ;
39+
40+ /**
41+ * if set to true, all values of a stack are drawn individually, and not
42+ * just their sum
43+ */
44+ private boolean mDrawValuesForWholeStack = true ;
45+
46+ /**
47+ * if set to true, a grey area is darawn behind each bar that indicates the
48+ * maximum value
49+ */
50+ private boolean mDrawBarShadow = true ;
51+
52+ protected DrawOrder [] mDrawOrder = new DrawOrder [] {
53+ DrawOrder .BAR , DrawOrder .LINE , DrawOrder .CANDLE , DrawOrder .SCATTER
54+ };
55+
56+ /**
57+ * enum that allows to specify the order in which the different data objects
58+ * for the combined-chart are drawn
59+ */
60+ public enum DrawOrder {
61+ BAR , LINE , CANDLE , SCATTER
62+ }
2963
3064 public CombinedChart (Context context ) {
3165 super (context );
@@ -52,7 +86,7 @@ protected void init() {
5286 protected void calcMinMax () {
5387 super .calcMinMax ();
5488
55- if (getBarData () != null ) {
89+ if (getBarData () != null || getCandleData () != null ) {
5690 mXChartMin = -0.5f ;
5791 mXChartMax = mData .getXVals ().size () - 0.5f ;
5892 mDeltaX = Math .abs (mXChartMax - mXChartMin );
@@ -109,25 +143,83 @@ public CandleData getCandleData() {
109143
110144 @ Override
111145 public boolean isDrawBarShadowEnabled () {
112- // TODO Auto-generated method stub
113- return false ;
146+ return mDrawBarShadow ;
114147 }
115148
116149 @ Override
117150 public boolean isDrawValueAboveBarEnabled () {
118- // TODO Auto-generated method stub
119- return true ;
151+ return mDrawValueAboveBar ;
120152 }
121153
122154 @ Override
123155 public boolean isDrawHighlightArrowEnabled () {
124- // TODO Auto-generated method stub
125- return false ;
156+ return mDrawHighlightArrow ;
126157 }
127158
128159 @ Override
129160 public boolean isDrawValuesForWholeStackEnabled () {
130- // TODO Auto-generated method stub
131- return false ;
161+ return mDrawValuesForWholeStack ;
162+ }
163+
164+ /**
165+ * set this to true to draw the highlightning arrow
166+ *
167+ * @param enabled
168+ */
169+ public void setDrawHighlightArrow (boolean enabled ) {
170+ mDrawHighlightArrow = enabled ;
171+ }
172+
173+ /**
174+ * If set to true, all values are drawn above their bars, instead of below
175+ * their top.
176+ *
177+ * @param enabled
178+ */
179+ public void setDrawValueAboveBar (boolean enabled ) {
180+ mDrawValueAboveBar = enabled ;
181+ }
182+
183+ /**
184+ * if set to true, all values of a stack are drawn individually, and not
185+ * just their sum
186+ *
187+ * @param enabled
188+ */
189+ public void setDrawValuesForWholeStack (boolean enabled ) {
190+ mDrawValuesForWholeStack = enabled ;
191+ }
192+
193+ /**
194+ * If set to true, a grey area is drawn behind each bar that indicates the
195+ * maximum value. Enabling his will reduce performance by about 50%.
196+ *
197+ * @param enabled
198+ */
199+ public void setDrawBarShadow (boolean enabled ) {
200+ mDrawBarShadow = enabled ;
201+ }
202+
203+ /**
204+ * Returns the currently set draw order.
205+ *
206+ * @return
207+ */
208+ public DrawOrder [] getDrawOrder () {
209+ return mDrawOrder ;
210+ }
211+
212+ /**
213+ * Sets the order in which the provided data objects should be drawn. The
214+ * earlier you place them in the provided array, the further they will be in
215+ * the background. e.g. if you provide new DrawOrer[] { DrawOrder.BAR,
216+ * DrawOrder.LINE }, the bars will be drawn behind the lines.
217+ *
218+ * @param order
219+ */
220+ public void setDrawOrder (DrawOrder [] order ) {
221+ if (order == null || order .length <= 0 )
222+ return ;
223+ mDrawOrder = order ;
132224 }
133225}
0 commit comments