本文整理汇总了Java中com.github.mikephil.charting.charts.ScatterChart类的典型用法代码示例。如果您正苦于以下问题:Java ScatterChart类的具体用法?Java ScatterChart怎么用?Java ScatterChart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScatterChart类属于com.github.mikephil.charting.charts包,在下文中一共展示了ScatterChart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateScatterData
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
protected ScatterData generateScatterData(int dataSets, float range, int count) {
ArrayList<IScatterDataSet> sets = new ArrayList<IScatterDataSet>();
ScatterChart.ScatterShape[] shapes = ScatterChart.ScatterShape.getAllDefaultShapes();
for(int i = 0; i < dataSets; i++) {
ArrayList<Entry> entries = new ArrayList<Entry>();
for(int j = 0; j < count; j++) {
entries.add(new Entry(j, (float) (Math.random() * range) + range / 4));
}
ScatterDataSet ds = new ScatterDataSet(entries, getLabel(i));
ds.setScatterShapeSize(12f);
ds.setScatterShape(shapes[i % shapes.length]);
ds.setColors(ColorTemplate.COLORFUL_COLORS);
ds.setScatterShapeSize(9f);
sets.add(ds);
}
ScatterData d = new ScatterData(sets);
d.setValueTypeface(tf);
return d;
}
示例2: setData
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
private void setData() {
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
RealmScatterDataSet<RealmDemoData> set = new RealmScatterDataSet<RealmDemoData>(result, "xValue", "yValue");
set.setLabel("Realm ScatterDataSet");
set.setScatterShapeSize(9f);
set.setColor(ColorTemplate.rgb("#CDDC39"));
set.setScatterShape(ScatterChart.ScatterShape.CIRCLE);
ArrayList<IScatterDataSet> dataSets = new ArrayList<IScatterDataSet>();
dataSets.add(set); // add the dataset
// create a data object with the dataset list
ScatterData data = new ScatterData(dataSets);
styleData(data);
// set data
mChart.setData(data);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
示例3: generateScatterData
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
protected ScatterData generateScatterData(int dataSets, float range, int count) {
ArrayList<IScatterDataSet> sets = new ArrayList<IScatterDataSet>();
ScatterShape[] shapes = ScatterChart.getAllPossibleShapes();
for(int i = 0; i < dataSets; i++) {
ArrayList<Entry> entries = new ArrayList<Entry>();
for(int j = 0; j < count; j++) {
entries.add(new Entry((float) (Math.random() * range) + range / 4, j));
}
ScatterDataSet ds = new ScatterDataSet(entries, getLabel(i));
ds.setScatterShapeSize(12f);
ds.setScatterShape(shapes[i % shapes.length]);
ds.setColors(ColorTemplate.COLORFUL_COLORS);
ds.setScatterShapeSize(9f);
sets.add(ds);
}
ScatterData d = new ScatterData(ChartData.generateXVals(0, count), sets);
d.setValueTypeface(tf);
return d;
}
示例4: setData
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
private void setData() {
RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);
RealmScatterDataSet<RealmDemoData> set = new RealmScatterDataSet<RealmDemoData>(result, "value", "xIndex");
set.setLabel("Realm ScatterDataSet");
set.setScatterShapeSize(9f);
set.setColor(ColorTemplate.rgb("#CDDC39"));
set.setScatterShape(ScatterChart.ScatterShape.CIRCLE);
ArrayList<IScatterDataSet> dataSets = new ArrayList<IScatterDataSet>();
dataSets.add(set); // add the dataset
// create a data object with the dataset list
RealmScatterData data = new RealmScatterData(result, "xValue", dataSets);
styleData(data);
// set data
mChart.setData(data);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
示例5: onCreateView
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
logger = SimpleLogger.getInstance(getContext());
waltDevice = WaltDevice.getInstance(getContext());
// Inflate the layout for this fragment
final View view = inflater.inflate(R.layout.fragment_drag_latency, container, false);
logTextView = (TextView) view.findViewById(R.id.txt_log_drag_latency);
startButton = view.findViewById(R.id.button_start_drag);
restartButton = view.findViewById(R.id.button_restart_drag);
finishButton = view.findViewById(R.id.button_finish_drag);
touchCatcher = (TouchCatcherView) view.findViewById(R.id.tap_catcher);
crossCountsView = (TextView) view.findViewById(R.id.txt_cross_counts);
dragCountsView = (TextView) view.findViewById(R.id.txt_drag_counts);
latencyChart = (ScatterChart) view.findViewById(R.id.latency_chart);
latencyChartLayout = view.findViewById(R.id.latency_chart_layout);
logTextView.setMovementMethod(new ScrollingMovementMethod());
view.findViewById(R.id.button_close_chart).setOnClickListener(this);
restartButton.setEnabled(false);
finishButton.setEnabled(false);
return view;
}
示例6: onCreateView
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
logger = SimpleLogger.getInstance(getContext());
waltDevice = WaltDevice.getInstance(getContext());
// Inflate the layout for this fragment
final View view = inflater.inflate(R.layout.fragment_accelerometer, container, false);
logTextView = (TextView) view.findViewById(R.id.txt_log);
startButton = view.findViewById(R.id.button_start);
latencyChart = (ScatterChart) view.findViewById(R.id.latency_chart);
latencyChartLayout = view.findViewById(R.id.latency_chart_layout);
logTextView.setMovementMethod(new ScrollingMovementMethod());
view.findViewById(R.id.button_close_chart).setOnClickListener(this);
sensorManager = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
if (accelerometer == null) {
logger.log("ERROR! Accelerometer sensor not found");
}
return view;
}
示例7: drawLatencyChart
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
private void drawLatencyChart(List<Entry> phoneEntriesShifted, List<Entry> waltEntries) {
final ScatterDataSet dataSetWalt =
new ScatterDataSet(waltEntries, "WALT Events");
dataSetWalt.setColor(Color.BLUE);
dataSetWalt.setScatterShape(ScatterChart.ScatterShape.CIRCLE);
dataSetWalt.setScatterShapeSize(8f);
final ScatterDataSet dataSetPhoneShifted =
new ScatterDataSet(phoneEntriesShifted, "Phone Events Shifted");
dataSetPhoneShifted.setColor(Color.RED);
dataSetPhoneShifted.setScatterShapeSize(10f);
dataSetPhoneShifted.setScatterShape(ScatterChart.ScatterShape.X);
final ScatterData scatterData = new ScatterData(dataSetWalt, dataSetPhoneShifted);
final Description desc = new Description();
desc.setText("");
desc.setTextSize(12f);
latencyChart.setDescription(desc);
latencyChart.setData(scatterData);
latencyChart.invalidate();
latencyChartLayout.setVisibility(View.VISIBLE);
}
示例8: getRendererForShape
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
public static IShapeRenderer getRendererForShape(ScatterChart.ScatterShape shape) {
switch (shape) {
case SQUARE:
return new SquareShapeRenderer();
case CIRCLE:
return new CircleShapeRenderer();
case TRIANGLE:
return new TriangleShapeRenderer();
case CROSS:
return new CrossShapeRenderer();
case X:
return new XShapeRenderer();
case CHEVRON_UP:
return new ChevronUpShapeRenderer();
case CHEVRON_DOWN:
return new ChevronDownShapeRenderer();
}
return null;
}
示例9: getRendererForShape
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
public static IShapeRenderer getRendererForShape(ScatterChart.ScatterShape shape) {
switch (shape) {
case SQUARE: return new SquareShapeRenderer();
case CIRCLE: return new CircleShapeRenderer();
case TRIANGLE: return new TriangleShapeRenderer();
case CROSS: return new CrossShapeRenderer();
case X: return new XShapeRenderer();
case CHEVRON_UP: return new ChevronUpShapeRenderer();
case CHEVRON_DOWN: return new ChevronDownShapeRenderer();
}
return null;
}
示例10: onCreateView
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.frag_simple_scatter, container, false);
mChart = (ScatterChart) v.findViewById(R.id.scatterChart1);
mChart.getDescription().setEnabled(false);
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf");
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
mv.setChartView(mChart); // For bounds control
mChart.setMarker(mv);
mChart.setDrawGridBackground(false);
mChart.setData(generateScatterData(6, 10000, 200));
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(true);
xAxis.setPosition(XAxisPosition.BOTTOM);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(tf);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setTypeface(tf);
rightAxis.setDrawGridLines(false);
Legend l = mChart.getLegend();
l.setWordWrapEnabled(true);
l.setTypeface(tf);
l.setFormSize(14f);
l.setTextSize(9f);
// increase the space between legend & bottom and legend & content
l.setYOffset(13f);
mChart.setExtraBottomOffset(16f);
return v;
}
示例11: onCreate
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_scatterchart_noseekbar);
mChart = (ScatterChart) findViewById(R.id.chart1);
setup(mChart);
mChart.getAxisLeft().setDrawGridLines(false);
mChart.getXAxis().setDrawGridLines(false);
mChart.setPinchZoom(true);
}
示例12: onCreateView
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.frag_simple_scatter, container, false);
mChart = (ScatterChart) v.findViewById(R.id.scatterChart1);
mChart.setDescription("");
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf");
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
mChart.setMarkerView(mv);
mChart.setDrawGridBackground(false);
mChart.setData(generateScatterData(6, 10000, 200));
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(true);
xAxis.setPosition(XAxisPosition.BOTTOM);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(tf);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setTypeface(tf);
rightAxis.setDrawGridLines(false);
Legend l = mChart.getLegend();
l.setWordWrapEnabled(true);
l.setTypeface(tf);
l.setFormSize(14f);
l.setTextSize(9f);
// increase the space between legend & bottom and legend & content
l.setYOffset(13f);
mChart.setExtraBottomOffset(16f);
return v;
}
示例13: buildScatterDataForProperty
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
private ScatterData buildScatterDataForProperty(WaterProfile profile, String property){
ScatterData data = new ScatterData();
if (profile != null){
// Get all the measurements for the property
Map<Double,Double> propertyMeasurementByDepth = profile.getMeasurementsForProperty(property);
ArrayList<Entry> entries = new ArrayList<>();
Set<Double> depths = propertyMeasurementByDepth.keySet();
for (Double depth : depths){
float y = (float) Math.abs(depth);
float x = (float) propertyMeasurementByDepth.get(depth).doubleValue();
entries.add(new Entry(x, y));
}
Collections.sort(entries, new EntryXComparator());
ScatterDataSet set = new ScatterDataSet(entries, property);
set.setColor(Color.BLACK);
set.setScatterShape(ScatterChart.ScatterShape.CIRCLE);
set.setScatterShapeSize(20f);
set.setDrawValues(false);
data.addDataSet(set);
}else{
Log.e(TAG, "Profile data object is null!");
}
return data;
}
示例14: generateScatterData
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
/**
* Prepare ScatterData object
* @param averageValue
* @param seriesName
* @return ScatterData
*/
private ScatterData generateScatterData(float averageValue, String seriesName){
ScatterData d = new ScatterData();
ArrayList<Entry> entries = new ArrayList<>();
entries.add(new Entry(1.5f, averageValue));
ScatterDataSet set = new ScatterDataSet(entries, seriesName);
set.setColor(Color.parseColor("#FF4081"));
set.setScatterShape(ScatterChart.ScatterShape.SQUARE);
set.setScatterShapeSize(15f);
set.setDrawValues(false);
set.setValueTextSize(10f);
d.addDataSet(set);
return d;
}
示例15: drawLatencyGraph
import com.github.mikephil.charting.charts.ScatterChart; //导入依赖的package包/类
private void drawLatencyGraph(double[] ft, double[] fy, double[] lt, double averageBestShift) {
final ArrayList<Entry> touchEntries = new ArrayList<>();
final ArrayList<Entry> laserEntries = new ArrayList<>();
final double[] laserT = new double[lt.length];
for (int i = 0; i < ft.length; i++) {
touchEntries.add(new Entry((float) ft[i], (float) fy[i]));
}
for (int i = 0; i < lt.length; i++) {
laserT[i] = lt[i] + averageBestShift;
}
final double[] laserY = Utils.interp(laserT, ft, fy);
for (int i = 0; i < laserY.length; i++) {
laserEntries.add(new Entry((float) laserT[i], (float) laserY[i]));
}
final ScatterDataSet dataSetTouch = new ScatterDataSet(touchEntries, "Touch Events");
dataSetTouch.setScatterShape(ScatterChart.ScatterShape.CIRCLE);
dataSetTouch.setScatterShapeSize(8f);
final ScatterDataSet dataSetLaser = new ScatterDataSet(laserEntries,
String.format(Locale.US, "Laser Events Latency=%.1f ms", averageBestShift));
dataSetLaser.setColor(Color.RED);
dataSetLaser.setScatterShapeSize(10f);
dataSetLaser.setScatterShape(ScatterChart.ScatterShape.X);
final ScatterData scatterData = new ScatterData(dataSetTouch, dataSetLaser);
final Description desc = new Description();
desc.setText("Y-Position [pixels] vs. Time [ms]");
desc.setTextSize(12f);
latencyChart.setDescription(desc);
latencyChart.setData(scatterData);
latencyChartLayout.setVisibility(View.VISIBLE);
}