本文整理汇总了Java中com.github.mikephil.charting.components.YAxis.setAxisMaximum方法的典型用法代码示例。如果您正苦于以下问题:Java YAxis.setAxisMaximum方法的具体用法?Java YAxis.setAxisMaximum怎么用?Java YAxis.setAxisMaximum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.components.YAxis
的用法示例。
在下文中一共展示了YAxis.setAxisMaximum方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
/**
* Initialize the non-data aspects of the line chart
*/
private void initChart(){
//Initial line Chart for visualization of statistic
lineChart = (LineChart) findViewById(R.id.LineChart);
lineChart.setDragEnabled(true);
lineChart.setScaleEnabled(false);
lineChart.getAxisRight().setEnabled(false);
lineChart.getDescription().setEnabled(false);
YAxis leftAxis = lineChart.getAxisLeft();
leftAxis.removeAllLimitLines();
leftAxis.setAxisMaximum(100f);
leftAxis.setAxisMinimum(0.0f);
leftAxis.enableGridDashedLine(10f, 10f, 0f);
leftAxis.setDrawLimitLinesBehindData(true);
}
示例2: setAxis
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
@Override
public void setAxis(AnalysisXAxisValueFormatter formatter, float yAxisMaxValue) {
XAxis xAxis = mRadarChart.getXAxis();
xAxis.setTextSize(9f);
xAxis.setYOffset(0f);
xAxis.setXOffset(0f);
xAxis.setValueFormatter(formatter);
xAxis.setTextColor(Color.WHITE);
YAxis yAxis = mRadarChart.getYAxis();
yAxis.setLabelCount(5, false);
yAxis.setTextSize(9f);
yAxis.setAxisMinimum(0f);
yAxis.setAxisMaximum(yAxisMaxValue);
yAxis.setDrawLabels(false);
Legend l = mRadarChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
l.setXEntrySpace(7f);
l.setYEntrySpace(5f);
l.setTextColor(Color.WHITE);
}
示例3: onCreate
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的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();
}
示例4: prepareChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void prepareChart() {
mChart.setTouchEnabled(true);
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setPinchZoom(true);
mChart.setHighlightPerTapEnabled(true);
mChart.setDoubleTapToZoomEnabled(false);
mChart.setHighlightPerDragEnabled(false);
mChart.getDescription().setEnabled(false);
mChart.setDrawGridBackground(false);
mChart.getLegend().setEnabled(true);
mChart.getAxisRight().setEnabled(false);
mChart.setMarker(new AMarkView(this, R.layout.ac_detail_mark_view));
final YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTextColor(ContextCompat.getColor(this, R.color.text_primary));
leftAxis.setAxisMaximum(1F);
leftAxis.setDrawGridLines(false);
leftAxis.setDrawAxisLine(true);
final LimitLine upLine = new LimitLine(0.9F, "Great");
upLine.setLineWidth(2F);
upLine.enableDashedLine(10F, 10F, 10F);
upLine.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_TOP);
upLine.setLineColor(ContextCompat.getColor(this, R.color.divider));
upLine.setTextColor(ContextCompat.getColor(this, R.color.green$1));
final LimitLine downLine = new LimitLine(0.5F, "Bad");
downLine.setLineWidth(2F);
downLine.enableDashedLine(10F, 10F, 10F);
downLine.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_BOTTOM);
downLine.setLineColor(ContextCompat.getColor(this, R.color.divider));
downLine.setTextColor(ContextCompat.getColor(this, R.color.pink_$1));
leftAxis.addLimitLine(upLine);
leftAxis.addLimitLine(downLine);
}
示例5: init
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyle) {
getDescription().setEnabled(false);
LimitLine llXAxis = new LimitLine(10f, "Index 10");
llXAxis.setLineWidth(4f);
llXAxis.enableDashedLine(10f, 10f, 0f);
llXAxis.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_BOTTOM);
llXAxis.setTextSize(10f);
XAxis xAxis = getXAxis();
// xAxis.enableGridDashedLine(10f, 10f, 0f);
xAxis.setDrawGridLines(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextColor(Color.GRAY);
LimitLine ll1 = new LimitLine(80f, "Avg");
ll1.setLineWidth(1f);
ll1.enableDashedLine(10f, 10f, 0f);
ll1.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_TOP);
ll1.setTextSize(10f);
YAxis leftAxis = getAxisLeft();
leftAxis.removeAllLimitLines();
leftAxis.addLimitLine(ll1);
leftAxis.setAxisMaximum(160f);
leftAxis.setAxisMinimum(0f);
leftAxis.setDrawGridLines(false);
leftAxis.setDrawZeroLine(false);
leftAxis.setTextColor(Color.GRAY);
leftAxis.setDrawLimitLinesBehindData(true);
getAxisRight().setEnabled(false);
Legend l = getLegend();
l.setForm(Legend.LegendForm.LINE);
}
示例6: setupChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
/**
* Setup chart (axis, grid, etc.).
*
* @param lineChart chart to setup.
* @param data chart with the data.
* @param firstTimestamp seconds timestamp of the first record (used as initial reference).
*/
private void setupChart(LineChart lineChart, LineData data, long firstTimestamp) {
// General setup
lineChart.setDrawGridBackground(false);
lineChart.setDrawBorders(false);
lineChart.setViewPortOffsets(50, 0, 50, 50);
lineChart.getDescription().setEnabled(false);
lineChart.getLegend().setEnabled(false);
lineChart.setTouchEnabled(false);
lineChart.setNoDataText(context.getString(R.string.no_flight_act_data_available));
// X axis setup
IAxisValueFormatter xAxisFormatter = new HourAxisValueFormatter(firstTimestamp);
XAxis xAxis = lineChart.getXAxis();
xAxis.setValueFormatter(xAxisFormatter);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setCenterAxisLabels(false);
xAxis.setTextColor(ContextCompat.getColor(context, R.color.colorIcons));
// Y axis setup
YAxis yAxis = lineChart.getAxisLeft();
yAxis.setAxisMaximum(40);
yAxis.setAxisMinimum(0);
yAxis.setDrawLabels(false);
yAxis.setDrawAxisLine(false);
yAxis.setDrawGridLines(true);
lineChart.getAxisRight().setEnabled(false);
// Add data
lineChart.setData(data);
}
示例7: configureWeatherChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
/**
* Configure styles of weather charts.
*
* @param entries chart data.
* @param formatter value formatter.
* @param minVal min value to show.
* @param maxVal max value to show.
* @return chart formatted.
*/
private LineDataSet configureWeatherChart(
LineChart chart, int chartName, int colorLineTempChart, int colorFillTempChart,
List<Entry> entries, IAxisValueFormatter formatter, double minVal, double maxVal) {
LineDataSet lineDataSet = new LineDataSet(entries, getString(chartName));
lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
lineDataSet.setDrawValues(false);
lineDataSet.setValueTextSize(10f);
lineDataSet.setDrawCircles(false);
lineDataSet.setLineWidth(1.8f);
lineDataSet.setColor(ContextCompat.getColor(getContext(), colorLineTempChart));
lineDataSet.setLineWidth(2f);
lineDataSet.setDrawFilled(true);
lineDataSet.setFillColor(ContextCompat.getColor(getContext(), colorFillTempChart));
lineDataSet.setFillAlpha(255);
// General setup
chart.setDrawGridBackground(false);
chart.setDrawBorders(false);
chart.setViewPortOffsets(0, 0, 0, 0);
chart.getDescription().setEnabled(false);
chart.getLegend().setEnabled(false);
chart.setTouchEnabled(false);
// X axis setup
XAxis xAxis = chart.getXAxis();
xAxis.setEnabled(false);
xAxis.setAxisMinimum(0);
xAxis.setAxisMaximum(lastTimestamp);
// Y axis setup
YAxis leftAxis = chart.getAxisLeft();
leftAxis.setEnabled(false);
leftAxis.setAxisMaximum((float) (maxVal));
leftAxis.setAxisMinimum((float) (minVal));
YAxis rightAxis = chart.getAxisRight();
rightAxis.setAxisMaximum((float) (maxVal));
rightAxis.setAxisMinimum((float) (minVal));
rightAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
rightAxis.setValueFormatter(formatter);
return lineDataSet;
}
示例8: onCreate
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的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_sinus);
mSinusData = FileUtils.loadBarEntriesFromAssets(getAssets(), "othersine.txt");
tvX = (TextView) findViewById(R.id.tvValueCount);
mSeekBarX = (SeekBar) findViewById(R.id.seekbarValues);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
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);
// draw shadows for each bar that show the maximum value
// mChart.setDrawBarShadow(true);
// mChart.setDrawXLabels(false);
mChart.setDrawGridBackground(false);
// mChart.setDrawYLabels(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
leftAxis.setLabelCount(6, false);
leftAxis.setAxisMinimum(-2.5f);
leftAxis.setAxisMaximum(2.5f);
leftAxis.setGranularityEnabled(true);
leftAxis.setGranularity(0.1f);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setTypeface(mTfLight);
rightAxis.setLabelCount(6, false);
rightAxis.setAxisMinimum(-2.5f);
rightAxis.setAxisMaximum(2.5f);
rightAxis.setGranularity(0.1f);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarX.setProgress(150); // set data
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
l.setForm(LegendForm.SQUARE);
l.setFormSize(9f);
l.setTextSize(11f);
l.setXEntrySpace(4f);
mChart.animateXY(2000, 2000);
}
示例9: onCreate
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_realtime_linechart);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
// enable description text
mChart.getDescription().setEnabled(true);
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setDrawGridBackground(false);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(true);
// set an alternative background color
mChart.setBackgroundColor(Color.LTGRAY);
LineData data = new LineData();
data.setValueTextColor(Color.WHITE);
// add empty data
mChart.setData(data);
// get the legend (only possible after setting data)
Legend l = mChart.getLegend();
// modify the legend ...
l.setForm(LegendForm.LINE);
l.setTypeface(mTfLight);
l.setTextColor(Color.WHITE);
XAxis xl = mChart.getXAxis();
xl.setTypeface(mTfLight);
xl.setTextColor(Color.WHITE);
xl.setDrawGridLines(false);
xl.setAvoidFirstLastClipping(true);
xl.setEnabled(true);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
leftAxis.setTextColor(Color.WHITE);
leftAxis.setAxisMaximum(100f);
leftAxis.setAxisMinimum(0f);
leftAxis.setDrawGridLines(true);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
}
示例10: onCreate
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的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);
}
示例11: onCreate
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_radarchart_noseekbar);
TextView tv = (TextView) findViewById(R.id.textView);
tv.setTypeface(mTfLight);
tv.setTextColor(Color.WHITE);
tv.setBackgroundColor(Color.rgb(60, 65, 82));
mChart = (RadarChart) findViewById(R.id.chart1);
mChart.setBackgroundColor(Color.rgb(60, 65, 82));
mChart.getDescription().setEnabled(false);
mChart.setWebLineWidth(1f);
mChart.setWebColor(Color.LTGRAY);
mChart.setWebLineWidthInner(1f);
mChart.setWebColorInner(Color.LTGRAY);
mChart.setWebAlpha(100);
// create a custom MarkerView (extend MarkerView) and specify the layout
// to use for it
MarkerView mv = new RadarMarkerView(this, R.layout.radar_markerview);
mv.setChartView(mChart); // For bounds control
mChart.setMarker(mv); // Set the marker to the chart
setData();
mChart.animateXY(
1400, 1400,
Easing.EasingOption.EaseInOutQuad,
Easing.EasingOption.EaseInOutQuad);
XAxis xAxis = mChart.getXAxis();
xAxis.setTypeface(mTfLight);
xAxis.setTextSize(9f);
xAxis.setYOffset(0f);
xAxis.setXOffset(0f);
xAxis.setValueFormatter(new IAxisValueFormatter() {
private String[] mActivities = new String[]{"Burger", "Steak", "Salad", "Pasta", "Pizza"};
@Override
public String getFormattedValue(float value, AxisBase axis) {
return mActivities[(int) value % mActivities.length];
}
});
xAxis.setTextColor(Color.WHITE);
YAxis yAxis = mChart.getYAxis();
yAxis.setTypeface(mTfLight);
yAxis.setLabelCount(5, false);
yAxis.setTextSize(9f);
yAxis.setAxisMinimum(0f);
yAxis.setAxisMaximum(80f);
yAxis.setDrawLabels(false);
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
l.setTypeface(mTfLight);
l.setXEntrySpace(7f);
l.setYEntrySpace(5f);
l.setTextColor(Color.WHITE);
}
示例12: setUpBarChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void setUpBarChart() {
BarData barData = generateBarData(project.getTimeSpent());
XAxis xAxis = barChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setAxisLineColor(Color.WHITE);
xAxis.setTextColor(Color.WHITE);
xAxis.setDrawGridLines(false);
xAxis.setGranularity(1f);
xAxis.setValueFormatter(new FormatUtils().getBarXAxisValueFormatterInstance(referenceTime));
xAxis.setAxisLineWidth(2f);
YAxis leftAxis = barChart.getAxisLeft();
leftAxis.removeAllLimitLines();
leftAxis.setDrawGridLines(false);
leftAxis.setAxisLineColor(Color.WHITE);
leftAxis.setTextColor(Color.WHITE);
leftAxis.setGranularity(60 * 60);
leftAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
int hours = (int) TimeUnit.SECONDS.toHours((long) Math.ceil(value));
return (hours == 0)
? "" : context.getString(R.string.hours, hours);
}
});
leftAxis.setAxisLineWidth(2f);
int maxYData = (int) (Math.ceil(barData.getYMax()) + 3600);
leftAxis.setAxisMaximum(maxYData);
leftAxis.setAxisMinimum(0f);
CustomMarkerView customMarkerView = new CustomMarkerView(context, R.layout.marker_view, referenceTime);
barChart.setMarker(customMarkerView);
barChart.getAxisRight().setEnabled(false);
barChart.getLegend().setEnabled(false);
barChart.getDescription().setEnabled(false);
barChart.setBackground(context.getResources().getDrawable(R.color.colorPrimaryDark));
barChart.setDrawGridBackground(false);
barChart.setDragEnabled(false);
barChart.setScaleEnabled(false);
barChart.setDragDecelerationEnabled(false);
barChart.setPinchZoom(false);
barChart.setDoubleTapToZoomEnabled(false);
barChart.setDrawBorders(false);
barChart.setData(barData);
customMarkerView.setChartView(barChart);
barChart.setVisibility(View.VISIBLE);
barChart.animateY(1500, Easing.EasingOption.Linear);
}
示例13: setUpBarChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void setUpBarChart(int dailyGoal, List<Integer> progressSoFar) {
BarData barData = generateBarData(dailyGoal, progressSoFar);
//Set up a limit line indicating the goal
LimitLine limitLine = new LimitLine(dailyGoal * 60 * 60, context.getString(R.string.goal));
limitLine.setLineWidth(4f);
limitLine.setLineColor(blue400);
limitLine.setTextSize(12f);
limitLine.setTextColor(Color.WHITE);
//Format Xaxis
XAxis xAxis = goalBarChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
xAxis.setAxisLineColor(Color.WHITE);
xAxis.setTextColor(Color.WHITE);
xAxis.setGranularity(1f);
xAxis.setValueFormatter(new FormatUtils().getBarXAxisValueFormatterInstance(referenceTime));
xAxis.setAxisLineWidth(2f);
//Format Yaxis
YAxis leftAxis = goalBarChart.getAxisLeft();
leftAxis.removeAllLimitLines();
leftAxis.addLimitLine(limitLine);
leftAxis.setDrawGridLines(false);
leftAxis.setAxisLineColor(Color.WHITE);
leftAxis.setTextColor(Color.WHITE);
leftAxis.setGranularity(60 * 60);
leftAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
/* Do not display zero value and format the value as time*/
return (value == 0)
? "" : FormatUtils.getFormattedTime(context, (int) value);
}
});
leftAxis.setAxisLineWidth(2f);
//Set a maximum value on purpose so that marker view is visible
int maximum;
int maxYData = (int) TimeUnit.SECONDS.toHours((long) Math.ceil(barData.getYMax()));
maximum = (maxYData > dailyGoal) ? maxYData : dailyGoal;
maximum += 2;
leftAxis.setAxisMaximum(maximum * 60 * 60);
leftAxis.setAxisMinimum(0f);
// Setup a marker view to display details of the selected dataItem
CustomMarkerView customMarkerView = new CustomMarkerView(context, R.layout.marker_view, referenceTime);
goalBarChart.setMarker(customMarkerView);
// Disable interactions
goalBarChart.getAxisRight().setEnabled(false);
goalBarChart.getLegend().setEnabled(false);
goalBarChart.getDescription().setEnabled(false);
goalBarChart.setBackgroundColor(windowColor);
goalBarChart.setDrawGridBackground(false);
goalBarChart.setDragEnabled(false);
goalBarChart.setScaleEnabled(false);
goalBarChart.setDragDecelerationEnabled(false);
goalBarChart.setPinchZoom(false);
goalBarChart.setDoubleTapToZoomEnabled(false);
goalBarChart.setDrawBorders(false);
goalBarChart.setData(barData);
customMarkerView.setChartView(goalBarChart);
goalBarChart.setVisibility(View.VISIBLE);
goalBarChart.animateY(1500, Easing.EasingOption.Linear);
}
示例14: initChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void initChart() {
// init chart
mChart.getDescription().setEnabled(false);
mChart.setTouchEnabled(true);
mChart.setDragDecelerationFrictionCoef(0.9f);
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setDrawGridBackground(false);
mChart.setHighlightPerDragEnabled(true);
mChart.setBackground(getActivity().getDrawable(R.drawable.bg_chart));
mChart.setViewPortOffsets(80f, 0f, 80f, 0f);
setData();
mChart.invalidate();
mChart.getLegend().setEnabled(false);
// init xAxis
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
xAxis.setDrawAxisLine(false);
xAxis.setTextSize(10f);
xAxis.setTextColor(Color.rgb(255, 192, 56));
xAxis.setDrawGridLines(true);
xAxis.setCenterAxisLabels(false);
xAxis.setDrawGridLines(false);
xAxis.setEnabled(false);
xAxis.setGranularityEnabled(true);
YAxis yAxis = mChart.getAxisLeft();
yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
yAxis.setTextColor(ColorTemplate.getHoloBlue());
yAxis.setDrawGridLines(true);
yAxis.setGranularityEnabled(true);
yAxis.setAxisMinimum(50f);
yAxis.setAxisMaximum(130f);
yAxis.setYOffset(-9f);
yAxis.setXOffset(-20f);
yAxis.setTextColor(Color.rgb(255, 192, 56));
yAxis.setDrawAxisLine(false);
yAxis.setDrawGridLines(false);
mChart.getAxisRight().setEnabled(false);
}
示例15: onCreateView
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_voice_db_record_db, container, false);
mDBTextView = (TextView) view.findViewById(R.id.record_db_fragment_db_tv);
mDurationTimeView = (TextView) view.findViewById(R.id.record_db_fragment_duration_tv);
mAverageTextView = (TextView) view.findViewById(R.id.record_db_fragment_average_tv);
mMaxTextView = (TextView) view.findViewById(R.id.record_db_fragment_max_tv);
mBtn = (Button) view.findViewById(R.id.record_db_fragment_switch_btn);
mBtn.setOnClickListener(this);
mLineChart = (LineChart) view.findViewById(R.id.record_db_fragment_info_lc);
mLineChart.setOnChartValueSelectedListener(this);
// 设置表描述为不可见
mLineChart.getDescription().setEnabled(false);
// 设置表描述可见,颜色值以及显示的文本
// mLineChart.getDescription().setEnabled(true);
// mLineChart.getDescription().setText(getString(R.string.db));
// mLineChart.getDescription().setTextColor(Color.WHITE);
// enable touch gestures
mLineChart.setTouchEnabled(true);
// enable scaling and dragging
mLineChart.setDragEnabled(true);
mLineChart.setScaleEnabled(true);
mLineChart.setDrawGridBackground(false);
// if disabled, scaling can be done on x- and y-axis separately
mLineChart.setPinchZoom(true);
// set an alternative background color
mLineChart.setBackgroundColor(Color.parseColor("#6A1B9A") );
LineData data = new LineData();
data.setValueTextColor(Color.WHITE);
// add empty data
mLineChart.setData(data);
// get the legend (only possible after setting data)
Legend l = mLineChart.getLegend();
// modify the legend ...
l.setForm(Legend.LegendForm.LINE);
//l.setTypeface(mTfLight);
l.setTextColor(Color.WHITE);
// 获得图表的x轴
XAxis xAxis = mLineChart.getXAxis();
// 设置x轴的文本颜色为白色
xAxis.setTextColor(Color.WHITE);
// 不设置纵向的网格线,即与x轴垂直的线
xAxis.setDrawGridLines(false);
// 避免图表剪辑的边缘是屏幕
xAxis.setAvoidFirstLastClipping(true);
// 设置x轴可见
xAxis.setEnabled(true);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
YAxis leftYAxis = mLineChart.getAxisLeft();
leftYAxis.setTextColor(Color.WHITE);
leftYAxis.setAxisMaximum(100f);
leftYAxis.setAxisMinimum(0f);
leftYAxis.setDrawGridLines(true);
// 获取右y轴并将其设置为可见
YAxis rightYAxis = mLineChart.getAxisRight();
rightYAxis.setEnabled(true);
rightYAxis.setDrawGridLines(false);
// 设置与背景颜色相同使文本不可见
rightYAxis.setTextColor(Color.parseColor("#6A1B9A"));
addEntry(UserInfo.getInt(getContext(),"AverageDb"));
return view;
}