本文整理汇总了Java中com.github.mikephil.charting.charts.PieChart.highlightValues方法的典型用法代码示例。如果您正苦于以下问题:Java PieChart.highlightValues方法的具体用法?Java PieChart.highlightValues怎么用?Java PieChart.highlightValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.charts.PieChart
的用法示例。
在下文中一共展示了PieChart.highlightValues方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpPieChart
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
/**
* @param pieChart that needs to be setup
* @param chartData data that will displayed on the chart
* @param chartType type of the chart
*/
public void setUpPieChart(PieChart pieChart, Map<String, Integer> chartData, @PieChartType int chartType) {
formatPieChart(pieChart);
formatPieChartLegend(pieChart.getLegend());
List<PieChartItem> pieChartItems = setUpData(chartData);
pieChart.setData(generatePieData(pieChartItems));
pieChart.highlightValues(null);
switch (chartType) {
case LANGUAGE_CHART_ID:
languageDataItems = pieChartItems;
break;
case EDITORS_CHART_ID:
editorDataItems = pieChartItems;
break;
case OS_CHART_ID:
osDataItems = pieChartItems;
break;
default:
throw new UnsupportedOperationException("Invalid chart type");
}
}
示例2: handleHighlights
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
protected void handleHighlights(PieChart pieChart, boolean isExpanded) {
if (isExpanded) {
Highlight[] highlights = pieChart.getHighlighted();
if (highlights != null && highlights.length != 0) {
pieChart.highlightValues(null);
}
}
}
示例3: setPieChart
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
/**
* Set the pie pattern
* @param pieChart chart
* @param chartData pie chart data
* @param title chart title
* @param tf Typeface font
*/
public static void setPieChart(PieChart pieChart, ChartData<?> chartData,
SpannableString title, Typeface tf) {
chartData.setValueFormatter(new PercentFormatter());
chartData.setValueTextSize(11f);
chartData.setValueTextColor(Color.BLACK);
chartData.setValueTypeface(tf);
pieChart.setUsePercentValues(true);
pieChart.getDescription().setEnabled(false);
pieChart.setExtraOffsets(5, 10, 5, 5);
pieChart.setDragDecelerationFrictionCoef(0.95f);
pieChart.setCenterTextTypeface(tf);
pieChart.setCenterText(title);
pieChart.setExtraOffsets(20.f, 0.f, 20.f, 0.f);
pieChart.setDrawHoleEnabled(true);
pieChart.setHoleColor(Color.WHITE);
pieChart.setTransparentCircleColor(Color.WHITE);
pieChart.setTransparentCircleAlpha(110);
pieChart.setHoleRadius(58f);
pieChart.setTransparentCircleRadius(61f);
pieChart.setDrawCenterText(true);
pieChart.setRotationAngle(0);
pieChart.setRotationEnabled(true);// enable rotation of the chart by touch
pieChart.setHighlightPerTapEnabled(true);
pieChart.setEntryLabelTextSize(10f);
Legend l = pieChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setEnabled(false);
pieChart.setData((PieData) chartData);
pieChart.animateY(DURATION_MEDIUM, Easing.EasingOption.EaseInOutQuad);
pieChart.highlightValues(null);// undo all highlights
pieChart.invalidate();
}
示例4: setChartData
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
private void setChartData(PieChart chart, List<Integer> yData) {
ArrayList<Entry> yVals = new ArrayList<>();
for (int i = 0; i < yData.size(); ++i) {
yVals.add(new Entry(yData.get(i), i));
}
ArrayList<String> xVals = new ArrayList<>();
for (int i = 0; i < xData.length; ++i) {
xVals.add(xData[i]);
}
PieDataSet dataSet = new PieDataSet(yVals, "");
dataSet.setSliceSpace(3);
dataSet.setSelectionShift(5);
ArrayList<Integer> colors = new ArrayList<>();
colors.add(0xFFDD2C00);
colors.add(0xFFFF6D00);
colors.add(0xFFFFAB00);
colors.add(0xFFAEEA00);
colors.add(0xFF64DD17);
dataSet.setColors(colors);
PieData data = new PieData(xVals, dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(15f);
data.setValueTextColor(Color.BLACK);
chart.setData(data);
chart.highlightValues(null);
chart.invalidate();
}
示例5: setData
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
private void setData(PieChart colorPie, float value) {
ArrayList<PieEntry> entries = new ArrayList<PieEntry>();
float result = value / 5f;
Log.d(TAG + " result ", result + "");
entries.add(new PieEntry(result, 0));
entries.add(new PieEntry(1 - result, 1));
// NOTE: The order of the entries when being added to the entries array determines their position around the center of
// the chart.
// colorPie.setCenterTextTypeface(mTfLight);
int centerTextColor = android.graphics.Color.argb(255, 57, 197, 193);
colorPie.setCenterTextColor(centerTextColor);
PieDataSet dataSet = new PieDataSet(entries, "");
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(3f);
// add a lot of colors
ArrayList<Integer> colors = new ArrayList<Integer>();
colors.add(Color.argb(120, 57, 197, 193));
colorPie.setCenterText(value + "");
colorPie.setCenterTextSize(30);
colors.add(Color.argb(100, 214, 214, 214));
dataSet.setColors(colors);
PieData data = new PieData(dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(0f);
data.setValueTextColor(Color.WHITE);
colorPie.setData(data);
// undo all highlights
colorPie.highlightValues(null);
colorPie.invalidate();
}
示例6: updateChartData
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
private void updateChartData(PieChart chart) {
ArrayList<PieEntry> entries = new ArrayList<>();
ArrayList<Integer> colors = new ArrayList<>();
double sum = 0;
for (int i = 0; i < categorizedExpenses.getCategories().size(); i++) {
Category c = categorizedExpenses.getCategory(i);
Report r = categorizedExpenses.getReport(c);
sum += r.getTotalAmount().doubleValue();
entries.add(new PieEntry((int) (r.getTotalAmount().doubleValue() * 1000), c.getTitle()));
colors.add(c.getColor());
}
PieDataSet dataSet = new PieDataSet(entries, "Outlay");
dataSet.setSliceSpace(2f);
dataSet.setSelectionShift(10f);
dataSet.setColors(colors);
PieData data = new PieData(dataSet);
data.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> NumberUtils.formatAmount((double) value / 1000));
data.setValueTextSize(11f);
data.setValueTextColor(Color.WHITE);
chart.setData(data);
chart.setCenterText(NumberUtils.formatAmount(sum));
chart.highlightValues(null);
chart.invalidate();
}
示例7: setData
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
private void setData(PieChart mChart, Station station) {
ArrayList<Entry> yVals1 = new ArrayList<Entry>();
float inactive = (float) Integer.parseInt(station.getNumberBases()) - Integer.parseInt(station.getBasesFree()) - Integer.parseInt(station.getBikeEngaged());
yVals1.add(new Entry(Float.parseFloat(station.getBasesFree()), 0));
yVals1.add(new Entry(Float.parseFloat(station.getBikeEngaged()), 1));
yVals1.add(new Entry(inactive, 2));
ArrayList<String> xVals = new ArrayList<String>();
for (int i = 0; i < mParties.length + 1; i++)
xVals.add(mParties[i % mParties.length]);
PieDataSet dataSet = new PieDataSet(yVals1, getString(R.string.base_state));
dataSet.setSliceSpace(2f);
dataSet.setSelectionShift(5f);
ArrayList<Integer> colors = new ArrayList<Integer>();
colors.add(ContextCompat.getColor(getActivity(), R.color.red_chart));
colors.add(ContextCompat.getColor(getActivity(), R.color.green_chart));
colors.add(ContextCompat.getColor(getActivity(), R.color.gray_chart));
dataSet.setColors(colors);
PieData data = new PieData(xVals, dataSet);
data.setValueFormatter(new ValueFormatter() {
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
return "" + (int) value;
}
});
data.setValueTextSize(11f);
data.setValueTextColor(Color.BLACK);
mChart.setData(data);
mChart.highlightValues(null);
mChart.invalidate();
}
示例8: clearChartData
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
private void clearChartData(PieChart chart) {
chart.clear();
chart.setData(null);
chart.highlightValues(null);
chart.invalidate();
}
示例9: setData
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
private void setData(PieChart colorPie, int order, int color) {
ArrayList<PieEntry> entries = new ArrayList<PieEntry>();
float colorValue = color / 255f;
entries.add(new PieEntry(colorValue, 0));
entries.add(new PieEntry(1 - colorValue, 1));
// NOTE: The order of the entries when being added to the entries array determines their position around the center of
// the chart.
// colorPie.setCenterTextTypeface(mTfLight);
colorPie.setCenterTextColor(ColorTemplate.getHoloBlue());
PieDataSet dataSet = new PieDataSet(entries, "");
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(3f);
// add a lot of colors
ArrayList<Integer> colors = new ArrayList<Integer>();
colors.clear();
switch (order) {
case 0:
colors.add(Color.argb(100, color, 0, 0));
colorPie.setCenterText("Red");
break;
case 1:
colors.add(Color.argb(100, 0, color, 0));
colorPie.setCenterText("Green");
break;
case 2:
colors.add(Color.argb(100, 0, 0, color));
colorPie.setCenterText("Blue");
break;
}
colors.add(Color.argb(80, 214, 214, 214));
dataSet.setColors(colors);
PieData data = new PieData(dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(0f);
data.setValueTextColor(Color.WHITE);
colorPie.setData(data);
// undo all highlights
colorPie.highlightValues(null);
colorPie.invalidate();
}