1 2 package com.github.mikephil.charting.charts; 3 4 import android.content.Context; 5 import android.util.AttributeSet; 6 7 import com.github.mikephil.charting.data.ScatterData; 8 import com.github.mikephil.charting.interfaces.dataprovider.ScatterDataProvider; 9 import com.github.mikephil.charting.renderer.ScatterChartRenderer; 10 11 /** 12 * The ScatterChart. Draws dots, triangles, squares and custom shapes into the 13 * Chart-View. CIRCLE and SCQUARE offer the best performance, TRIANGLE has the 14 * worst performance. 15 * 16 * @author Philipp Jahoda 17 */ 18 public class ScatterChart extends BarLineChartBase<ScatterData> implements ScatterDataProvider { 19 ScatterChart(Context context)20 public ScatterChart(Context context) { 21 super(context); 22 } 23 ScatterChart(Context context, AttributeSet attrs)24 public ScatterChart(Context context, AttributeSet attrs) { 25 super(context, attrs); 26 } 27 ScatterChart(Context context, AttributeSet attrs, int defStyle)28 public ScatterChart(Context context, AttributeSet attrs, int defStyle) { 29 super(context, attrs, defStyle); 30 } 31 32 33 @Override init()34 protected void init() { 35 super.init(); 36 37 mRenderer = new ScatterChartRenderer(this, mAnimator, mViewPortHandler); 38 39 getXAxis().setSpaceMin(0.5f); 40 getXAxis().setSpaceMax(0.5f); 41 } 42 43 @Override getScatterData()44 public ScatterData getScatterData() { 45 return mData; 46 } 47 48 /** 49 * Predefined ScatterShapes that allow the specification of a shape a ScatterDataSet should be drawn with. 50 * If a ScatterShape is specified for a ScatterDataSet, the required renderer is set. 51 */ 52 public enum ScatterShape { 53 54 SQUARE("SQUARE"), 55 CIRCLE("CIRCLE"), 56 TRIANGLE("TRIANGLE"), 57 CROSS("CROSS"), 58 X("X"), 59 CHEVRON_UP("CHEVRON_UP"), 60 CHEVRON_DOWN("CHEVRON_DOWN"); 61 62 private final String shapeIdentifier; 63 ScatterShape(final String shapeIdentifier)64 ScatterShape(final String shapeIdentifier) { 65 this.shapeIdentifier = shapeIdentifier; 66 } 67 68 @Override toString()69 public String toString() { 70 return shapeIdentifier; 71 } 72 getAllDefaultShapes()73 public static ScatterShape[] getAllDefaultShapes() { 74 return new ScatterShape[]{SQUARE, CIRCLE, TRIANGLE, CROSS, X, CHEVRON_UP, CHEVRON_DOWN}; 75 } 76 } 77 } 78