本文整理汇总了Java中com.github.mikephil.charting.data.LineDataSet类的典型用法代码示例。如果您正苦于以下问题:Java LineDataSet类的具体用法?Java LineDataSet怎么用?Java LineDataSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LineDataSet类属于com.github.mikephil.charting.data包,在下文中一共展示了LineDataSet类的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包/类
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;
}
示例3: 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;
}
示例4: createSet
import com.github.mikephil.charting.data.LineDataSet; //导入依赖的package包/类
private LineDataSet createSet() {
LineDataSet set = new LineDataSet(null, "Dynamic Data");
set.setAxisDependency(AxisDependency.LEFT);
set.setColor(ColorTemplate.getHoloBlue());
set.setCircleColor(Color.WHITE);
set.setLineWidth(2f);
set.setCircleRadius(4f);
set.setFillAlpha(65);
set.setFillColor(ColorTemplate.getHoloBlue());
set.setHighLightColor(Color.rgb(244, 117, 117));
set.setValueTextColor(Color.WHITE);
set.setValueTextSize(9f);
set.setDrawValues(false);
return set;
}
示例5: setData
import com.github.mikephil.charting.data.LineDataSet; //导入依赖的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);
}
示例6: setData
import com.github.mikephil.charting.data.LineDataSet; //导入依赖的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);
}
示例7: generateDataLine
import com.github.mikephil.charting.data.LineDataSet; //导入依赖的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);
}
示例8: buildLineData
import com.github.mikephil.charting.data.LineDataSet; //导入依赖的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);
}
示例9: getData
import com.github.mikephil.charting.data.LineDataSet; //导入依赖的package包/类
private LineData getData(ArrayList<Entry> yVals) {
LineDataSet set1 = new LineDataSet(yVals, "");
set1.setLineWidth(1.45f);
set1.setColor(Color.argb(240, 255, 255, 255));
set1.setCircleColor(Color.WHITE);
set1.setHighLightColor(Color.WHITE);
set1.setFillColor(getResources().getColor(R.color.chartFilled));
set1.setDrawCircles(false);
set1.setDrawValues(false);
set1.setDrawFilled(true);
set1.setFillFormatter(new IFillFormatter() {
@Override
public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
return priceChart.getAxisLeft().getAxisMinimum();
}
});
LineData data = new LineData(set1);
return data;
}
示例10: populateDiagram
import com.github.mikephil.charting.data.LineDataSet; //导入依赖的package包/类
@BindingAdapter({"bind:items"})
public static void populateDiagram(LineChart view, List<SingleValue> items) {
if (null == items || items.size() == 0) {
return;
}
List<Entry> entries = new ArrayList<>();
for (int i = 0; i < items.size(); i++) {
final SingleValue item = items.get(i);
final Entry entry = new Entry(i, (float) item.getValue(), item);
entries.add(entry);
}
LineDataSet dataSet = new LineDataSet(entries, view.getContext().getString(R.string.currency_value));
LineData lineData = new LineData(dataSet);
formatXAxisLabels(view, items);
view.setData(lineData);
view.invalidate();
}
示例11: 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;
}
示例12: 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);
}
示例13: addAoNDataSets
import com.github.mikephil.charting.data.LineDataSet; //导入依赖的package包/类
/**
* Adds the data set for the average-of-N (AoN) times and the corresponding data set for the
* single best average time for that value of "N". The best AoN times are not shown as a
* progression; only one time is shown and it superimposed on its main AoN line, rendered in
* the same color as a circle and with the value drawn on the chart.
*
* @param chartData The chart data to which to add the new data sets.
* @param label The label of the AoN line and best AoN time marker.
* @param color The color of the AoN line and best AoN time marker.
*/
private void addAoNDataSets(LineData chartData, String label, int color) {
// Main AoN data set for all AoN times for one value of "N".
chartData.addDataSet(createDataSet(label, color));
// Data set for the single best AoN time for this "N".
final LineDataSet bestAoNDataSet = createDataSet(label, color);
bestAoNDataSet.setDrawCircles(true);
bestAoNDataSet.setCircleRadius(BEST_TIME_CIRCLE_RADIUS_DP);
bestAoNDataSet.setCircleColor(color);
// Drawing the value of the best AoN time for each "N" seems like it would be a good idea,
// but the values are really hard because they appear over other chart lines and sometimes
// over the values drawn for the best time progression. Disabling them is no great loss,
// as the statistics table shows the same values, anyway. Just showing a circle to mark
// the best AoN time looks well enough on its own.
bestAoNDataSet.setDrawValues(false);
// bestAoNDataSet.setValueTextColor(color);
// bestAoNDataSet.setValueTextSize(BEST_TIME_VALUES_TEXT_SIZE_DP);
// bestAoNDataSet.setValueFormatter(new TimeChartValueFormatter());
chartData.addDataSet(bestAoNDataSet);
}
示例14: createDataSet
import com.github.mikephil.charting.data.LineDataSet; //导入依赖的package包/类
/**
* Creates a data set with the given label and color. Highlights and drawing of values and
* circles are disabled, as that is common for many cases.
*
* @param label The label to assign to the new data set.
* @param color The line color to set for the new data set.
*/
private LineDataSet createDataSet(String label, int color) {
// A legend is enabled on the chart view in the graph fragment. The legend is created
// automatically, but requires a unique labels and colors on each data set.
final LineDataSet dataSet = new LineDataSet(null, label);
// A dashed line can make peaks inaccurate. It also makes the graph look too "busy". It
// is OK for some uses, such as progressions of best times, but that is left to the caller
// to change once this new data set is returned.
//
// If graphing only times for a session, there will be fewer, and a thicker line will look
// well. However, if all times are graphed, a thinner line will probably look better, as
// the finer details will be more visible.
dataSet.setLineWidth(getLineWidth());
dataSet.setColor(color);
dataSet.setHighlightEnabled(false);
dataSet.setDrawCircles(false);
dataSet.setDrawValues(false);
return dataSet;
}
示例15: createSet
import com.github.mikephil.charting.data.LineDataSet; //导入依赖的package包/类
private LineDataSet createSet() {
LineDataSet set = new LineDataSet(null, getString(R.string.app_name));
set.setAxisDependency(YAxis.AxisDependency.LEFT);
set.setColor(ColorTemplate.getHoloBlue());
set.setCircleColor(Color.WHITE);
set.setLineWidth(1f);
set.setCircleRadius(1.5f);
set.setFillAlpha(65);
set.setFillColor(ColorTemplate.getHoloBlue());
set.setHighLightColor(Color.rgb(244, 117, 117));
set.setValueTextColor(Color.WHITE);
set.setValueTextSize(9f);
set.setDrawValues(false);
return set;
}