本文整理汇总了Java中com.github.mikephil.charting.data.LineData类的典型用法代码示例。如果您正苦于以下问题:Java LineData类的具体用法?Java LineData怎么用?Java LineData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LineData类属于com.github.mikephil.charting.data包,在下文中一共展示了LineData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.github.mikephil.charting.data.LineData; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_linechart_noseekbar);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawGridBackground(false);
mChart.getDescription().setEnabled(false);
// add an empty data object
mChart.setData(new LineData());
// mChart.getXAxis().setDrawLabels(false);
// mChart.getXAxis().setDrawGridLines(false);
mChart.invalidate();
}
示例2: prepareInitData
import com.github.mikephil.charting.data.LineData; //导入依赖的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;
}
示例3: generateLineData
import com.github.mikephil.charting.data.LineData; //导入依赖的package包/类
protected LineData generateLineData() {
ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>();
LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "sine.txt"), "Sine function");
LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "cosine.txt"), "Cosine function");
ds1.setLineWidth(2f);
ds2.setLineWidth(2f);
ds1.setDrawCircles(false);
ds2.setDrawCircles(false);
ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]);
// load DataSets from textfiles in assets folders
sets.add(ds1);
sets.add(ds2);
LineData d = new LineData(sets);
d.setValueTypeface(tf);
return d;
}
示例4: generateLineData
import com.github.mikephil.charting.data.LineData; //导入依赖的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;
}
示例5: removeLastEntry
import com.github.mikephil.charting.data.LineData; //导入依赖的package包/类
private void removeLastEntry() {
LineData data = mChart.getData();
if (data != null) {
ILineDataSet set = data.getDataSetByIndex(0);
if (set != null) {
Entry e = set.getEntryForXValue(set.getEntryCount() - 1, Float.NaN);
data.removeEntry(e, 0);
// or remove by index
// mData.removeEntryByXValue(xIndex, dataSetIndex);
data.notifyDataChanged();
mChart.notifyDataSetChanged();
mChart.invalidate();
}
}
}
示例6: onCreate
import com.github.mikephil.charting.data.LineData; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_colored_lines);
mCharts[0] = (LineChart) findViewById(R.id.chart1);
mCharts[1] = (LineChart) findViewById(R.id.chart2);
mCharts[2] = (LineChart) findViewById(R.id.chart3);
mCharts[3] = (LineChart) findViewById(R.id.chart4);
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Bold.ttf");
for (int i = 0; i < mCharts.length; i++) {
LineData data = getData(36, 100);
data.setValueTypeface(mTf);
// add some transparency to the color with "& 0x90FFFFFF"
setupChart(mCharts[i], data, mColors[i % mColors.length]);
}
}
示例7: setData
import com.github.mikephil.charting.data.LineData; //导入依赖的package包/类
private void setData() {
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
RealmLineDataSet<RealmDemoData> set = new RealmLineDataSet<RealmDemoData>(result, "xValue", "yValue");
set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
set.setLabel("Realm LineDataSet");
set.setDrawCircleHole(false);
set.setColor(ColorTemplate.rgb("#FF5722"));
set.setCircleColor(ColorTemplate.rgb("#FF5722"));
set.setLineWidth(1.8f);
set.setCircleRadius(3.6f);
ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
dataSets.add(set); // add the dataset
// create a data object with the dataset list
LineData data = new LineData(dataSets);
styleData(data);
// set data
mChart.setData(data);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
示例8: setData
import com.github.mikephil.charting.data.LineData; //导入依赖的package包/类
private void setData(int count, float range) {
ArrayList<Entry> entries = new ArrayList<Entry>();
for (int i = 0; i < count; i++) {
float xVal = (float) (Math.random() * range);
float yVal = (float) (Math.random() * range);
entries.add(new Entry(xVal, yVal));
}
// sort by x-value
Collections.sort(entries, new EntryXComparator());
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(entries, "DataSet 1");
set1.setLineWidth(1.5f);
set1.setCircleRadius(4f);
// create a data object with the datasets
LineData data = new LineData(set1);
// set data
mChart.setData(data);
}
示例9: bindActivityChart
import com.github.mikephil.charting.data.LineData; //导入依赖的package包/类
private void bindActivityChart() {
LineData lineData = generateActivityLineData();
lineChart.setData(lineData);
int maxYData = (int) (Math.ceil(lineData.getYMax()) + 7200);
lineChart.getAxisLeft().setAxisMaximum(maxYData);
long referenceTime = new DateTime(stats.endDate).minusDays(6).getMillis();
lineChart.getXAxis()
.setValueFormatter(new FormatUtils().getBarXAxisValueFormatterInstance(referenceTime));
CustomMarkerView customMarkerView = new CustomMarkerView(context, R.layout.marker_view, referenceTime);
lineChart.setMarker(customMarkerView);
customMarkerView.setChartView(lineChart);
lineChart.animateX(1500, Easing.EasingOption.Linear);
}
示例10: generateA1cData
import com.github.mikephil.charting.data.LineData; //导入依赖的package包/类
private LineData generateA1cData() {
ArrayList<String> xVals = new ArrayList<>();
ArrayList<Entry> yVals = new ArrayList<>();
for (int i = 0; i < presenter.getA1cReadings().size(); i++) {
float val = Float.parseFloat(presenter.getA1cReadings().get(i).toString());
yVals.add(new Entry(val, i));
}
xVals.clear();
for (int i = 0; i < presenter.getA1cReadingsDateTime().size(); i++) {
String date = presenter.convertDate(presenter.getA1cReadingsDateTime().get(i));
xVals.add(date + "");
}
// create a data object with the datasets
return new LineData(xVals,
generateLineDataSet(yVals, getResources().getColor(R.color.glucosio_fab_HB1AC)));
}
示例11: generateKetonesData
import com.github.mikephil.charting.data.LineData; //导入依赖的package包/类
private LineData generateKetonesData() {
List<String> xVals = new ArrayList<>();
List<Entry> yVals = new ArrayList<>();
for (int i = 0; i < presenter.getKetonesReadings().size(); i++) {
float val = Float.parseFloat(presenter.getKetonesReadings().get(i).toString());
yVals.add(new Entry(val, i));
}
xVals.clear();
for (int i = 0; i < presenter.getKetonesReadingsDateTime().size(); i++) {
String date = presenter.convertDate(presenter.getKetonesReadingsDateTime().get(i));
xVals.add(date + "");
}
// create a data object with the datasets
return new LineData(xVals,
generateLineDataSet(yVals, getResources().getColor(R.color.glucosio_fab_ketones)));
}
示例12: generateWeightData
import com.github.mikephil.charting.data.LineData; //导入依赖的package包/类
private LineData generateWeightData() {
List<String> xVals = new ArrayList<>();
List<Entry> yVals = new ArrayList<>();
for (int i = 0; i < presenter.getWeightReadings().size(); i++) {
float val = Float.parseFloat(presenter.getWeightReadings().get(i).toString());
yVals.add(new Entry(val, i));
}
xVals.clear();
for (int i = 0; i < presenter.getWeightReadingsDateTime().size(); i++) {
String date = presenter.convertDate(presenter.getWeightReadingsDateTime().get(i));
xVals.add(date + "");
}
// create a data object with the datasets
return new LineData(xVals,
generateLineDataSet(yVals, getResources().getColor(R.color.glucosio_fab_weight)));
}
示例13: generateCholesterolData
import com.github.mikephil.charting.data.LineData; //导入依赖的package包/类
private LineData generateCholesterolData() {
List<String> xVals = new ArrayList<>();
List<Entry> yVals = new ArrayList<>();
for (int i = 0; i < presenter.getCholesterolReadings().size(); i++) {
float val = Float.parseFloat(presenter.getCholesterolReadings().get(i).toString());
yVals.add(new Entry(val, i));
}
xVals.clear();
for (int i = 0; i < presenter.getCholesterolReadingsDateTime().size(); i++) {
String date = presenter.convertDate(presenter.getCholesterolReadingsDateTime().get(i));
xVals.add(date + "");
}
// create a data object with the datasets
return new LineData(xVals,
generateLineDataSet(yVals, getResources().getColor(R.color.glucosio_fab_cholesterol)));
}
示例14: generateDataLine
import com.github.mikephil.charting.data.LineData; //导入依赖的package包/类
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private LineData generateDataLine(float[] datas, String type) {
ArrayList<Entry> entryList = new ArrayList<Entry>();
for (int i = 0; i < datas.length; i++) {
entryList.add(new Entry(i, datas[i]));
}
LineDataSet d1 = new LineDataSet(entryList, "DataSet :" + type);
d1.setLineWidth(2.5f);
Random r = new Random();
d1.setHighLightColor(Color.rgb(r.nextInt(256), r.nextInt(256), r.nextInt(256)));
d1.setDrawValues(false);
ArrayList<ILineDataSet> sets = new ArrayList<>();
sets.add(d1);
return new LineData(sets);
}
示例15: buildLineData
import com.github.mikephil.charting.data.LineData; //导入依赖的package包/类
private LineData buildLineData(List<Entry> seniors, List<Entry> engineer,
List<Entry> juniors, String[] jobTitles ){
List<ILineDataSet> sets = new ArrayList<>();
if (!seniors.isEmpty()){
LineDataSet dSenior = buildLineDataSet(seniors, jobTitles[0]);
sets.add(dSenior);
}
if (!engineer.isEmpty()){
LineDataSet dEngineer = buildLineDataSet(engineer, jobTitles[1]);
dEngineer.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
dEngineer.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]);
sets.add(dEngineer);
}
if (!juniors.isEmpty()) {
LineDataSet dJunior = buildLineDataSet(juniors, jobTitles[2]);
dJunior.setColor(ColorTemplate.VORDIPLOM_COLORS[2]);
dJunior.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[2]);
sets.add(dJunior);//add data
}
return new LineData(sets);
}