• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.github.mikephil.charting.data;
2 
3 import android.graphics.DashPathEffect;
4 
5 import com.github.mikephil.charting.interfaces.datasets.ILineScatterCandleRadarDataSet;
6 import com.github.mikephil.charting.utils.Utils;
7 
8 import java.util.List;
9 
10 /**
11  * Created by Philipp Jahoda on 11/07/15.
12  */
13 public abstract class LineScatterCandleRadarDataSet<T extends Entry> extends BarLineScatterCandleBubbleDataSet<T> implements ILineScatterCandleRadarDataSet<T> {
14 
15     protected boolean mDrawVerticalHighlightIndicator = true;
16     protected boolean mDrawHorizontalHighlightIndicator = true;
17 
18     /** the width of the highlight indicator lines */
19     protected float mHighlightLineWidth = 0.5f;
20 
21     /** the path effect for dashed highlight-lines */
22     protected DashPathEffect mHighlightDashPathEffect = null;
23 
24 
LineScatterCandleRadarDataSet(List<T> yVals, String label)25     public LineScatterCandleRadarDataSet(List<T> yVals, String label) {
26         super(yVals, label);
27         mHighlightLineWidth = Utils.convertDpToPixel(0.5f);
28     }
29 
30     /**
31      * Enables / disables the horizontal highlight-indicator. If disabled, the indicator is not drawn.
32      * @param enabled
33      */
setDrawHorizontalHighlightIndicator(boolean enabled)34     public void setDrawHorizontalHighlightIndicator(boolean enabled) {
35         this.mDrawHorizontalHighlightIndicator = enabled;
36     }
37 
38     /**
39      * Enables / disables the vertical highlight-indicator. If disabled, the indicator is not drawn.
40      * @param enabled
41      */
setDrawVerticalHighlightIndicator(boolean enabled)42     public void setDrawVerticalHighlightIndicator(boolean enabled) {
43         this.mDrawVerticalHighlightIndicator = enabled;
44     }
45 
46     /**
47      * Enables / disables both vertical and horizontal highlight-indicators.
48      * @param enabled
49      */
setDrawHighlightIndicators(boolean enabled)50     public void setDrawHighlightIndicators(boolean enabled) {
51         setDrawVerticalHighlightIndicator(enabled);
52         setDrawHorizontalHighlightIndicator(enabled);
53     }
54 
55     @Override
isVerticalHighlightIndicatorEnabled()56     public boolean isVerticalHighlightIndicatorEnabled() {
57         return mDrawVerticalHighlightIndicator;
58     }
59 
60     @Override
isHorizontalHighlightIndicatorEnabled()61     public boolean isHorizontalHighlightIndicatorEnabled() {
62         return mDrawHorizontalHighlightIndicator;
63     }
64 
65     /**
66      * Sets the width of the highlight line in dp.
67      * @param width
68      */
setHighlightLineWidth(float width)69     public void setHighlightLineWidth(float width) {
70         mHighlightLineWidth = Utils.convertDpToPixel(width);
71     }
72 
73     @Override
getHighlightLineWidth()74     public float getHighlightLineWidth() {
75         return mHighlightLineWidth;
76     }
77 
78     /**
79      * Enables the highlight-line to be drawn in dashed mode, e.g. like this "- - - - - -"
80      *
81      * @param lineLength the length of the line pieces
82      * @param spaceLength the length of space inbetween the line-pieces
83      * @param phase offset, in degrees (normally, use 0)
84      */
enableDashedHighlightLine(float lineLength, float spaceLength, float phase)85     public void enableDashedHighlightLine(float lineLength, float spaceLength, float phase) {
86         mHighlightDashPathEffect = new DashPathEffect(new float[] {
87                 lineLength, spaceLength
88         }, phase);
89     }
90 
91     /**
92      * Disables the highlight-line to be drawn in dashed mode.
93      */
disableDashedHighlightLine()94     public void disableDashedHighlightLine() {
95         mHighlightDashPathEffect = null;
96     }
97 
98     /**
99      * Returns true if the dashed-line effect is enabled for highlight lines, false if not.
100      * Default: disabled
101      *
102      * @return
103      */
isDashedHighlightLineEnabled()104     public boolean isDashedHighlightLineEnabled() {
105         return mHighlightDashPathEffect == null ? false : true;
106     }
107 
108     @Override
getDashPathEffectHighlight()109     public DashPathEffect getDashPathEffectHighlight() {
110         return mHighlightDashPathEffect;
111     }
112 
copy(LineScatterCandleRadarDataSet lineScatterCandleRadarDataSet)113     protected void copy(LineScatterCandleRadarDataSet lineScatterCandleRadarDataSet) {
114         super.copy(lineScatterCandleRadarDataSet);
115         lineScatterCandleRadarDataSet.mDrawHorizontalHighlightIndicator = mDrawHorizontalHighlightIndicator;
116         lineScatterCandleRadarDataSet.mDrawVerticalHighlightIndicator = mDrawVerticalHighlightIndicator;
117         lineScatterCandleRadarDataSet.mHighlightLineWidth = mHighlightLineWidth;
118         lineScatterCandleRadarDataSet.mHighlightDashPathEffect = mHighlightDashPathEffect;
119     }
120 }
121