本文整理汇总了Java中com.github.mikephil.charting.charts.BarChart.setExtraRightOffset方法的典型用法代码示例。如果您正苦于以下问题:Java BarChart.setExtraRightOffset方法的具体用法?Java BarChart.setExtraRightOffset怎么用?Java BarChart.setExtraRightOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.charts.BarChart
的用法示例。
在下文中一共展示了BarChart.setExtraRightOffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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_noseekbar);
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setBackgroundColor(Color.WHITE);
mChart.setExtraTopOffset(-30f);
mChart.setExtraBottomOffset(10f);
mChart.setExtraLeftOffset(70f);
mChart.setExtraRightOffset(70f);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.getDescription().setEnabled(false);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false);
xAxis.setTextColor(Color.LTGRAY);
xAxis.setTextSize(13f);
xAxis.setLabelCount(5);
xAxis.setCenterAxisLabels(true);
xAxis.setGranularity(1f);
YAxis left = mChart.getAxisLeft();
left.setDrawLabels(false);
left.setSpaceTop(25f);
left.setSpaceBottom(25f);
left.setDrawAxisLine(false);
left.setDrawGridLines(false);
left.setDrawZeroLine(true); // draw a zero line
left.setZeroLineColor(Color.GRAY);
left.setZeroLineWidth(0.7f);
mChart.getAxisRight().setEnabled(false);
mChart.getLegend().setEnabled(false);
// THIS IS THE ORIGINAL DATA YOU WANT TO PLOT
final List<Data> data = new ArrayList<>();
data.add(new Data(0f, -224.1f, "12-29"));
data.add(new Data(1f, 238.5f, "12-30"));
data.add(new Data(2f, 1280.1f, "12-31"));
data.add(new Data(3f, -442.3f, "01-01"));
data.add(new Data(4f, -2280.1f, "01-02"));
xAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return data.get(Math.min(Math.max((int) value, 0), data.size()-1)).xAxisValue;
}
});
setData(data);
}
示例2: 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_noseekbar);
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setBackgroundColor(Color.WHITE);
mChart.setExtraTopOffset(-30f);
mChart.setExtraBottomOffset(10f);
mChart.setExtraLeftOffset(70f);
mChart.setExtraRightOffset(70f);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false);
xAxis.setSpaceBetweenLabels(2);
xAxis.setTextColor(Color.LTGRAY);
xAxis.setTextSize(13f);
YAxis left = mChart.getAxisLeft();
left.setDrawLabels(false);
left.setStartAtZero(false);
left.setSpaceTop(25f);
left.setSpaceBottom(25f);
left.setDrawAxisLine(false);
left.setDrawGridLines(false);
left.setDrawZeroLine(true); // draw a zero line
left.setZeroLineColor(Color.GRAY);
left.setZeroLineWidth(0.7f);
mChart.getAxisRight().setEnabled(false);
mChart.getLegend().setEnabled(false);
// THIS IS THE ORIGINAL DATA YOU WANT TO PLOT
List<Data> data = new ArrayList<>();
data.add(new Data(0, -224.1f, "12-29"));
data.add(new Data(1, 238.5f, "12-30"));
data.add(new Data(2, 1280.1f, "12-31"));
data.add(new Data(3, -442.3f, "01-01"));
data.add(new Data(4, -2280.1f, "01-02"));
setData(data);
}
示例3: initializeViews
import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
private void initializeViews() {
titleTextView = (TextView) findViewById(R.id.view_chart_bar_title);
titleTextView.setText(titleText);
titleTextView.setTextColor(titleTextColor);
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize);
titleTextView.setTypeface(Typeface.create(titleTextTypeface, Typeface.NORMAL));
expand = (ImageView) findViewById(R.id.view_chart_line_expand);
if (expandTintColor != 0) {
Drawable drawable = expand.getDrawable();
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable, expandTintColor);
expand.setImageDrawable(drawable);
}
chart = (BarChart) findViewById(R.id.view_chart_bar);
chart.getLegend().setEnabled(false);
chart.setDescription("");
chart.setDrawBorders(false);
chart.setDrawValueAboveBar(false);
chart.setDrawGridBackground(false);
chart.setDrawBarShadow(false);
chart.setDrawHighlightArrow(false);
chart.setPinchZoom(false);
chart.setExtraLeftOffset(0);
chart.setExtraRightOffset(0);
chart.setExtraBottomOffset(8);
chart.setExtraTopOffset(0);
chart.setTouchEnabled(true);
chart.setDragEnabled(true);
XAxis xAxis = chart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawAxisLine(false);
xAxis.setYOffset(16);
xAxis.setDrawGridLines(false);
xAxis.setLabelsToSkip(0);
xAxis.setTextSize(chartXAxisTextSize);
xAxis.setTextColor(chartXAxisTextColor);
xAxis.setTypeface(Typeface.create(chartXAxisTextTypeface, Typeface.NORMAL));
YAxis yAxisLeft = chart.getAxisLeft();
yAxisLeft.setDrawAxisLine(false);
yAxisLeft.setDrawGridLines(false);
yAxisLeft.setDrawZeroLine(false);
yAxisLeft.setDrawLabels(false);
YAxis yAxisRight = chart.getAxisRight();
yAxisRight.setDrawAxisLine(false);
yAxisRight.setDrawGridLines(false);
yAxisRight.setDrawZeroLine(false);
yAxisRight.setDrawLabels(false);
}