本文整理匯總了Java中com.github.mikephil.charting.charts.BarChart.invalidate方法的典型用法代碼示例。如果您正苦於以下問題:Java BarChart.invalidate方法的具體用法?Java BarChart.invalidate怎麽用?Java BarChart.invalidate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.mikephil.charting.charts.BarChart
的用法示例。
在下文中一共展示了BarChart.invalidate方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.timevis_layout);
barchart = (BarChart) findViewById(R.id.barchart);
Intent intent = getIntent();
String ot = intent.getExtras().getString("ot");
String pt = intent.getExtras().getString("pt");
String lt = intent.getExtras().getString("lt");
String pert = intent.getExtras().getString("pert");
Float otf = Float.valueOf(ot);
Float ptf = Float.valueOf(pt);
Float ltf = Float.valueOf(lt);
Float pertf = Float.valueOf(pert);
List<BarEntry> entries = new ArrayList<>();
entries.add(new BarEntry(0f, otf.floatValue()));
entries.add(new BarEntry(1f, ptf.floatValue()));
entries.add(new BarEntry(2f, ltf.floatValue()));
entries.add(new BarEntry(3f, pertf.floatValue()));
BarDataSet set = new BarDataSet(entries, "Time Visualization");
BarData data = new BarData(set);
data.setBarWidth(0.9f); // set custom bar width
barchart.setData(data);
barchart.setFitBars(true); // make the x-axis fit exactly all bars
barchart.invalidate();
}
示例2: insertChartSample
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
/**
* Procedure to add last DetailsData sample to chart.
* @param data
* @param chart
*/
private void insertChartSample(DetailsData data, BarChart chart, @Nullable Beacon beacon) {
data.insertAndUpdate(beacon);
BarData barData = chart.getData();
BarDataSet set = barData.getDataSetByIndex(0);
if(set.getEntryCount() == mPresenter.getSamplesCount()) {
barData.removeXValue(0);
set.removeEntry(0);
for (Entry entry : set.getYVals()) {
entry.setXIndex(entry.getXIndex() - 1);
}
}
barData.addXValue(" ");
BarEntry newEntry = new BarEntry(
data.getCurrentValue(mPresenter.getMode()),
set.getEntryCount());
barData.addEntry(newEntry, 0);
setChartRange(chart, data, mPresenter.getAutoscale());
setChartAverage(chart, data, mPresenter.getAverage());
chart.notifyDataSetChanged();
chart.invalidate();
}
示例3: onCreateView
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_historique_graph, container, false);
// Gestion de l'affichage graphique
rlGraphHistorique = (RelativeLayout) view.findViewById(R.id.rlGraphHistorique);
graphiqueHistorique = new BarChart(getContext());
final RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
rlGraphHistorique.addView(graphiqueHistorique,lp);
List<BarEntry> entries = getEntries(pointMesures);
BarDataSet dataSet = new BarDataSet(entries, "Graphique Historique");
//TODO : ne fonctionne pas avec le fichier de ressource colors
dataSet.setColor(R.color.barColorGraph);
dataSet.setValueTextColor(R.color.textColorGraph);
BarData lineData = new BarData(dataSet);
graphiqueHistorique.setData(lineData);
graphiqueHistorique.getLegend().setEnabled(false);
graphiqueHistorique.getDescription().setEnabled(false);
graphiqueHistorique.invalidate(); // refresh
return view;
}
示例4: onCreateView
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_idpt, container, false);
BarChart chart = (BarChart) view.findViewById(R.id.chart);
BarData data = new BarData(getXAxisValues(), getDataSet());
//legend coding
Legend l=chart.getLegend();
l.setFormSize(10f);
l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
l.setTextSize(12f);
l.setTextColor(Color.BLACK);
l.setXEntrySpace(5f);
l.setYEntrySpace(5f);
//l.setCustom();
XAxis xaxis=chart.getXAxis();
xaxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xaxis.setTextSize(7f);
xaxis.setTextColor(Color.parseColor("#212121"));
xaxis.setDrawAxisLine(true);
xaxis.setDrawGridLines(false);
chart.setData(data);
chart.setDescription("");
chart.animateXY(2000, 2000);
chart.invalidate();
// chart.zoom(100, 10, 10, 10);
return view;
}
示例5: onCreate
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chart);
BarChart chart = (BarChart) findViewById(R.id.chart);
//BarData data = new BarData(getXAxisValues(),getDataSet());
BarData data = new BarData();
chart.setData(data);
chart.setDescription("My Chart");
chart.animateXY(2000, 2000);
chart.invalidate();
}
示例6: updateSpectrumGUI
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
private void updateSpectrumGUI() {
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
double[] freqLabels = measurementService.getAudioProcess().getRealtimeCenterFrequency();
float[] freqValues = measurementService.getAudioProcess().getThirdOctaveFrequencySPL();
for(int idfreq =0; idfreq < freqLabels.length; idfreq++) {
xVals.add(Spectrogram.formatFrequency((int)freqLabels[idfreq]));
// Sum values
// Compute frequency range covered by frequency
yVals1.add(new BarEntry(new float[] {freqValues[idfreq]}, idfreq));
}
BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
set1.setColor(Color.rgb(102, 178, 255));
set1.setStackLabels(new String[]{
"SL"
});
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
BarChart sChart = getSpectrum();
if(sChart != null){
sChart.setData(data);
sChart.setPadding(0, 0, 0, 0);
sChart.setViewPortOffsets(0,0,0,0);
sChart.invalidate(); // refresh
}
}
示例7: populateUserStatsChart
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
/**
* Show user stats graph
*/
private void populateUserStatsChart() {
final String[] userStatsChartXAxisLabel = getActivity().getResources().getStringArray(R.array.user_stats_x_axis_labels);
final BarChart chart = getActivity().findViewById(R.id.user_stats_chart);
chart.setTouchEnabled(false);
XAxis xAxis = chart.getXAxis();
xAxis.setGranularity(1);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setValueFormatter(new IAxisValueFormatter() {
/**
* Format the value
* @param value - value to fit to the axis
* @param axis - the axis to fit to
* @return Returns the formatted value
*/
@Override
public String getFormattedValue(float value, AxisBase axis) {
int v = (int) value;
return userStatsChartXAxisLabel[v];
}
});
xAxis.setDrawGridLines(false);
xAxis.setTextSize(11f);
YAxis rightAxis = chart.getAxisRight();
rightAxis.setEnabled(false);
chart.getAxisLeft().setGranularity(1);
chart.getDescription().setEnabled(false);
if (mUser != null) {
int[] colors = getActivity().getResources().getIntArray(R.array.user_stats_chart_colors);
List<BarEntry> entries = new ArrayList<>();
entries.add(new BarEntry(0f, mUser.getPlantsAdded()));
entries.add(new BarEntry(1f, mUser.getPlantsDeleted()));
entries.add(new BarEntry(2f, mUser.getWaterCount()));
entries.add(new BarEntry(3f, mUser.getMeasureCount()));
entries.add(new BarEntry(4f, mUser.getPhotoCount()));
BarDataSet barDataSet = new BarDataSet(entries, "Plant Operations");
barDataSet.setColors(ColorTemplate.createColors(colors));
barDataSet.setValueTextSize(11f);
BarData data = new BarData(barDataSet);
data.setBarWidth(0.9f); // set custom bar width
chart.setData(data);
chart.invalidate(); // refresh
}
}
示例8: onCreateView
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_type_country, container, false);
deathWheelProgressDialog = DeathWheelProgressDialog.createDialog(getActivity());
deathWheelProgressDialog.show();
// 從接口獲取數據
Observer<Statistics> observer = new Observer<Statistics>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
Snackbar.make(getView(), "獲取戰績信息錯誤!", Snackbar.LENGTH_LONG).show();
deathWheelProgressDialog.dismiss();
}
@Override
public void onNext(Statistics s) {
statistics = s;
setLevelChartData();
setCountryChartData();
setTypeChartData();
deathWheelProgressDialog.dismiss();
}
};
String woterId = PreferenceUtils.getCustomPrefString(getActivity(), "woterId", "woterId", "");
String region = PreferenceUtils.getCustomPrefString(getActivity(), "queryinfo", "region", "");
Network.getKongzhongNewApi(region)
.getStatistics(woterId, MainFragment.BATTLE_TYPE)
.map(StatisticsJsonToStatisticsMapper.getInstance())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(observer);
level_chart = (BarChart) view.findViewById(R.id.level_chart);
type_chart = (BarChart) view.findViewById(R.id.type_chart);
country_charts = (BarChart) view.findViewById(R.id.country_chart);
level_chart.invalidate();
type_chart.invalidate();
country_charts.invalidate();
deathWheelProgressDialog.dismiss();
return view;
}
示例9: HistogramChart
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
public HistogramChart(Context context, AttributeSet attrs) {
super(context, attrs);
inflate(getContext(), R.layout.histogram, this);
barChart = (BarChart) findViewById(R.id.bar_chart);
findViewById(R.id.button_close_bar_chart).setOnClickListener(this);
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HistogramChart);
final String descString;
final int numDataSets;
final float binWidth;
try {
descString = a.getString(R.styleable.HistogramChart_description);
numDataSets = a.getInteger(R.styleable.HistogramChart_numDataSets, 1);
binWidth = a.getFloat(R.styleable.HistogramChart_binWidth, 5f);
} finally {
a.recycle();
}
ArrayList<IBarDataSet> dataSets = new ArrayList<>(numDataSets);
for (int i = 0; i < numDataSets; i++) {
final BarDataSet dataSet = new BarDataSet(new ArrayList<BarEntry>(), "");
dataSet.setColor(ColorTemplate.MATERIAL_COLORS[i]);
dataSets.add(dataSet);
}
BarData barData = new BarData(dataSets);
barData.setBarWidth((1f - GROUP_SPACE)/numDataSets);
barChart.setData(barData);
histogramData = new HistogramData(numDataSets, binWidth);
groupBars(barData);
final Description desc = new Description();
desc.setText(descString);
desc.setTextSize(12f);
barChart.setDescription(desc);
XAxis xAxis = barChart.getXAxis();
xAxis.setGranularityEnabled(true);
xAxis.setGranularity(1);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setValueFormatter(new IAxisValueFormatter() {
DecimalFormat df = new DecimalFormat("#.##");
@Override
public String getFormattedValue(float value, AxisBase axis) {
return df.format(histogramData.getDisplayValue(value));
}
});
barChart.setFitBars(true);
barChart.invalidate();
}
示例10: onCreate
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_graph);
cacheFiles = (TextView)findViewById(R.id.cache_files);
dataFiles = (TextView)findViewById(R.id.data_files);
systemFiles = (TextView)findViewById(R.id.system_files);
cacheTitle = (TextView)findViewById(R.id.cache_title);
dataTitle = (TextView)findViewById(R.id.data_title);
systemTitle = (TextView)findViewById(R.id.system_title);
mParts.add("Cache");
mParts.add("Data");
mParts.add("System");
mPieParts.add("RR");
mPieParts.add("RW");
mPieParts.add("SR");
mPieParts.add("SW");
graphData = new GraphData();
btnParse = (Button)findViewById(R.id.bt_parse);
btnParse.setOnClickListener(this);
progressDialog = new ProgressDialog(this);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setCancelable(false);
partBartChart = (BarChart)findViewById(R.id.part_bar_chart);
partBartChart.setDrawGridBackground(false);
partBartChart.setDescription("");
// I don't want handle touch event
partBartChart.setTouchEnabled(false);
Legend l = partBartChart.getLegend();
l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_INSIDE);
l.setYOffset(0f);
l.setYEntrySpace(0f);
l.setTextSize(8f);
XAxis xl = partBartChart.getXAxis();
xl.setPosition(XAxis.XAxisPosition.BOTTOM);
YAxis leftAxis = partBartChart.getAxisLeft();
leftAxis.setDrawGridLines(false);
leftAxis.setSpaceTop(30f);
leftAxis.setAxisMinValue(0);
leftAxis.setValueFormatter(new LargeValueFormatter());
partBartChart.getAxisRight().setEnabled(false);
BarData barData = new BarData();
barData.addXValue(mParts.get(0));
barData.addXValue(mParts.get(1));
barData.addXValue(mParts.get(2));
partBartChart.setData(barData);
partBartChart.invalidate();
ioPercentChart = (PieChart)findViewById(R.id.io_percent);
ioPercentChart.setUsePercentValues(true);
ioPercentChart.setDescription("");
ioPercentChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
ioPercentChart.setRotationAngle(0);
// enable rotation of the chart by touch
ioPercentChart.setRotationEnabled(true);
ioPercentChart.setHighlightPerTapEnabled(true);
Legend pieL = ioPercentChart.getLegend();
pieL.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
pieL.setXEntrySpace(7f);
pieL.setYEntrySpace(0f);
pieL.setYOffset(0f);
}
示例11: updateBarChart
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
private void updateBarChart() {
BarChart barChart = getBarChart();
if(barChart == null) {
return;
}
if(freqLeqStats.size() <= 2) {
return;
}
double[] pearsons = computePearson();
if(pearsons == null) {
return;
}
float YMin = Float.MAX_VALUE;
float YMax = Float.MIN_VALUE;
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
// Read all white noise values for indexing before usage
ArrayList<BarEntry> yMeasure = new ArrayList<BarEntry>();
int idfreq = 0;
for (double value : pearsons) {
YMax = Math.max(YMax, (float)value);
YMin = Math.min(YMin, (float)value);
yMeasure.add(new BarEntry((float)value, idfreq++));
}
BarDataSet freqSet = new BarDataSet(yMeasure, "Pearson's correlation");
freqSet.setColor(ColorTemplate.COLORFUL_COLORS[0]);
freqSet.setValueTextColor(Color.WHITE);
freqSet.setDrawValues(true);
dataSets.add(freqSet);
ArrayList<String> xVals = new ArrayList<String>();
double[] freqs = FFTSignalProcessing.computeFFTCenterFrequency(AudioProcess.REALTIME_SAMPLE_RATE_LIMITATION);
for (double freqValue : freqs) {
xVals.add(Spectrogram.formatFrequency((int)freqValue));
}
// create a data object with the datasets
BarData data = new BarData(xVals, dataSets);
barChart.setData(data);
YAxis yl = barChart.getAxisLeft();
yl.setAxisMinValue(YMin - 0.1f);
yl.setAxisMaxValue(YMax + 0.1f);
barChart.invalidate();
}