本文整理匯總了Java中com.github.mikephil.charting.charts.PieChart.setDescription方法的典型用法代碼示例。如果您正苦於以下問題:Java PieChart.setDescription方法的具體用法?Java PieChart.setDescription怎麽用?Java PieChart.setDescription使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.mikephil.charting.charts.PieChart
的用法示例。
在下文中一共展示了PieChart.setDescription方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateView
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.frag_simple_pie, container, false);
mChart = (PieChart) v.findViewById(R.id.pieChart1);
mChart.setDescription("");
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "OpenSans-Light.ttf");
mChart.setCenterTextTypeface(tf);
mChart.setCenterText(generateCenterText());
mChart.setCenterTextSize(10f);
mChart.setCenterTextTypeface(tf);
// radius of the center hole in percent of maximum radius
mChart.setHoleRadius(45f);
mChart.setTransparentCircleRadius(50f);
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.RIGHT_OF_CHART);
mChart.setData(generatePieData());
return v;
}
示例2: setDefaultPieChartConfig
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
public static PieChart setDefaultPieChartConfig(PieChart chart) {
chart.setDrawHoleEnabled(true);
chart.setHoleColor(Color.WHITE);
chart.setTransparentCircleColor(Color.WHITE);
chart.setTransparentCircleAlpha(110);
chart.setDragDecelerationFrictionCoef(0.95f);
chart.setHoleRadius(58f);
chart.setTransparentCircleRadius(61f);
chart.setDescription("");
chart.setUsePercentValues(true);
chart.setEntryLabelColor(Color.WHITE);
chart.setDrawCenterText(true);
chart.setCenterTextSize(18f);
chart.setCenterTextColor(ContextCompat.getColor(chart.getContext(), R.color.colorSecondaryText));
chart.setRotationAngle(0);
chart.setRotationEnabled(true);
chart.setHighlightPerTapEnabled(true);
chart.setMaxHighlightDistance(400f);
chart.setCenterTextTypeface(Typeface.createFromAsset(chart.getContext().getAssets(), "fonts/Lato-Regular.ttf"));
chart.setEntryLabelTypeface(Typeface.createFromAsset(chart.getContext().getAssets(), "fonts/Lato-Regular.ttf"));
chart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
return chart;
}
示例3: initializeViews
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
private void initializeViews() {
titleTextView = (TextView) findViewById(R.id.view_chart_pie_title);
titleTextView.setText(titleText);
titleTextView.setTextColor(titleTextColor);
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize);
titleTextView.setTypeface(Typeface.create(titleTextTypeface, Typeface.NORMAL));
chart = (PieChart) findViewById(R.id.view_chart_pie);
chart.setDrawSliceText(false);
chart.setTouchEnabled(false);
chart.setHoleRadius(0);
chart.setTransparentCircleRadius(0);
chart.getLegend().setEnabled(false);
chart.setDescription("");
chart.setDrawCenterText(false);
rowContainer = (LinearLayout) findViewById(R.id.view_chart_pie_rows);
}
示例4: initializeViews
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
private void initializeViews() {
titleTextView = (TextView) findViewById(R.id.view_chart_progress_title);
titleTextView.setText(titleText);
titleTextView.setTextColor(titleTextColor);
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize);
titleTextView.setTypeface(Typeface.create(titleTextTypeface, Typeface.NORMAL));
finishView = (TextView) findViewById(R.id.view_chart_progress_finish);
finishView.setText(finishText);
finishView.setTextColor(finishTextColor);
tabLayout = (TabLayout) findViewById(R.id.view_chart_progress_tabs);
tabLayout.setSelectedTabIndicatorColor(tabIndicatorColor);
tabLayout.setTabTextColors(tabTextColor, tabSelectedTextColor);
chart = (PieChart) findViewById(R.id.view_chart_progress_chart);
chart.setDrawSliceText(false);
chart.setTouchEnabled(false);
chart.setHoleColor(Color.TRANSPARENT);
chart.setHoleRadius(95f);
chart.getLegend().setEnabled(false);
chart.setDescription("");
chart.setCenterTextColor(centerTextColor);
chart.setCenterTextSize(centerTextSize);
chart.setCenterTextTypeface(Typeface.create(centerTextTypeface, Typeface.NORMAL));
}
示例5: initializeChart
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
/**
* Initializes the PieChart with the given parameters. Automatically hides description and adds animation.
*
* @param chart: PieChart object defined in XML layout
* @param colorTemplate: int[] array of colors, where each color is a resource, i.e. R.color.green
* @param data: HashMap of section name label to value, i.e. "Yes": 40, "No": 60
*/
public void initializeChart(PieChart chart, int[] colorTemplate, HashMap<String, Integer> data) {
// Add y-values from data to the pie chart data set
ArrayList<Entry> values = new ArrayList<Entry>();
int index = 0;
for (int value : data.values())
values.add(new Entry(value, index++));
PieDataSet dataSet = new PieDataSet(values, "");
// Create section labels and disable x-value labels
chart.setData(new PieData(new ArrayList<String>(data.keySet()), dataSet));
chart.setDrawXValues(false);
// Add colors from color template
dataSet.setColors(colorTemplate);
// Hide description and legend
chart.setDescription("");
chart.setDrawLegend(false);
// Add animation
chart.animateXY(1500, 1500);
}
示例6: setSizePieChart
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
private void setSizePieChart() {
PieChart pieChart = (PieChart) findViewById(R.id.size_pie_chart);
ArrayList<Entry> yVals = new ArrayList<Entry>();
yVals.add(new Entry(totalSize(DeviceDataContract.VideoDataEntry.TABLE_NAME, VideoDataCollector.videoColumnNames), 0));
yVals.add(new Entry(totalSize(DeviceDataContract.ImageDataEntry.TABLE_NAME, ImageDataCollector.imageColumnNames), 1));
yVals.add(new Entry(totalSize(DeviceDataContract.AudioDataEntry.TABLE_NAME, AudioDataCollector.audioColumnNames), 2));
yVals.add(new Entry(totalSize(DeviceDataContract.TextDataEntry.TABLE_NAME, TextDataCollector.textColumnNames), 3));
ArrayList<String> xVals = new ArrayList<String>();
xVals.add("Videos (kB)");
xVals.add("Images (kB)");
xVals.add("Audio (kB)");
xVals.add("Text files (kB)");
PieDataSet pieDataSet = new PieDataSet(yVals, "");
int[] colorsi = new int[] {R.color.red, R.color.blue, R.color.yellow, R.color.green} ;
pieDataSet.setColors(colorsi, this);
PieData data = new PieData(xVals, pieDataSet);
pieChart.setDescription("");
pieChart.setData(data);
}
示例7: setCountPieChart
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
private void setCountPieChart() {
PieChart pieChart = (PieChart) findViewById(R.id.count_pie_chart);
ArrayList<Entry> yVals = new ArrayList<Entry>();
yVals.add(new Entry(count(DeviceDataContract.VideoDataEntry.TABLE_NAME, VideoDataCollector.videoColumnNames), 0));
yVals.add(new Entry(count(DeviceDataContract.ImageDataEntry.TABLE_NAME, ImageDataCollector.imageColumnNames), 1));
yVals.add(new Entry(count(DeviceDataContract.AudioDataEntry.TABLE_NAME, AudioDataCollector.audioColumnNames), 2));
yVals.add(new Entry(count(DeviceDataContract.TextDataEntry.TABLE_NAME, TextDataCollector.textColumnNames), 3));
yVals.add(new Entry(count(DeviceDataContract.ApplicationDataEntry.TABLE_NAME, ApplicationDataCollector.applicationDataColumnNames), 4));
ArrayList<String> xVals = new ArrayList<String>();
xVals.add("Videos");
xVals.add("Images");
xVals.add("Audio");
xVals.add("Text files");
xVals.add("Applications");
PieDataSet pieDataSet = new PieDataSet(yVals, "");
int[] colorsi = new int[] {R.color.red, R.color.blue, R.color.yellow, R.color.green} ;
pieDataSet.setColors(colorsi, this);
PieData data = new PieData(xVals, pieDataSet);
pieChart.setDescription("");
pieChart.setData(data);
}
示例8: configChart
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
private void configChart(Station station, PieChart mChart) {
mChart.setDescription("");
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
mChart.setCenterText(getString(R.string.base_state));
mChart.setDrawHoleEnabled(true);
mChart.setHoleColorTransparent(true);
mChart.setUsePercentValues(false);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setTouchEnabled(false);
mChart.setRotationEnabled(false);
mChart.setRotationAngle(0);
setData(mChart, station);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
// mChart.spin(2000, 0, 360);
Legend l = mChart.getLegend();
l.setEnabled(false);
l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
}
示例9: setupPie
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
private void setupPie(PieChart pieChart, int pos, float dados[], String labels[]) {
List<PieEntry> entries = new ArrayList<>();
int index = 0;
for (float dado : dados) {
entries.add(new PieEntry(dado, labels[index]));
index++;
}
//entries.add(new PieEntry(24.0f, "Red"));
//entries.add(new PieEntry(30.8f, "Blue"));
PieDataSet set = new PieDataSet(entries, "");
Description description = new Description();
description.setText(" ");
pieChart.setDescription(description);
set.setColors(ColorTemplate.MATERIAL_COLORS);
PieData data = new PieData(set);
pieChart.setData(data);
pieChart.invalidate();
Legend l = pieChart.getLegend();
l.setFormSize(15f); // set the size of the legend forms/shapes
l.setForm(Legend.LegendForm.CIRCLE); // set what type of form/shape should be used
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
l.setTextSize(18f);
l.setTextColor(Color.BLACK);
l.setXEntrySpace(5f); // set the space between the legend entries on the x-axis
l.setYEntrySpace(5f);
pieChart.animateXY(3000, 3000);
}
示例10: setChartOptions
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
private void setChartOptions(PieChart chart) {
Paint p = chart.getPaint(PieChart.PAINT_INFO);
p.setTextSize(32);
p.setColor(0xFF444444);
chart.setNoDataText("Dados indisponíveis.");
chart.setUsePercentValues(true);
chart.setHoleColor(Color.TRANSPARENT);
chart.setHoleRadius(40f);
chart.setTransparentCircleRadius(40f);
chart.setDrawCenterText(true);
chart.setDescription("");
chart.setRotationAngle(0);
chart.setRotationEnabled(true);
chart.getLegend().setEnabled(false);
}
示例11: getFormattedPieChart
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
/**
* Formats a pie chart in a standardized way
* @param c Context
* @param p Pie chart
* @param shouldShowLegend
* @return the PieChart, whose data must be set and invalidated
*/
public static PieChart getFormattedPieChart(Context c, PieChart p, boolean shouldShowLegend) {
Legend cLegend = p.getLegend();
if (shouldShowLegend) {
cLegend.setEnabled(true);
cLegend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
cLegend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
cLegend.setOrientation(Legend.LegendOrientation.HORIZONTAL);
cLegend.setDrawInside(false);
cLegend.setForm(Legend.LegendForm.CIRCLE);
cLegend.setTextSize(15);
cLegend.setWordWrapEnabled(true);
} else {
cLegend.setEnabled(false);
}
p.setDrawEntryLabels(false);
p.setDescription(EMPTY_CHART_DESCRIPTION);
p.setHoleRadius(60f);
p.setTransparentCircleRadius(65f);
p.setCenterTextSize(20);
if (SettingsActivity.getTheme(c) == SettingsActivity.THEME_NOIR) {
int colorPrimaryNoir = ContextCompat.getColor(c, R.color.colorPrimaryNoir);
int colorPrimaryTextNoir = ContextCompat.getColor(c, R.color.colorPrimaryTextNoir);
p.setHoleColor(colorPrimaryNoir);
p.setTransparentCircleColor(colorPrimaryNoir);
p.setCenterTextColor(colorPrimaryTextNoir);
cLegend.setTextColor(colorPrimaryTextNoir);
}
p.setRotationEnabled(false);
p.setOnChartValueSelectedListener(new PieChartListener(p));
return p;
}
示例12: onCreate
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PieChart pieChart = (PieChart)findViewById(R.id.chart);
ArrayList<Entry> entries = new ArrayList<>();
entries.add(new Entry(4f,0));
entries.add(new Entry(8f,1));
entries.add(new Entry(6f,2));
entries.add(new Entry(12f,3));
// entries.add(new Entry(18f,4));
// entries.add(new Entry(9f,0));
PieDataSet dataset = new PieDataSet(entries, "# of calls");
ArrayList<String> labels = new ArrayList<String>();
labels.add("January");
labels.add("February");
labels.add("March");
labels.add("April");
// labels.add("May");
// labels.add("June");
PieData data = new PieData(labels, dataset); // initialize Piedata
pieChart.setData(data);
pieChart.setDescription("Description");
dataset.setColors(ColorTemplate.COLORFUL_COLORS);
pieChart.animateY(2000);
}
示例13: setupSleepStagesChart
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
private void setupSleepStagesChart(int sleep, int awake) {
PieChart pieChart = (PieChart) findViewById(R.id.sleepstages);
ArrayList<Entry> pieComp1 = new ArrayList<Entry>();
Entry c1e1 = new Entry(sleep, 0);
pieComp1.add(c1e1);
Entry c1e2 = new Entry(awake, 1);
pieComp1.add(c1e2);
PieDataSet pieDataSet = new PieDataSet(pieComp1, "Sleep stages");
pieDataSet.setColors(ColorTemplate.PASTEL_COLORS);
ArrayList<String> xPieVals = new ArrayList<String>();
xPieVals.add("Deep");
xPieVals.add("Light");
PieData pieData = new PieData(xPieVals,pieDataSet);
pieData.setValueTextSize(14);
pieData.setValueTextColor(Color.WHITE);
pieChart.setData(pieData);
Legend pieLegend = pieChart.getLegend();
pieLegend.setEnabled(false);
pieChart.setUsePercentValues(true);
pieChart.setDescription("Sleep stages");
pieChart.setHardwareAccelerationEnabled(true);
pieChart.setBackgroundColor(Color.parseColor("#52B19D"));
pieChart.setHoleColor(Color.parseColor("#52B09C"));
pieChart.invalidate();
}
示例14: setupLightChart
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
private void setupLightChart(int night, int dawn, int day) {
PieChart pieChart = (PieChart) findViewById(R.id.lightquality);
ArrayList<Entry> pieComp1 = new ArrayList<Entry>();
Entry c1e1 = new Entry(night, 0);
pieComp1.add(c1e1);
Entry c1e2 = new Entry(dawn, 1);
pieComp1.add(c1e2);
Entry c1e3 = new Entry(day, 2);
pieComp1.add(c1e3);
PieDataSet pieDataSet = new PieDataSet(pieComp1, "Light quality");
pieDataSet.setColors(ColorTemplate.PASTEL_COLORS);
ArrayList<String> xPieVals = new ArrayList<String>();
xPieVals.add("Night");
xPieVals.add("Dawn");
xPieVals.add("Day");
PieData pieData = new PieData(xPieVals,pieDataSet);
pieData.setValueTextSize(14);
pieData.setValueTextColor(Color.WHITE);
pieChart.setData(pieData);
Legend pieLegend = pieChart.getLegend();
pieLegend.setEnabled(false);
pieChart.setUsePercentValues(true);
pieChart.setDescription("Light quality");
pieChart.setHardwareAccelerationEnabled(true);
pieChart.setHoleColor(Color.parseColor("#52B09C"));
pieChart.invalidate();
}
示例15: onCreateView
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//return buildChart();
mLayout = (LinearLayout) inflater.inflate(R.layout.chart_pie_fragment, container, false);
mChart = (PieChart) mLayout.findViewById(R.id.chartPie);
mChart.setUsePercentValues(true);
// change the color of the center-hole
mChart.setHoleColor(Color.TRANSPARENT);
mChart.setHoleRadius(30f);
mChart.setDescription("");
mChart.setDrawCenterText(true);
mChart.setDrawHoleEnabled(true);
mChart.setRotationAngle(0);
// enable rotation of the chart by touch
mChart.setRotationEnabled(true);
// mChart.setUnit(" €");
// mChart.setDrawUnitsInChart(true);
// add a selection listener
mChart.setOnChartValueSelectedListener(this);
// mChart.setTouchEnabled(false);
//mChart.setCenterText("MPAndroidChart\nLibrary");
mChart.animateXY(1500, 1500);
return mLayout;
}