本文整理汇总了Java中com.github.mikephil.charting.data.LineDataSet.setValueFormatter方法的典型用法代码示例。如果您正苦于以下问题:Java LineDataSet.setValueFormatter方法的具体用法?Java LineDataSet.setValueFormatter怎么用?Java LineDataSet.setValueFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.LineDataSet
的用法示例。
在下文中一共展示了LineDataSet.setValueFormatter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMainDataSets
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
/**
* Adds the main data set for all times and the data set for the progression of record best
* times among all times. The progression of best times are marked in a different color to the
* main line of all time using circles lined with a dashed line. This will appear to connect
* the lowest troughs along the main line of all times.
*
* @param chartData The chart data to which to add the new data sets.
* @param allLabel The label of the all-times line.
* @param allColor The color of the all-times line.
* @param bestLabel The label of the best-times line.
* @param bestColor The color of the best-times line.
*/
private void addMainDataSets(LineData chartData, String allLabel, int allColor,
String bestLabel, int bestColor) {
// Main data set for all solve times.
chartData.addDataSet(createDataSet(allLabel, allColor));
// Data set to show the progression of best times along the main line of all times.
final LineDataSet bestDataSet = createDataSet(bestLabel, bestColor);
bestDataSet.enableDashedLine(3f, 6f, 0f);
bestDataSet.setDrawCircles(true);
bestDataSet.setCircleRadius(BEST_TIME_CIRCLE_RADIUS_DP);
bestDataSet.setCircleColor(bestColor);
bestDataSet.setDrawValues(false);
bestDataSet.setValueTextColor(bestColor);
bestDataSet.setValueTextSize(BEST_TIME_VALUES_TEXT_SIZE_DP);
bestDataSet.setValueFormatter(new TimeChartValueFormatter());
chartData.addDataSet(bestDataSet);
}
示例2: getLineData
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private LineData getLineData(List<String> xVals, List<Entry> lineEntries) {
final LineDataSet dataSet = new LineDataSet(lineEntries, getContext().getString(R.string.moving_average));
final int color = ContextCompat.getColor(getContext(), R.color.brown);
dataSet.setColor(color);
dataSet.setLineWidth(2.5f);
dataSet.setCircleColor(color);
dataSet.setFillColor(color);
dataSet.setDrawValues(true);
dataSet.setValueTextSize(12);
dataSet.setValueTextColor(color);
// Format the value labels to two decimal places
dataSet.setValueFormatter(new LineChartValueFormatter());
return new LineData(xVals, dataSet);
}
示例3: setData
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private void setData() {
List<Entry> entries = data.getList();
for(Entry e: entries){
Date d= new Date((long) e.getX());
Log.d(Const.TAG2, "Next Entry is "+d.toString()+" , "+e.getY());
}
LineDataSet dataSet = new LineDataSet(entries, "Hourly Weather report");
dataSet.setColor(Color.rgb(184, 235, 161));
dataSet.setDrawCircleHole(false);
dataSet.setCircleColor(Color.CYAN);
dataSet.setValueTextColor(Color.WHITE);
dataSet.setValueTextSize(15);
dataSet.setDrawFilled(true);
dataSet.setFillColor(Color.LTGRAY);
dataSet.setDrawValues(true);
dataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
dataSet.setValueFormatter(new IValueFormatter() {
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
int newValue = (int) value;
return newValue + Const.DEGREE;
}
});
LineData lineData = new LineData(dataSet);
lineChart.setData(lineData);
lineChart.invalidate();//refresh
}
示例4: updateGraph
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
public void updateGraph(){
List<Entry> entries = new ArrayList<>();
Last7Days newDays = AxisFormatter.reverseLast7Days(last7Days);
int i = 0;
for(long dataEntry : get7Days(newDays)){
entries.add(new Entry((float)i,(float)dataEntry));
i++;
}
LineDataSet dataSet = new LineDataSet(entries,context.getString(R.string.main_scores));
dataSet.setColor(ContextCompat.getColor(context,R.color.greenDark));
dataSet.setValueTextSize(14f);
dataSet.setValueFormatter(new IValueFormatter() {
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
return String.valueOf((int) value);
}
});
dataSet.setCircleColor(ContextCompat.getColor(context,R.color.greenPrimary));
dataSet.setLineWidth(3f);
dataSet.setCircleRadius(10f);
dataSet.setDrawValues(false);
dataSet.setHighlightEnabled(true);
LineData lineData = new LineData(dataSet);
graph.setData(lineData);
Description description = new Description();
description.setEnabled(false);
description.setText("");
graph.setDescription(description);
graph.setNoDataText(context.getString(R.string.main_connecting));
graph.setNoDataTextColor(ContextCompat.getColor(context,R.color.greenDark));
graph.setDrawGridBackground(false);
graph.setDrawBorders(false);
YAxis leftAxis = graph.getAxisLeft();
leftAxis.setEnabled(false);
leftAxis.setAxisMinimum(0);
YAxis rightAxis = graph.getAxisRight();
rightAxis.setEnabled(false);
XAxis xAxis = graph.getXAxis();
Calendar c = Calendar.getInstance();
c.setTimeInMillis(System.currentTimeMillis());
ArrayList<Date> dateArrayList = new ArrayList<>();
for(int count = 0;count<7;count++){
Date date = c.getTime();
dateArrayList.add(date);
c.setTimeInMillis(c.getTimeInMillis() - ((long) 1000 * 60 * 60 * 24 ));
}
Collections.reverse(dateArrayList);
xAxis.setValueFormatter(new AxisFormatter(context,dateArrayList,dateFormatPattern));
xAxis.setTextSize(10f);
graph.setTouchEnabled(false);
graph.setDragEnabled(false);
graph.setScaleEnabled(false);
graph.setScaleXEnabled(false);
graph.setScaleYEnabled(false);
graph.setPinchZoom(false);
graph.setDoubleTapToZoomEnabled(false);
Legend legend = graph.getLegend();
legend.setEnabled(false);
graph.invalidate();
}