本文整理汇总了Java中com.github.mikephil.charting.data.LineDataSet.setMode方法的典型用法代码示例。如果您正苦于以下问题:Java LineDataSet.setMode方法的具体用法?Java LineDataSet.setMode怎么用?Java LineDataSet.setMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.LineDataSet
的用法示例。
在下文中一共展示了LineDataSet.setMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareInitData
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private LineDataSet prepareInitData(@NonNull LineChart chart, @NonNull List<Entry> entries) {
final LineDataSet set = new LineDataSet(entries, "Accuracy");
set.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
set.setAxisDependency(YAxis.AxisDependency.LEFT);
set.setLineWidth(2F);
set.setDrawCircleHole(false);
set.setDrawCircles(false);
set.setHighlightEnabled(false);
set.setDrawFilled(true);
final LineData group = new LineData(set);
group.setDrawValues(false);
chart.setData(group);
return set;
}
示例2: generateLineData
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private LineData generateLineData() {
LineData d = new LineData();
ArrayList<Entry> entries = new ArrayList<Entry>();
for (int index = 0; index < itemcount; index++)
entries.add(new Entry(index + 0.5f, getRandom(15, 5)));
LineDataSet set = new LineDataSet(entries, "Line DataSet");
set.setColor(Color.rgb(240, 238, 70));
set.setLineWidth(2.5f);
set.setCircleColor(Color.rgb(240, 238, 70));
set.setCircleRadius(5f);
set.setFillColor(Color.rgb(240, 238, 70));
set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
set.setDrawValues(true);
set.setValueTextSize(10f);
set.setValueTextColor(Color.rgb(240, 238, 70));
set.setAxisDependency(YAxis.AxisDependency.LEFT);
d.addDataSet(set);
return d;
}
示例3: createSet
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private LineDataSet createSet(String label) {
LineDataSet set = new LineDataSet(null, label);
set.setAxisDependency(YAxis.AxisDependency.LEFT);
int color;
if (label.equals(pm1Label)) {
color = Color.BLUE;
} else if (label.equals(pm25Label)) {
color = Color.RED;
} else {
color = Color.BLACK;
}
set.setColor(color);
set.setLineWidth(2f);
set.setDrawValues(false);
set.setDrawCircles(false);
set.setMode(LineDataSet.Mode.LINEAR);
return set;
}
示例4: generateLineData
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
/**
* 曲线
*/
private LineData generateLineData() {
LineData lineData = new LineData();
ArrayList<Entry> entries = new ArrayList<>();
for (int index = 0; index < items.size(); index++) {
entries.add(new Entry(index + 1f, (float) items.get(index).sub_data.getData()));
}
LineDataSet lineDataSet = new LineDataSet(entries, "对比数据");
lineDataSet.setValues(entries);
lineDataSet.setDrawValues(false);//是否在线上显示值
lineDataSet.setColor(ContextCompat.getColor(mContext, R.color.co3));
lineDataSet.setLineWidth(2.5f);
lineDataSet.setCircleColor(ContextCompat.getColor(mContext, R.color.co3));
lineDataSet.setCircleRadius(5f);
lineDataSet.setDrawCircles(false);
lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);//设置线条类型
//set.setDrawHorizontalHighlightIndicator(false);//隐藏选中线
//set.setDrawVerticalHighlightIndicator(false);//隐藏选中线条
lineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
lineDataSet.setHighlightEnabled(false);
lineData.setHighlightEnabled(false);
lineData.addDataSet(lineDataSet);
return lineData;
}
示例5: styleChartLines
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
/**
* Style char lines (type, color, etc.).
*
* @param entries list of entries.
* @return line data chart.
*/
private LineData styleChartLines(List<Entry> entries) {
// Set styles
LineDataSet lineDataSet = new LineDataSet(entries, "Recording");
lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
lineDataSet.setCubicIntensity(0.2f);
lineDataSet.setDrawValues(false);
lineDataSet.setDrawCircles(false);
lineDataSet.setLineWidth(1.8f);
lineDataSet.setColor(ContextCompat.getColor(context, R.color.colorAccent));
if (((int) lineDataSet.getYMax()) != 0) {
lineDataSet.setDrawFilled(true);
lineDataSet.setFillAlpha(255);
// Fix bug with vectors in API < 21
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT){
Drawable drawable = ResourcesCompat.getDrawable(context.getResources(),
R.drawable.chart_fade, null);
lineDataSet.setFillDrawable(drawable);
} else{
lineDataSet.setFillColor(ContextCompat.getColor(context, R.color.colorPrimary));
}
}
return new LineData(lineDataSet);
}
示例6: generateLineData
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private LineData generateLineData() {
LineData d = new LineData();
ArrayList<Entry> entries = new ArrayList<Entry>();
for (int index = 0; index < 3; index++)
entries.add(new Entry(index + 0.5f, UtilsRG.getRandomNumberInRange(0, 1)));
LineDataSet set = new LineDataSet(entries, "Line DataSet");
set.setColor(R.color.colorPrimaryLight);
set.setLineWidth(2.5f);
set.setCircleColor(R.color.colorPrimaryLight);
set.setCircleRadius(5f);
set.setFillColor(R.color.colorPrimaryLight);
set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
set.setDrawValues(true);
set.setValueTextSize(10f);
set.setValueTextColor(R.color.colorPrimaryLight);
set.setAxisDependency(YAxis.AxisDependency.LEFT);
d.addDataSet(set);
return d;
}
示例7: setData
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private void setData(int count, float range) {
ArrayList<Entry> yVals = new ArrayList<Entry>();
for (int i = 0; i < count; i++) {
float mult = (range + 1);
float val = (float) (Math.random() * mult) + 3;// + (float)
// ((mult *
// 0.1) / 10);
yVals.add(new Entry(i * 0.001f, val));
}
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
set1.setColor(Color.BLACK);
set1.setLineWidth(0.5f);
set1.setDrawValues(false);
set1.setDrawCircles(false);
set1.setMode(LineDataSet.Mode.LINEAR);
set1.setDrawFilled(false);
// create a data object with the datasets
LineData data = new LineData(set1);
// set data
mChart.setData(data);
// get the legend (only possible after setting data)
Legend l = mChart.getLegend();
l.setEnabled(false);
}
示例8: formatLineDataSet
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private void formatLineDataSet(LineDataSet set, int color, int width) {
set.setDrawValues(false);
set.setDrawHighlightIndicators(false);
set.setMode(LineDataSet.Mode.LINEAR);
set.setColor(color);
set.setLineWidth(width);
set.setCircleColor(color);
set.setCircleRadius(width + 2);
}
示例9: 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
}
示例10: setUpChart
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private boolean setUpChart(@NonNull Model model) {
final double[] accuracies = model.getAccuracies();
if (accuracies == null
|| accuracies.length == 0
|| model.getStepEpoch() < 1) {
return false;
}
mAccuracyData.clear();
for (int i = 0, len = model.getStepEpoch(); i < len; ++i) {
mAccuracyData.add(new Entry(i + 1, (float) accuracies[i]));
}
final LineDataSet set = new LineDataSet(mAccuracyData, getString(R.string.text_chart_left_axis));
set.setMode(LineDataSet.Mode.LINEAR);
set.setAxisDependency(YAxis.AxisDependency.LEFT);
set.setColor(ContextCompat.getColor(this, R.color.chart_left_axis));
set.setCircleColor(ContextCompat.getColor(this, R.color.chart_left_axis));
set.setHighLightColor(ContextCompat.getColor(this, R.color.chart_highlight));
set.setCircleColorHole(Color.WHITE);
set.setDrawCircleHole(true);
set.setHighlightEnabled(true);
set.setLineWidth(2F);
set.setCircleRadius(3F);
set.setDrawFilled(false);
final LineData group = new LineData(set);
group.setDrawValues(false);
setXAxis(model.getEpochs());
mChart.setData(group);
mChart.invalidate();
startChartAnimate();
return true;
}
示例11: configureWeatherChart
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
/**
* Configure styles of weather charts.
*
* @param entries chart data.
* @param formatter value formatter.
* @param minVal min value to show.
* @param maxVal max value to show.
* @return chart formatted.
*/
private LineDataSet configureWeatherChart(
LineChart chart, int chartName, int colorLineTempChart, int colorFillTempChart,
List<Entry> entries, IAxisValueFormatter formatter, double minVal, double maxVal) {
LineDataSet lineDataSet = new LineDataSet(entries, getString(chartName));
lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
lineDataSet.setDrawValues(false);
lineDataSet.setValueTextSize(10f);
lineDataSet.setDrawCircles(false);
lineDataSet.setLineWidth(1.8f);
lineDataSet.setColor(ContextCompat.getColor(getContext(), colorLineTempChart));
lineDataSet.setLineWidth(2f);
lineDataSet.setDrawFilled(true);
lineDataSet.setFillColor(ContextCompat.getColor(getContext(), colorFillTempChart));
lineDataSet.setFillAlpha(255);
// General setup
chart.setDrawGridBackground(false);
chart.setDrawBorders(false);
chart.setViewPortOffsets(0, 0, 0, 0);
chart.getDescription().setEnabled(false);
chart.getLegend().setEnabled(false);
chart.setTouchEnabled(false);
// X axis setup
XAxis xAxis = chart.getXAxis();
xAxis.setEnabled(false);
xAxis.setAxisMinimum(0);
xAxis.setAxisMaximum(lastTimestamp);
// Y axis setup
YAxis leftAxis = chart.getAxisLeft();
leftAxis.setEnabled(false);
leftAxis.setAxisMaximum((float) (maxVal));
leftAxis.setAxisMinimum((float) (minVal));
YAxis rightAxis = chart.getAxisRight();
rightAxis.setAxisMaximum((float) (maxVal));
rightAxis.setAxisMinimum((float) (minVal));
rightAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
rightAxis.setValueFormatter(formatter);
return lineDataSet;
}
示例12: loadData
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private LineData loadData(ChartCard card) {
// add entries to dataset
LineDataSet lineDataSet = new LineDataSet(card.entries, null);
lineDataSet.setMode(LineDataSet.Mode.LINEAR);
lineDataSet.setDrawValues(false);
lineDataSet.setDrawCircleHole(false);
lineDataSet.setColor(card.color);
lineDataSet.setCircleColor(card.color);
lineDataSet.setLineWidth(1.8f);
lineDataSet.setDrawFilled(true);
lineDataSet.setFillColor(card.color);
return new LineData(lineDataSet);
}
示例13: setupGraphic
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private void setupGraphic(LineChart chart, List<Entry> entries, float axisMinimum, IAxisValueFormatter formatter) {
LineDataSet dataSet = new LineDataSet(entries, Constants.EMPTY_STRING);
dataSet.setDrawCircles(false);
dataSet.setDrawCircleHole(false);
dataSet.setLineWidth(ResourcesHelper.getDimensionPixelSize(this, R.dimen.half_dp));
dataSet.setFillColor(getResources().getColor(R.color.colorPrimary));
dataSet.setDrawFilled(true);
dataSet.setFillAlpha(Constants.Chart.ALPHA_FILL);
dataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
dataSet.setColor(getResources().getColor(R.color.colorPrimary));
dataSet.setDrawValues(false);
LineData lineData = new LineData(dataSet);
chart.getDescription().setEnabled(false);
chart.setTouchEnabled(false);
chart.getLegend().setEnabled(false);
chart.getAxisRight().setEnabled(false);
chart.getXAxis().setDrawLabels(false);
chart.getXAxis().setDrawGridLines(false);
chart.getAxisLeft().removeAllLimitLines();
chart.getAxisLeft().setTextColor(getResources().getColor(R.color.gray));
chart.getAxisLeft().setAxisMinimum(axisMinimum);
chart.getAxisLeft().setTextSize(Constants.Chart.LABEL_SIZE);
chart.getAxisLeft().setValueFormatter(formatter);
chart.animateX(Constants.Chart.ANIMATION_DURATION, Easing.EasingOption.EaseInSine);
chart.setData(lineData);
chart.invalidate();
}
示例14: makeLineData
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private LineDataSet makeLineData(List<GlucoseData> glucoseDataList) {
String title = "History";
if (glucoseDataList.get(0).isTrendData()) title = "Trend";
LineDataSet lineDataSet = new LineDataSet(new ArrayList<Entry>(), title);
for (GlucoseData gd : glucoseDataList) {
float x = convertDateToXAxisValue(gd.getDate());
float y = gd.glucose();
lineDataSet.addEntryOrdered(new Entry(x, y));
/*
Log.d(LOG_ID, String.format("%s: %s -> %s: %f -> %f",
title,
mFormatDateTime.format(new Date(gd.date)),
mFormatDateTime.format(new Date(convertXAxisValueToDate(x))),
x,
y)
);
*/
}
lineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
lineDataSet.setDrawCircles(true);
lineDataSet.setCircleRadius(2f);
lineDataSet.setDrawCircleHole(false);
lineDataSet.setDrawValues(false);
lineDataSet.setDrawHighlightIndicators(true);
int baseColor = PLOT_COLORS[mPlotColorIndex % NUM_PLOT_COLORS][0];
int softColor = Color.argb(150, Color.red(baseColor), Color.green(baseColor), Color.blue(baseColor));
int hardColor = PLOT_COLORS[mPlotColorIndex % NUM_PLOT_COLORS][1];
if (glucoseDataList.get(0).isTrendData()) {
lineDataSet.setColor(hardColor);
lineDataSet.setLineWidth(2f);
lineDataSet.setCircleColor(softColor);
lineDataSet.setMode(LineDataSet.Mode.LINEAR);
} else {
lineDataSet.setColor(softColor);
lineDataSet.setLineWidth(4f);
lineDataSet.setCircleColor(hardColor);
lineDataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
lineDataSet.setCubicIntensity(0.1f);
}
return lineDataSet;
}
示例15: setChart1Value
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
/**
* Used to display the value from the measure list into the chart
* @param measures The list of the measure we want to display
* @param labelName The label we want to display for each value under the graph
*/
private void setChart1Value(List<Measure> measures, String labelName,String dateFormat, CustomRules rule) {
chart=(LineChart) view.findViewById(R.id.chart_measure);
if (measures.size()==0)
return;
//data for the entry
List<Entry> dataEntries=new ArrayList<>();
//get the data based on measure
for (int k=0;k<measures.size();k++)
{ //add the entry
dataEntries.add(new Entry(k,measures.get(k).getValue1().floatValue()));
//enter the fix value related to the rule
}
//add label instead of number in the axis
chart.notifyDataSetChanged();
//sort otherwise we will trigger an error
Collections.sort(dataEntries, new EntryXComparator());
//add the entry to a data set (data that belong together), it's a line
LineDataSet dataSet=new LineDataSet(dataEntries,labelName);
dataSet.setColor(Color.BLUE);
dataSet.setValueTextColor(Color.BLACK);
//create a data set for each line
LineData lineData=new LineData(dataSet);
chart.setData(lineData);
//refresh view
IAxisValueFormatter formatter =new XaxValueFormater(measures,dateFormat);
//set the gape between value in x axis
XAxis xAxis = chart.getXAxis();
xAxis.setGranularity(1f); // minimum axis-step (interval) is 1
//set the label instead of numner
xAxis.setValueFormatter(formatter);
dataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
dataSet.setDrawFilled(true);
dataSet.setFillColor(Color.BLUE);
//draw the limite of the allowed value
setLimites(rule);
chart.getDescription().setEnabled(false);
chart.invalidate();
}