@@ -61,10 +61,19 @@ public abstract class BarLineChartBase extends Chart {
6161 /** if true, the y-legend will always start at zero */
6262 protected boolean mStartAtZero = true ;
6363
64+ /** paint object for the grid lines */
6465 protected Paint mGridPaint ;
66+
67+ /** paint object for the (by default) lightgrey background of the grid */
6568 protected Paint mGridBackgroundPaint ;
69+
70+ /** paint for the line surrounding the chart */
6671 protected Paint mOutLinePaint ;
72+
73+ /** paint for the x-legend values */
6774 protected Paint mXLegendPaint ;
75+
76+ /** paint for the y-legend values */
6877 protected Paint mYLegendPaint ;
6978
7079 public BarLineChartBase (Context context , AttributeSet attrs , int defStyle ) {
@@ -116,8 +125,9 @@ protected void init() {
116125 @ Override
117126 protected void onDraw (Canvas canvas ) {
118127 super .onDraw (canvas );
119-
120- if (mDataNotSet ) return ;
128+
129+ if (mDataNotSet )
130+ return ;
121131
122132 long starttime = System .currentTimeMillis ();
123133
@@ -244,7 +254,7 @@ protected void calcFormats() {
244254 @ Override
245255 protected void calcMinMax () {
246256 super .calcMinMax (); // calc min and max in the super class
247-
257+
248258 // additional handling for space (default 10% space)
249259
250260 float spaceTop = (mYMax - mYChartMin ) / 100f * 10f ;
@@ -486,29 +496,6 @@ protected void drawVerticalGrid() {
486496 }
487497 }
488498
489- @ Override
490- protected void drawValues () {
491-
492- // if values are drawn
493- if (mDrawValues && mYVals .size () < mMaxVisibleCount * mScaleX ) {
494-
495- float [] valuePoints = new float [mYVals .size () * 2 ];
496-
497- for (int i = 0 ; i < valuePoints .length ; i += 2 ) {
498- valuePoints [i ] = i / 2 ;
499- valuePoints [i + 1 ] = mYVals .get (i / 2 );
500- }
501-
502- transformPointArray (valuePoints );
503-
504- for (int i = 0 ; i < valuePoints .length ; i += 2 ) {
505- mDrawCanvas .drawText (
506- mFormatValue .format (mYVals .get (i / 2 )),
507- valuePoints [i ], valuePoints [i + 1 ] - 12 , mValuePaint );
508- }
509- }
510- }
511-
512499 /**
513500 * determines how much space (in percent of the total range) is left between
514501 * the loweset value of the chart and its bottom (bottomSpace) and the
@@ -518,22 +505,23 @@ protected void drawValues() {
518505 * @param bottomSpace
519506 * @param topSpace
520507 */
521- // public void setSpacePercent(int bottomSpace, int topSpace) {
522- // mYSpacePercentBottom = bottomSpace;
523- // mYSpacePercentTop = topSpace;
524- // }
525-
508+ // public void setSpacePercent(int bottomSpace, int topSpace) {
509+ // mYSpacePercentBottom = bottomSpace;
510+ // mYSpacePercentTop = topSpace;
511+ // }
512+
526513 /**
527514 * sets the effective range of y-values the chart can display
515+ *
528516 * @param minY
529517 * @param maxY
530518 */
531519 public void setYRange (float minY , float maxY ) {
532-
520+
533521 mYChartMin = minY ;
534522 mYChartMax = maxY ;
535523 mDeltaY = mYChartMax - mYChartMin ;
536-
524+
537525 prepareMatrix ();
538526 prepareYLegend ();
539527 }
@@ -694,9 +682,32 @@ public void setGridWidth(float width) {
694682 width = 3.0f ;
695683 mGridWidth = width ;
696684 }
697-
685+
698686 @ Override
699687 protected void highlightValues (int [] indices ) {
700688 super .highlightValues (indices );
701689 }
690+
691+ @ Override
692+ public void setPaint (Paint p , int which ) {
693+ super .setPaint (p , which );
694+
695+ switch (which ) {
696+ case PAINT_GRID :
697+ mGridPaint = p ;
698+ break ;
699+ case PAINT_GRID_BACKGROUND :
700+ mGridBackgroundPaint = p ;
701+ break ;
702+ case PAINT_OUTLINE :
703+ mOutLinePaint = p ;
704+ break ;
705+ case PAINT_XLEGEND :
706+ mXLegendPaint = p ;
707+ break ;
708+ case PAINT_YLEGEND :
709+ mYLegendPaint = p ;
710+ break ;
711+ }
712+ }
702713}
0 commit comments