本文整理汇总了Java中com.github.mikephil.charting.data.LineDataSet.setDrawFilled方法的典型用法代码示例。如果您正苦于以下问题:Java LineDataSet.setDrawFilled方法的具体用法?Java LineDataSet.setDrawFilled怎么用?Java LineDataSet.setDrawFilled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.LineDataSet
的用法示例。
在下文中一共展示了LineDataSet.setDrawFilled方法的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: 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;
}
示例3: 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);
}
示例4: 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);
}
示例5: 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
}
示例6: 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;
}
示例7: setData
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private void setData(int count, float range) {
ArrayList<String> xVals = new ArrayList<String>();
for (int i = 0; i < count; i++) {
xVals.add((i) + "");
}
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(val, i));
}
// 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.setDrawCubic(false);
set1.setDrawFilled(false);
// create a data object with the datasets
LineData data = new LineData(xVals, set1);
// set data
mChart.setData(data);
// get the legend (only possible after setting data)
Legend l = mChart.getLegend();
l.setEnabled(false);
}
示例8: marshallHumidity
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void marshallHumidity(List<HumidityHolder> humidity) {
final int count = humidity.size();
List<String> xVals = new ArrayList<>();
List<Entry> humidityList = new ArrayList<>();
for(int i = 0; i < count; ++i) {
HumidityHolder humidityHolder = humidity.get(i);
xVals.add(humidityHolder.getDate());
humidityList.add(new Entry(humidityHolder.getHumidity(), i));
}
LineDataSet lineDataSet = new LineDataSet(humidityList, "湿度");
lineDataSet.setDrawCubic(true);
lineDataSet.setDrawFilled(true);
lineDataSet.setDrawCircles(false);
lineDataSet.setCircleColor(Color.WHITE);
lineDataSet.setHighLightColor(m_context.getResources().getColor(R.color.max));
lineDataSet.setColor(Color.WHITE);
lineDataSet.setFillColor(m_context.getResources().getColor(R.color.fill));
lineDataSet.setFillAlpha(100);
LineData data = new LineData(xVals, lineDataSet);
data.setValueTextSize(5f);
m_iWeatherForecastView.showHumidity(data);
}
示例9: 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;
}
示例10: 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);
}
示例11: 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();
}
示例12: generateLineDataSet
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private LineDataSet generateLineDataSet(List<Entry> yVals, int color) {
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(yVals, "");
List<Integer> colors = new ArrayList<>();
if (color == getResources().getColor(R.color.glucosio_pink)) {
for (Entry yVal : yVals) {
if (yVal.getVal() == (0)) {
colors.add(Color.TRANSPARENT);
} else {
colors.add(color);
}
}
set1.setCircleColors(colors);
} else {
set1.setCircleColor(color);
}
set1.setColor(color);
set1.setLineWidth(2f);
set1.setCircleSize(4f);
set1.setDrawCircleHole(true);
set1.disableDashedLine();
set1.setFillAlpha(255);
set1.setDrawFilled(true);
set1.setValueTextSize(0);
set1.setValueTextColor(Color.parseColor("#FFFFFF"));
set1.setFillDrawable(getResources().getDrawable(R.drawable.graph_gradient));
set1.setHighLightColor(getResources().getColor(R.color.glucosio_gray_light));
set1.setCubicIntensity(0.2f);
// TODO: Change this to true when a fix is available
// https://github.com/PhilJay/MPAndroidChart/issues/1541
set1.setDrawCubic(false);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
set1.setDrawFilled(false);
set1.setLineWidth(2f);
set1.setCircleSize(4f);
set1.setDrawCircleHole(true);
}
return set1;
}
示例13: 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();
}
示例14: setChart2Value
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
/**
* this methode is basicaly the same as the setchart1value1, but it will process 2 value. Used for pressure
* @param measures the list of the measure we have to display
* @param labelValue1 the label of the first data set
* @param labelValue2 the label of the second data set
*/
private void setChart2Value(List<Measure> measures, String labelValue1, String labelValue2,String dateformat, CustomRules rule) {
if (measures.size()==0)
return;
//set the entry for the
List<Entry> entries_measure1=new ArrayList<>();
List<Entry>entries_measure2=new ArrayList<>();
for (int k=0;k<measures.size();k++)
{ //add the entry
entries_measure1.add(new Entry(k,measures.get(k).getValue1().floatValue()));
entries_measure2.add(new Entry(k,measures.get(k).getValue2().floatValue()));
}
//add label instead of number in the axis
chart.notifyDataSetChanged();
//sort otherwise we will trigger an error
Collections.sort(entries_measure1, new EntryXComparator());
Collections.sort(entries_measure2,new EntryXComparator());
//add the entry to a data set (data that belong together), it's a line
//************FIRST DATA SET *************************
LineDataSet dataSet1=new LineDataSet(entries_measure1,labelValue1);
dataSet1.setColor(Color.BLUE);
dataSet1.setValueTextColor(Color.BLACK);
//**************SECOND DATA SET*********************
LineDataSet dataSet2=new LineDataSet(entries_measure2,labelValue2);
dataSet2.setColor(Color.GREEN);
dataSet2.setValueTextColor(Color.BLACK);
//ad the data set to the line data. Linedata contains all data set
LineData lineData=new LineData(dataSet1,dataSet2);
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);
dataSet1.setMode(LineDataSet.Mode.CUBIC_BEZIER);
//draw the limite of the allowed value
setLimites(rule);
dataSet1.setDrawFilled(true);
dataSet1.setFillColor(Color.BLUE);
dataSet2.setDrawFilled(true);
dataSet2.setFillColor(Color.GREEN);
chart.notifyDataSetChanged();
chart.invalidate();
}
示例15: setData
import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private void setData(int count, float range) {
ArrayList<String> xVals = new ArrayList<String>();
for (int i = 0; i < count; i++) {
xVals.add((i) + "");
}
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(val, i));
}
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
// set1.setFillAlpha(110);
// set1.setFillColor(Color.RED);
// set the line to be drawn like this "- - - - - -"
set1.enableDashedLine(10f, 5f, 0f);
set1.enableDashedHighlightLine(10f, 5f, 0f);
set1.setColor(Color.BLACK);
set1.setCircleColor(Color.BLACK);
set1.setLineWidth(1f);
set1.setCircleRadius(3f);
set1.setDrawCircleHole(false);
set1.setValueTextSize(9f);
Drawable drawable = ContextCompat.getDrawable(this, R.drawable.fade_red);
set1.setFillDrawable(drawable);
set1.setDrawFilled(true);
ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
dataSets.add(set1); // add the datasets
// create a data object with the datasets
LineData data = new LineData(xVals, dataSets);
// set data
mChart.setData(data);
}