本文整理汇总了Java中com.github.mikephil.charting.charts.BarChart.animateY方法的典型用法代码示例。如果您正苦于以下问题:Java BarChart.animateY方法的具体用法?Java BarChart.animateY怎么用?Java BarChart.animateY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.charts.BarChart
的用法示例。
在下文中一共展示了BarChart.animateY方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setHorizontalBarChart
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
/**
* Set the horizontal bar pattern
* @param barChart chart
* @param chartData horizontal bar chart data
* @param jobs string array of job titles
* @param typeface Typeface font
*/
public static void setHorizontalBarChart(BarChart barChart, final ChartData<?> chartData,
final String[] jobs, Typeface typeface) {
barChart.setDrawGridBackground(false);
XAxis xAxis = barChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
//xAxis.setLabelCount(chartData.getEntryCount());
xAxis.setLabelCount(jobs.length);
xAxis.setTypeface(typeface);
xAxis.setDrawAxisLine(true);
xAxis.setDrawGridLines(false);
xAxis.setGranularity(1f);
YAxis leftAxis = barChart.getAxisLeft();
leftAxis.setTypeface(typeface);
leftAxis.setSpaceTop(15f);
leftAxis.setAxisMinimum(0f);
leftAxis.setGranularity(1f);
leftAxis.setDrawAxisLine(true);
leftAxis.setDrawGridLines(true);
YAxis axisRight = barChart.getAxisRight();
axisRight.setTypeface(typeface);
axisRight.setDrawAxisLine(true);
axisRight.setDrawGridLines(false);
axisRight.setGranularity(1f);
axisRight.setAxisMinimum(0f);
final Legend legend = barChart.getLegend();
legend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
legend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
legend.setOrientation(Legend.LegendOrientation.HORIZONTAL);
legend.setDrawInside(false);
legend.setFormSize(8f);
legend.setXEntrySpace(4f);
barChart.setData((BarData) chartData);
barChart.setFitBars(true);
barChart.animateY(DURATION_LONG);
xAxis.setValueFormatter(new HorizontalBarValueFormatter(jobs));
}
示例2: setVerticalBarChart
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
/**
* Set the vertical bar pattern
* @param barChart chart
* @param chartData pie chart data
* @param typeface Typeface font
*/
public static void setVerticalBarChart(Context context, BarChart barChart, ChartData<?> chartData,
Typeface typeface) {
// create a custom MarkerView (extend MarkerView) and specify the layout to use for it
ExperienceMarker marker = new ExperienceMarker(context, R.layout.marker_exp_age);
marker.setChartView(barChart); // For bounds control
barChart.setMarker(marker);
//fix crash com.github.mikephil.charting.charts.Chart.drawMarkers(Chart.java:731)
barChart.setDrawMarkers(false);
barChart.getDescription().setEnabled(false);
barChart.setDrawGridBackground(false);
barChart.setDrawBarShadow(false);
XAxis xAxis = barChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
//Sets the number of labels for the x-axis (display all the x-axis values)
// xAxis.setLabelCount(chartData.getEntryCount());
xAxis.setTypeface(typeface);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(true);
YAxis leftAxis = barChart.getAxisLeft();
leftAxis.setTypeface(typeface);
leftAxis.setSpaceTop(20f);
leftAxis.setAxisMinimum(0f);
YAxis rightAxis = barChart.getAxisRight();
rightAxis.setTypeface(typeface);
rightAxis.setSpaceTop(20f);
rightAxis.setAxisMinimum(0f);
chartData.setValueTypeface(typeface);
barChart.setData((BarData) chartData);
barChart.setFitBars(true);
barChart.animateY(DURATION_SHORT);
}
示例3: initChart
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
/**
* initiliaze chart
*/
private void initChart() {
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
mChart.setDescriptionColor(Color.parseColor("#000000"));
XAxis xAxis = mChart.getXAxis();
xAxis.setDrawGridLines(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setSpaceBetweenLabels(0);
YAxisValueFormatter custom = new DataAxisFormatter("%");
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setValueFormatter(custom);
leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setValueFormatter(custom);
rightAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setDrawGridLines(true);
rightAxis.setDrawGridLines(false);
mChart.animateY(1000);
mChart.getLegend().setEnabled(true);
mChart.setVisibility(View.GONE);
}
示例4: setupTemperatureChart
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
protected void setupTemperatureChart(){
EnvStatistic temperature = mHDD.getSessionData().getCurrentStats().getTemperature();
if(temperature!=null && temperature.isValid()){
mTempChart = new BarChart(this);
List<BarEntry> statVals = new ArrayList<>(3);
statVals.add(new BarEntry((float) temperature.getMin(), 0));
statVals.add(new BarEntry((float) temperature.getAvg(), 1));
statVals.add(new BarEntry((float) temperature.getMax(), 2));
BarDataSet summary = new BarDataSet(statVals,"Temperature");
mTempChart.setData(new BarData(new String[]{"Min", "Avg", "Max"}, summary));
mTempChart.setDescription("");
mTempChart.animateY(2000);
mTempChart.getAxisRight().setEnabled(false);
mTempChart.setTouchEnabled(false);
mTempChart.setLayoutParams(new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
mTempChart.setMinimumHeight(STATISTIC_CHART_HEIGHT);
mTempChartContainer.addView(mTempChart);
}
else{
TextView noGraph = new TextView(this);
noGraph.setText("No Temperature Statistics to Show");
noGraph.setGravity(View.TEXT_ALIGNMENT_CENTER);
mTempChartContainer.addView(noGraph);
}
}
示例5: setupPressureChart
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
protected void setupPressureChart(){
EnvStatistic pressure = mHDD.getSessionData().getCurrentStats().getPressure();
if(pressure!=null && pressure.isValid()){
mPressureChart = new BarChart(this);
List<BarEntry> statVals = new ArrayList<>(3);
statVals.add(new BarEntry((float) pressure.getMin(),0));
statVals.add(new BarEntry((float) pressure.getAvg(), 1));
statVals.add(new BarEntry((float) pressure.getMax(), 2));
BarDataSet summary = new BarDataSet(statVals,"Pressure");
mPressureChart.setData(new BarData(new String[]{"Min", "Avg", "Max"}, summary));
mPressureChart.setDescription("");
mPressureChart.animateY(2000);
mPressureChart.getAxisRight().setEnabled(false);
mPressureChart.setTouchEnabled(false);
mPressureChart.setLayoutParams(new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
mPressureChart.setMinimumHeight(STATISTIC_CHART_HEIGHT);
mPressureChartContainer.addView(mPressureChart);
}
else{
TextView noGraph = new TextView(this);
noGraph.setText("No Pressure Statistics to Show");
noGraph.setGravity(View.TEXT_ALIGNMENT_CENTER);
mPressureChartContainer.addView(noGraph);
}
}
示例6: setupHumidityChart
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
protected void setupHumidityChart(){
EnvStatistic humidity = mHDD.getSessionData().getCurrentStats().getHumidity();
if(humidity!=null && humidity.isValid()){
mHumidityChart = new BarChart(this);
List<BarEntry> statVals = new ArrayList<>(3);
statVals.add(new BarEntry((float) humidity.getMin(), 0));
statVals.add(new BarEntry((float) humidity.getAvg(), 1));
statVals.add(new BarEntry((float) humidity.getMax(), 2));
BarDataSet summary = new BarDataSet(statVals,"Humidity");
mHumidityChart.setData(new BarData(new String[]{"Min", "Avg", "Max"}, summary));
mHumidityChart.setDescription("");
mHumidityChart.animateY(2000);
mHumidityChart.getAxisRight().setEnabled(false);
mHumidityChart.setTouchEnabled(false);
mHumidityChart.setLayoutParams(new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
mHumidityChart.setMinimumHeight(STATISTIC_CHART_HEIGHT);
mHumidityChartContainer.addView(mHumidityChart);
}
else{
TextView noGraph = new TextView(this);
noGraph.setText("No Humidity Statistics to Show");
noGraph.setGravity(View.TEXT_ALIGNMENT_CENTER);
mHumidityChartContainer.addView(noGraph);
}
}
示例7: onCreate
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_barchart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.getDescription().setEnabled(false);
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawBarShadow(false);
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
mChart.getAxisLeft().setDrawGridLines(false);
// setting data
mSeekBarX.setProgress(10);
mSeekBarY.setProgress(100);
// add a nice and smooth animation
mChart.animateY(2500);
mChart.getLegend().setEnabled(false);
}
示例8: onCreate
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_barchart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setDescription("");
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawBarShadow(false);
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setSpaceBetweenLabels(0);
xAxis.setDrawGridLines(false);
mChart.getAxisLeft().setDrawGridLines(false);
// setting data
mSeekBarX.setProgress(10);
mSeekBarY.setProgress(100);
// add a nice and smooth animation
mChart.animateY(2500);
mChart.getLegend().setEnabled(false);
// Legend l = mChart.getLegend();
// l.setPosition(LegendPosition.BELOW_CHART_CENTER);
// l.setFormSize(8f);
// l.setFormToTextSpace(4f);
// l.setXEntrySpace(6f);
// mChart.setDrawLegend(false);
}
示例9: onCreateView
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_stats, container, false);
// page index
int pageIndex = getArguments().getInt(ARG_SECTION_NUMBER);
// init stats for this page
initStats(pageIndex);
TextView textView = (TextView) rootView.findViewById(R.id.section_label);
String playerName;
if (pageIndex < 2) {
playerName = getString(R.string.all_players);
} else {
playerName = game.getPlayer(pageIndex - 2).getName();
}
// fill text using format string template from resource
textView.setText(getString(
R.string.section_format,
playerName,
createStatsText(pageIndex)
));
// To make vertical bar chart, initialize graph id this way
barChart = (BarChart) rootView.findViewById(R.id.chart);
barChart.animateY(1000);
barChart.getXAxis().setLabelsToSkip(0);
barChart.setDescription(null);
barChart.getLegend().setPosition(Legend.LegendPosition.ABOVE_CHART_LEFT);
barChart.getLegend().setTextSize(14);
if (pageIndex == 0) {
// fill chart with stacked bars showing player vs. player
createBarChartStackedPlayers(barChart);
} else {
// fill chart with stacked bars showing single vs. double roll
createBarChartStacked(barChart);
// fill chart
// createBarChart(barChart);
}
return rootView;
}
示例10: onCreateView
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.charts_fragment, container, false);
TextView month = (TextView) v.findViewById(R.id.current_month);
long ts = getArguments().getLong(DB.TIMESTAMP);
month.setText(SDF_MONTH.format(new Date(ts * 1000)));
// отображение статистики за текущий месяц
BarChart barChart = (BarChart) v.findViewById(R.id.bar_chart);
barChart.setDescription("");
Paint mInfoPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mInfoPaint.setColor(getResources().getColor(R.color.primary));
mInfoPaint.setTextAlign(Paint.Align.CENTER);
mInfoPaint.setTextSize(com.github.mikephil.charting.utils.Utils.convertDpToPixel(16f));
barChart.setPaint(mInfoPaint, Chart.PAINT_INFO);
barChart.setNoDataText(getString(R.string.charts_no_data));
barChart.setDrawBarShadow(false);
barChart.setDrawGridBackground(false);
barChart.setDrawValueAboveBar(false);
barChart.setPinchZoom(false);
barChart.setScaleEnabled(false);
barChart.setDoubleTapToZoomEnabled(false);
barChart.getXAxis().disableGridDashedLine();
barChart.getXAxis().setDrawGridLines(false);
barChart.getXAxis().setEnabled(false);
barChart.getAxisLeft().setDrawGridLines(false);
barChart.getAxisLeft().setEnabled(false);
barChart.getAxisRight().setDrawGridLines(false);
barChart.getAxisRight().removeAllLimitLines();
barChart.getAxisRight().setValueFormatter(new FinanceFormatter());
barChart.getLegend().setEnabled(false);
barChart.setData(generateMonthlyData());
// если данных нет, не показывать ось
barChart.getAxisRight().setEnabled(!barChart.isEmpty());
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
mv.setX(mv.getMeasuredWidth());
barChart.setMarkerView(mv);
Utils.log("getYMin = " + barChart.getBarData().getYMin());
Utils.log("getYMax = " + barChart.getBarData().getYMax());
barChart.animateY(ANIMATION_TIME);
return v;
}