MPAndroidChart使用-散点图、雷达图、饼图等……
ScatterChart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| private void setScatterProperties() { xAxis = scatterChart.getXAxis(); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setLabelRotationAngle(90); xAxis.setGranularityEnabled(true); xAxis.setGranularity(1f); xAxis.setAxisMinimum(0f); xAxis.setAxisMaximum(86400f); scatterChart.setVisibleXRange(0, 35); xAxis.setLabelCount(35); Log.d(TAG, "getLableCount: " + xAxis.getLabelCount());
YAxis axisLeft = scatterChart.getAxisLeft(); YAxis axisRight = scatterChart.getAxisRight(); axisRight.setEnabled(false); axisLeft.setGranularityEnabled(true); axisLeft.setGranularity(1); axisLeft.setAxisMinimum(0); axisLeft.setAxisMaximum(eventIndexKeys.length); scatterChart.setVisibleYRange(0, 8, YAxis.AxisDependency.LEFT); axisLeft.setLabelCount(8); axisLeft.setValueFormatter(new YAxisValueFormatter(eventIndexKeys));
scatterChart.getLegend().setEnabled(false);
scatterChart.setExtraBottomOffset(10);
scatterChartDescription = scatterChart.getDescription();
}
|
RadarChart
BubbleChart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| private void setBubbleProperties() { bubbleChart.setDrawBorders(false); bubbleChart.setDrawGridBackground(false); bubbleChart.setGridBackgroundColor(Color.GRAY); bubbleChart.setTouchEnabled(true); bubbleChart.setDragEnabled(true); Legend legend = bubbleChart.getLegend(); legend.setForm(Legend.LegendForm.CIRCLE); legend.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); legend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
XAxis xAxis = bubbleChart.getXAxis(); xAxis.setGranularity(1); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setAxisMinimum(0); Log.d(TAG, "labelCount: " + xAxis.getLabelCount());
YAxis axisLeft = bubbleChart.getAxisLeft(); YAxis axisRight = bubbleChart.getAxisRight(); axisRight.setEnabled(false); axisLeft.setGranularity(1); axisLeft.setLabelCount(10);
Description description = bubbleChart.getDescription(); description.setText("实时行为气泡图"); description.setTextColor(Color.RED); Log.d(TAG, "position: " + description.getPosition() + ", width: " + bubbleChart.getWidth() + ", height: " + bubbleChart.getHeight());
}
|