本文整理汇总了Java中com.github.mikephil.charting.components.Description类的典型用法代码示例。如果您正苦于以下问题:Java Description类的具体用法?Java Description怎么用?Java Description使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Description类属于com.github.mikephil.charting.components包,在下文中一共展示了Description类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPieChart
import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
private void createPieChart(ArrayList<PieEntry> yEntrys, ArrayList<Integer> colors) {
//create the data set
PieDataSet pieDataSet = new PieDataSet(yEntrys, "");
pieDataSet.setSliceSpace(2);
pieDataSet.setValueTextSize(12);
pieDataSet.setColors(colors);
pieChart.setCenterText(start.toString() + "\n" + end.toString());
pieChart.setCenterTextColor(Color.BLACK);
pieChart.setCenterTextSize(20);
pieChart.animateY(2000);
pieChart.animateX(2000);
pieChart.getLegend().setEnabled(true);
Description description = new Description();
description.setText("");
pieChart.setDescription(description);
//create pie data object
PieData pieData = new PieData();
pieData.addDataSet(pieDataSet);
pieChart.setData(pieData);
pieChart.invalidate();
}
示例2: prepareLegend
import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
/**
* Create a legend based on a dummy chart. The legend
* is used by all charts and is positioned
* across the top of the screen.
* @param data - CombinedData used to generate the legend
*/
private void prepareLegend(final CombinedData data){
//The dummy chart is never shown, but it's legend is.
final CombinedChart dummyChart = (CombinedChart) mRoot.findViewById(R.id.legend);
dummyChart.getPaint(Chart.PAINT_DESCRIPTION).setTextAlign(Paint.Align.CENTER);
dummyChart.getXAxis().setEnabled(false);
dummyChart.getAxisRight().setEnabled(false);
dummyChart.getAxisLeft().setEnabled(false);
final Description description = new Description();
description.setText("");
description.setTextSize(10f);
dummyChart.setDescription(description);
dummyChart.setBackgroundColor(Color.WHITE);
dummyChart.setDrawGridBackground(false);
dummyChart.setData(data);
final Legend l = dummyChart.getLegend();
l.setEnabled(true);
// The positioning of the legend effectively
// hides the dummy chart from view.
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
dummyChart.invalidate();
}
示例3: drawLatencyChart
import com.github.mikephil.charting.components.Description; //导入依赖的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);
}
示例4: initializeChart
import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
protected void initializeChart() {
Description description = new Description();
description.setText("");
messagesChart.setDescription(description);
messagesChart.setNoDataText(getIdleText());
messagesChart.setTouchEnabled(false);
messagesChart.setDragEnabled(false);
messagesChart.setPinchZoom(false);
messagesChart.getLegend().setEnabled(false);
messagesChart.getAxisLeft().setAxisMinimum(0);
messagesChart.getAxisLeft().setGranularity(1f);
messagesChart.getAxisRight().setEnabled(false);
messagesChart.getXAxis().setAxisMinimum(0);
messagesChart.getXAxis().setGranularity(1f);
messagesChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
messagesChart.getXAxis().setValueFormatter(new DefaultAxisValueFormatter(0));
LineData data = new LineData();
data.setValueTextColor(Color.WHITE);
messagesChart.setData(data);
}
示例5: initBatteryChart
import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
private void initBatteryChart() {
mBatteryChart = findViewById(R.id.batteryPieChart);
// configure pie chart
mBatteryChart.setUsePercentValues(true);
mBatteryChart.setDescription(new Description());
// enable hole and configure
mBatteryChart.setDrawHoleEnabled(true);
Legend legend = mBatteryChart.getLegend();
legend.setEnabled(false);
}
示例6: setDescription
import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
/**
* 设置描述信息
*
* @param str
*/
public void setDescription(String str) {
Description description = new Description();
description.setText(str);
mBarChart.setDescription(description);
mBarChart.invalidate();
}
示例7: showChart
import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
/**
* Display the chart view
*/
private void showChart(){
final String [] labels = mData.getDataSetLabels();
String property = mData.getDataSetLabels()[labels.length -1];
mChart.setData(mData);
mChart.getAxisLeft().setInverted(true);
mChart.getXAxis().setEnabled(true);
mChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
mChart.getXAxis().setAxisMinimum(mData.getXMin()-1);
mChart.getXAxis().setAxisMaximum(mData.getXMax() + 1);
mChart.getAxisRight().setEnabled(false);
mChart.getAxisLeft().setDrawGridLines(true);
mChart.setDrawGridBackground(true);
final Description description = new Description();
description.setText("");
description.setTextSize(10f);
mChart.setDescription(description);
mChart.getLegend().setEnabled(false);
mChart.invalidate();
if (property.equalsIgnoreCase("TEMPERATURE")){
property = property + " \u2103";
}else if (property.equalsIgnoreCase("SALINITY")){
property = property + " ppm";
}else{
property = property + " \u00b5" + "m/L";
}
mTxtXAxisTitle.setText(property);
}
示例8: setupPie
import com.github.mikephil.charting.components.Description; //导入依赖的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);
}
示例9: drawLatencyGraph
import com.github.mikephil.charting.components.Description; //导入依赖的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);
}
示例10: drawBrightnessChart
import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
private void drawBrightnessChart() {
final String brightnessCurveString = brightnessCurveData.toString();
List<Entry> entries = new ArrayList<>();
// "u" marks the start of the brightness curve data
int startIndex = brightnessCurveString.indexOf("u") + 1;
int endIndex = brightnessCurveString.indexOf("end");
if (endIndex == -1) endIndex = brightnessCurveString.length();
String[] brightnessStrings =
brightnessCurveString.substring(startIndex, endIndex).trim().split("\n");
for (String str : brightnessStrings) {
String[] arr = str.split(" ");
final float timestampMs = Integer.parseInt(arr[0]) / 1000f;
final float brightness = Integer.parseInt(arr[1]);
entries.add(new Entry(timestampMs, brightness));
}
LineDataSet dataSet = new LineDataSet(entries, "Brightness");
dataSet.setColor(Color.BLACK);
dataSet.setValueTextColor(Color.BLACK);
dataSet.setCircleColor(Color.BLACK);
dataSet.setCircleRadius(1.5f);
dataSet.setCircleColorHole(Color.DKGRAY);
LineData lineData = new LineData(dataSet);
brightnessChart.setData(lineData);
final Description desc = new Description();
desc.setText("Screen Brightness [digital level 0-1023] vs. Time [ms]");
desc.setTextSize(12f);
brightnessChart.setDescription(desc);
brightnessChart.getLegend().setEnabled(false);
brightnessChart.invalidate();
brightnessChartLayout.setVisibility(View.VISIBLE);
}
示例11: drawWaveformChart
import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
private void drawWaveformChart() {
final short[] wave = AudioTest.getRecordedWave();
List<Entry> entries = new ArrayList<>();
int frameRate = audioTest.getOptimalFrameRate();
for (int i = 0; i < wave.length; i++) {
float timeStamp = (float) i / frameRate * 1000f;
entries.add(new Entry(timeStamp, (float) wave[i]));
}
LineDataSet dataSet = new LineDataSet(entries, "Waveform");
dataSet.setColor(Color.BLACK);
dataSet.setValueTextColor(Color.BLACK);
dataSet.setCircleColor(ContextCompat.getColor(getContext(), R.color.DarkGreen));
dataSet.setCircleRadius(1.5f);
dataSet.setCircleColorHole(Color.DKGRAY);
LineData lineData = new LineData(dataSet);
chart.setData(lineData);
LimitLine line = new LimitLine(audioTest.getThreshold(), "Threshold");
line.setLineColor(Color.RED);
line.setLabelPosition(LimitLine.LimitLabelPosition.LEFT_TOP);
line.setLineWidth(2f);
line.setTextColor(Color.DKGRAY);
line.setTextSize(10f);
chart.getAxisLeft().addLimitLine(line);
final Description desc = new Description();
desc.setText("Wave [digital level -32768 to +32767] vs. Time [ms]");
desc.setTextSize(12f);
chart.setDescription(desc);
chart.getLegend().setEnabled(false);
chart.invalidate();
chartLayout.setVisibility(View.VISIBLE);
}
示例12: initPlot
import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
/**
* Create the plot.
*/
private void initPlot() {
// enable touch gestures
chart.setTouchEnabled(true);
// enable scaling and dragging
chart.setDragEnabled(true);
chart.setScaleEnabled(true);
chart.setDrawGridBackground(false);
// if disabled, scaling can be done on x- and y-axis separately
chart.setPinchZoom(true);
// get the legend (only possible after setting data)
Legend l = chart.getLegend();
// modify the legend ...
l.setForm(Legend.LegendForm.LINE);
l.setTextColor(Color.GRAY);
l.setWordWrapEnabled(true);
Description description = chart.getDescription();
description.setEnabled(false);
XAxis xl = chart.getXAxis();
xl.setTextColor(Color.GRAY);
xl.setDrawGridLines(false);
xl.setAvoidFirstLastClipping(true);
xl.setEnabled(true);
YAxis leftAxis = chart.getAxisLeft();
leftAxis.setTextColor(Color.GRAY);
leftAxis.setDrawGridLines(true);
YAxis rightAxis = chart.getAxisRight();
rightAxis.setEnabled(false);
}
示例13: setUI
import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
public void setUI() {
final Description des = new Description();
des.setText(".");
lineChart.setDescription(des);
lineChart.setDrawGridBackground(false);
lineChart.setExtraBottomOffset(-50);
XAxis x = lineChart.getXAxis();
x.setPosition(XAxis.XAxisPosition.TOP);
x.setDrawGridLines(false);
x.setDrawAxisLine(false);
x.setDrawLabels(true);
x.setYOffset(25);
x.setLabelRotationAngle(270);
x.setTextSize(12);
x.setTextColor(Color.WHITE);
x.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
// Date dt = new Date((long) value);
// Log.d(Const.TAG2, "sVF Next is "+dt.toString());
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat(" hh:mm aaa");
// String newValue = simpleDateFormat.format(dt);
// return Const.NO_BREAK + newValue;
if(uHi==(int)value){
return "";
}else {
uHi= (int) value;
}
Date d= new Date(dt[(int) value]);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(" hh:mm aaa");
String newValue = simpleDateFormat.format(d);
return Const.NO_BREAK + newValue;
}
});
YAxis yLeft = lineChart.getAxis(YAxis.AxisDependency.LEFT);
yLeft.setDrawGridLines(false);
yLeft.setDrawAxisLine(false);
yLeft.setDrawLabels(false);
YAxis yRight = lineChart.getAxis(YAxis.AxisDependency.RIGHT);
yRight.setDrawGridLines(false);
yRight.setDrawAxisLine(false);
yRight.setDrawLabels(false);
lineChart.setDoubleTapToZoomEnabled(false);
setData();
}
示例14: onCreate
import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz_mode_stats_page);
Intent intent = getIntent();
stats = intent.getParcelableExtra("STATS");
category = intent.getStringExtra("CATEGORY");
categoryLabel = (TextView) findViewById(R.id.categoryLabel);
if (category.equals("Random")) {
categoryLabel.setText("Category: All");
} else {
categoryLabel.setText("Category: " + category);
}
menuButton = (Button) findViewById(R.id.menuButton);
noResultsLabel = (TextView) findViewById(R.id.noResultsLabel);
pieChart = (PieChart) findViewById(R.id.pieChart);
if (stats.getNumberCorrect() == 0 && stats.getNumberIncorrect() == 0 && stats.getNumberNotAnswered() == 0) {
System.out.println("Test");
noResultsLabel.setVisibility(View.VISIBLE);
} else {
Description desc = new Description();
desc.setText("");
pieChart.setDescription(desc);
pieChart.setHoleColor(Color.TRANSPARENT);
pieChart.setTransparentCircleRadius(0);
pieChart.getLegend().setEnabled(false);
List<PieEntry> entries = new ArrayList<PieEntry>();
List<Integer> colors = new ArrayList<Integer>();
if (stats.getNumberCorrect() > 0) {
entries.add(new PieEntry(stats.getNumberCorrect(), "Correct"));
colors.add(getResources().getColor(R.color.quizStatsCorrect));
}
if (stats.getNumberIncorrect() > 0) {
entries.add(new PieEntry(stats.getNumberIncorrect(), "Incorrect"));
colors.add(getResources().getColor(R.color.quizStatsIncorrect));
}
if (stats.getNumberNotAnswered() > 0) {
entries.add(new PieEntry(stats.getNumberNotAnswered(), "Not Answered"));
colors.add(getResources().getColor(R.color.quizStatsNotAnswered));
}
PieDataSet dataSet = new PieDataSet(entries, "");
dataSet.setColors(colors);
PieData pieData = new PieData(dataSet);
pieData.setValueTextColor(Color.WHITE);
pieData.setValueTextSize(16.0f);
pieData.setValueFormatter(new QuizStatsFormatter());
pieChart.setData(pieData);
pieChart.setVisibility(View.VISIBLE);
pieChart.invalidate();
}
}
示例15: prepareGraphLayout
import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
private void prepareGraphLayout() {
loadingLayout.setVisibility(View.GONE);
errorLayout.setVisibility(View.GONE);
swipeRefreshLayout.setVisibility(View.VISIBLE);
swipeRefreshLayout.setRefreshing(false);
if (results.getCounted() > 0f) {
pieChart.setVisibility(View.VISIBLE);
emptyChart.setVisibility(View.GONE);
ArrayList<PieEntry> entries = new ArrayList<>();
entries.add(new PieEntry(results.getInvalid(), StringsManager.getString("graph_invalid")));
entries.add(new PieEntry(results.getBlank(), StringsManager.getString("graph_blank")));
entries.add(new PieEntry(results.getNo(), StringsManager.getString("graph_no")));
entries.add(new PieEntry(results.getYes(), StringsManager.getString("graph_yes")));
PieDataSet set = new PieDataSet(entries, "");
set.setColors(Color.parseColor("#43474e"), Color.parseColor("#7f7f7f"), Color.parseColor("#fc543d"), Color.parseColor("#65c258"));
// set.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
// set.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
// set.setSliceSpace(2f);
set.setValueTextSize(16f);
set.setValueTextColor(Color.WHITE);
PieData data = new PieData(set);
data.setValueFormatter(new IValueFormatter() {
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
// write your logic here
return new DecimalFormat("##0.0").format(value) + "%"; // e.g. append a dollar-sign
}
});
pieChart.setData(data);
pieChart.getLegend().setEnabled(false);
pieChart.setUsePercentValues(true);
pieChart.setEntryLabelColor(Color.WHITE);
pieChart.setEntryLabelTextSize(16f);
pieChart.setRotationEnabled(false);
Description description = new Description();
description.setText("");
pieChart.setDescription(description);
pieChart.invalidate();
} else {
pieChart.setVisibility(View.GONE);
emptyChart.setVisibility(View.VISIBLE);
}
counted.setText(new DecimalFormat("##0.0").format(results.getCounted()) + "%");
countedBar.setProgress((int) (results.getCounted() * 10));
participation.setText(new DecimalFormat("##0.0").format(results.getParticipation()) + "%");
participationBar.setProgress((int) (results.getParticipation() * 10));
countedBar.getProgressDrawable().setColorFilter(
ResourcesCompat.getColor(getResources(), R.color.grey_dark, getContext().getTheme()), android.graphics.PorterDuff.Mode.SRC_IN);
participationBar.getProgressDrawable().setColorFilter(
ResourcesCompat.getColor(getResources(), R.color.red, getContext().getTheme()), android.graphics.PorterDuff.Mode.SRC_IN);
if (TextUtils.isEmpty(results.getMessage())) {
message.setVisibility(View.GONE);
} else {
message.setVisibility(View.VISIBLE);
message.setText(results.getMessage());
}
}