Java Code Examples for com.github.mikephil.charting.charts.BarChart#setFitBars()
The following examples show how to use
com.github.mikephil.charting.charts.BarChart#setFitBars() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BarChartHelper.java From Ticket-Analysis with MIT License | 5 votes |
public BarChart generateBarChartConfig(BarChart barChart) { XAxis xAxis = barChart.getXAxis(); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); //定制X轴是在图表上方还是下方。 xAxis.setDrawAxisLine(true); xAxis.setDrawGridLines(false); xAxis.setGranularity(1f);//放大的时候X值不增多 YAxis yAxisRight = barChart.getAxisRight(); yAxisRight.setEnabled(false); YAxis yAxisLeft = barChart.getAxisLeft(); yAxisLeft.setAxisMinimum(0); barChart.setDrawBarShadow(false); barChart.setPinchZoom(true); barChart.setFitBars(true); // if more than 60 entries are displayed in the chart, no values will be // drawn barChart.setMaxVisibleValueCount(60); barChart.setDrawValueAboveBar(true); barChart.getDescription().setEnabled(false); barChart.setNoDataText("无数据"); Legend l = barChart.getLegend(); l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER); l.setOrientation(Legend.LegendOrientation.HORIZONTAL); //设置单方向和双方向缩放 true x,y方向可以同时控制,false只能控制x方向的缩小放大或者Y方向的缩小放大 l.setDrawInside(false); l.setFormSize(8f); l.setXEntrySpace(4f); return barChart; }
Example 2
Source File: TestSuiteFragment.java From SQLite-Performance with The Unlicense | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.suite_fragment, container, false); mChart = (BarChart) v.findViewById(R.id.chart); mChart.setNoDataText(null); mChart.setNoDataTextColor(0xFF000000); mChart.setFitBars(true); return v; }
Example 3
Source File: HistogramChart.java From walt with Apache License 2.0 | 4 votes |
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(); }