本文整理汇总了Java中com.github.mikephil.charting.charts.LineChart.invalidate方法的典型用法代码示例。如果您正苦于以下问题:Java LineChart.invalidate方法的具体用法?Java LineChart.invalidate怎么用?Java LineChart.invalidate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.charts.LineChart
的用法示例。
在下文中一共展示了LineChart.invalidate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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: populateDiagram
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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();
}
示例3: onCreate
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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.setDescription("");
// add an empty data object
mChart.setData(new LineData());
// mChart.getXAxis().setDrawLabels(false);
// mChart.getXAxis().setDrawGridLines(false);
mChart.invalidate();
}
示例4: refreshTemperatureChart
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
public void refreshTemperatureChart(LineChart temperatureChart, MarsI2cControl i2cControl) {
int[] c = {0,0,0,0};
float[] tempValues = {i2cControl.getT1(), i2cControl.getT2(), i2cControl.getT3(), i2cControl.getGlobalTemp()};
for (int i=0;i<4;i++) {
c[i] = temperatureChart.getLineData().getDataSetByIndex(i).getEntryCount();
temperatureChart.getLineData().getDataSetByIndex(i).removeFirst();
temperatureChart.getLineData().getDataSetByIndex(i).addEntry(new Entry(c[i]++ + auxForTemperatureBuffer[i], tempValues[i]));
auxForTemperatureBuffer[i]++;
}
temperatureChart.getLineData().notifyDataChanged();
temperatureChart.notifyDataSetChanged();
temperatureChart.invalidate();
}
示例5: refreshGasesChart
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
public void refreshGasesChart(LineChart gasesChart, MarsI2cControl i2cControl) {
int[] c = {0,0};
float[] tempValues = {i2cControl.getO2(), i2cControl.getCo2()};
for (int i=0;i<2;i++) {
c[i] = gasesChart.getLineData().getDataSetByIndex(i).getEntryCount();
gasesChart.getLineData().getDataSetByIndex(i).removeFirst();
gasesChart.getLineData().getDataSetByIndex(i).addEntry(new Entry(c[i]++ + auxForGasesBuffer[i], tempValues[i]));
auxForGasesBuffer[i]++;
}
gasesChart.getLineData().notifyDataChanged();
gasesChart.notifyDataSetChanged();
gasesChart.invalidate();
}
示例6: onCreate
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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.setBackgroundColor(Color.WHITE);
mChart.setGridBackgroundColor(mFillColor);
mChart.setDrawGridBackground(true);
mChart.setDrawBorders(true);
// no description text
mChart.getDescription().setEnabled(false);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
Legend l = mChart.getLegend();
l.setEnabled(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setAxisMaximum(900f);
leftAxis.setAxisMinimum(-250f);
leftAxis.setDrawAxisLine(false);
leftAxis.setDrawZeroLine(false);
leftAxis.setDrawGridLines(false);
mChart.getAxisRight().setEnabled(false);
// add data
setData(100, 60);
mChart.invalidate();
}
示例7: onCreateView
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.v(TAG, "onCreateView() chart fragment");
// Load the layout of this fragment
View rootView = inflater.inflate(R.layout.fragment_chart, container, false);
createDataSets();
mChart = (LineChart) rootView.findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawYValues(false);
mChart.setDrawGridBackground(false);
mChart.setDescription("Battery and CPU usage chart");
mChart.setYRange(0, 100, false);
mChart.setDrawLegend(true);
initChart();
mChart.invalidate(); // invalidates the whole view
return rootView;
}
示例8: notifyDataSetChanged
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
/**
* 更新图表
*
* @param chart 图表
* @param values 数据
* @param valueType 数据类型
*/
public static void notifyDataSetChanged(LineChart chart, List<Entry> values,
final int valueType) {
chart.getXAxis().setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return xValuesProcess(valueType)[(int) value];
}
});
chart.invalidate();
setChartData(chart, values);
}
示例9: onCreate
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_performance_linechart);
mTvCount = (TextView) findViewById(R.id.tvValueCount);
mSeekBarValues = (SeekBar) findViewById(R.id.seekbarValues);
mTvCount.setText("500");
mSeekBarValues.setProgress(500);
mSeekBarValues.setOnSeekBarChangeListener(this);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setDrawGridBackground(false);
// no description text
mChart.getDescription().setEnabled(false);
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.getAxisLeft().setDrawGridLines(false);
mChart.getAxisRight().setEnabled(false);
mChart.getXAxis().setDrawGridLines(true);
mChart.getXAxis().setDrawAxisLine(false);
// dont forget to refresh the drawing
mChart.invalidate();
}
示例10: onCreate
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_performance_linechart);
mTvCount = (TextView) findViewById(R.id.tvValueCount);
mSeekBarValues = (SeekBar) findViewById(R.id.seekbarValues);
mTvCount.setText("500");
mSeekBarValues.setProgress(500);
mSeekBarValues.setOnSeekBarChangeListener(this);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setDrawGridBackground(false);
// no description text
mChart.setDescription("");
mChart.setNoDataTextDescription("You need to provide data for the chart.");
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.getAxisLeft().setDrawGridLines(false);
mChart.getAxisRight().setEnabled(false);
mChart.getXAxis().setDrawGridLines(true);
mChart.getXAxis().setDrawAxisLine(false);
// dont forget to refresh the drawing
mChart.invalidate();
}
示例11: setupGraphic
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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: initChart
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
/**
* 初始化图表
*
* @param chart 原始图表
* @return 初始化后的图表
*/
public static LineChart initChart(LineChart chart) {
// 不显示数据描述
chart.getDescription().setEnabled(false);
// 没有数据的时候,显示“暂无数据”
chart.setNoDataText("暂无数据");
// 不显示表格颜色
chart.setDrawGridBackground(false);
// 不可以缩放
chart.setScaleEnabled(false);
// 不显示y轴右边的值
chart.getAxisRight().setEnabled(false);
// 不显示图例
Legend legend = chart.getLegend();
legend.setEnabled(false);
// 向左偏移15dp,抵消y轴向右偏移的30dp
chart.setExtraLeftOffset(-15);
XAxis xAxis = chart.getXAxis();
// 不显示x轴
xAxis.setDrawAxisLine(false);
// 设置x轴数据的位置
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextColor(Color.WHITE);
xAxis.setTextSize(12);
xAxis.setGridColor(Color.parseColor("#30FFFFFF"));
// 设置x轴数据偏移量
xAxis.setYOffset(-12);
YAxis yAxis = chart.getAxisLeft();
// 不显示y轴
yAxis.setDrawAxisLine(false);
// 设置y轴数据的位置
yAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
// 不从y轴发出横向直线
yAxis.setDrawGridLines(false);
yAxis.setTextColor(Color.WHITE);
yAxis.setTextSize(12);
// 设置y轴数据偏移量
yAxis.setXOffset(30);
yAxis.setYOffset(-3);
yAxis.setAxisMinimum(0);
//Matrix matrix = new Matrix();
// x轴缩放1.5倍
//matrix.postScale(1.5f, 1f);
// 在图表动画显示之前进行缩放
//chart.getViewPortHandler().refresh(matrix, chart, false);
// x轴执行动画
//chart.animateX(2000);
chart.invalidate();
return chart;
}
示例13: onCreate
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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_time);
tvX = (TextView) findViewById(R.id.tvXMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarX.setProgress(100);
tvX.setText("100");
mSeekBarX.setOnSeekBarChangeListener(this);
mChart = (LineChart) findViewById(R.id.chart1);
// no description text
mChart.getDescription().setEnabled(false);
// enable touch gestures
mChart.setTouchEnabled(true);
mChart.setDragDecelerationFrictionCoef(0.9f);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setDrawGridBackground(false);
mChart.setHighlightPerDragEnabled(true);
// set an alternative background color
mChart.setBackgroundColor(Color.WHITE);
mChart.setViewPortOffsets(0f, 0f, 0f, 0f);
// add data
setData(100, 30);
mChart.invalidate();
// get the legend (only possible after setting data)
Legend l = mChart.getLegend();
l.setEnabled(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.TOP_INSIDE);
xAxis.setTypeface(mTfLight);
xAxis.setTextSize(10f);
xAxis.setTextColor(Color.WHITE);
xAxis.setDrawAxisLine(false);
xAxis.setDrawGridLines(true);
xAxis.setTextColor(Color.rgb(255, 192, 56));
xAxis.setCenterAxisLabels(true);
xAxis.setGranularity(1f); // one hour
xAxis.setValueFormatter(new IAxisValueFormatter() {
private SimpleDateFormat mFormat = new SimpleDateFormat("dd MMM HH:mm");
@Override
public String getFormattedValue(float value, AxisBase axis) {
long millis = TimeUnit.HOURS.toMillis((long) value);
return mFormat.format(new Date(millis));
}
});
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
leftAxis.setTypeface(mTfLight);
leftAxis.setTextColor(ColorTemplate.getHoloBlue());
leftAxis.setDrawGridLines(true);
leftAxis.setGranularityEnabled(true);
leftAxis.setAxisMinimum(0f);
leftAxis.setAxisMaximum(170f);
leftAxis.setYOffset(-9f);
leftAxis.setTextColor(Color.rgb(255, 192, 56));
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
}
示例14: onCreate
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarX.setProgress(45);
mSeekBarY.setProgress(100);
mSeekBarY.setOnSeekBarChangeListener(this);
mSeekBarX.setOnSeekBarChangeListener(this);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawGridBackground(false);
// no description text
mChart.getDescription().setEnabled(false);
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(true);
// set an alternative background color
// mChart.setBackgroundColor(Color.GRAY);
// create a custom MarkerView (extend MarkerView) and specify the layout
// to use for it
MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
mv.setChartView(mChart); // For bounds control
mChart.setMarker(mv); // Set the marker to the chart
XAxis xl = mChart.getXAxis();
xl.setAvoidFirstLastClipping(true);
xl.setAxisMinimum(0f);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setInverted(true);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
// add data
setData(25, 50);
// // restrain the maximum scale-out factor
// mChart.setScaleMinima(3f, 3f);
//
// // center the view to a specific position inside the chart
// mChart.centerViewPort(10, 50);
// get the legend (only possible after setting data)
Legend l = mChart.getLegend();
// modify the legend ...
l.setForm(LegendForm.LINE);
// dont forget to refresh the drawing
mChart.invalidate();
}
示例15: onCreate
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarX.setProgress(45);
mSeekBarY.setProgress(100);
mSeekBarY.setOnSeekBarChangeListener(this);
mSeekBarX.setOnSeekBarChangeListener(this);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setViewPortOffsets(0, 0, 0, 0);
mChart.setBackgroundColor(Color.rgb(104, 241, 175));
// no description text
mChart.getDescription().setEnabled(false);
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
mChart.setMaxHighlightDistance(300);
XAxis x = mChart.getXAxis();
x.setEnabled(false);
YAxis y = mChart.getAxisLeft();
y.setTypeface(mTfLight);
y.setLabelCount(6, false);
y.setTextColor(Color.WHITE);
y.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
y.setDrawGridLines(false);
y.setAxisLineColor(Color.WHITE);
mChart.getAxisRight().setEnabled(false);
// add data
setData(45, 100);
mChart.getLegend().setEnabled(false);
mChart.animateXY(2000, 2000);
// dont forget to refresh the drawing
mChart.invalidate();
}