本文整理汇总了Java中com.github.mikephil.charting.components.YAxis.setLabelCount方法的典型用法代码示例。如果您正苦于以下问题:Java YAxis.setLabelCount方法的具体用法?Java YAxis.setLabelCount怎么用?Java YAxis.setLabelCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.components.YAxis
的用法示例。
在下文中一共展示了YAxis.setLabelCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupYAxis
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void setupYAxis()
{
int valuesSelectedItemPos = cache.getValuesSpinner().getSelectedItemPosition();
YAxis leftAxis = this.chart.getAxisLeft();
leftAxis.setLabelCount(10, false);
leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setSpaceTop(20f);
leftAxis.setAxisMinValue(0f);
leftAxis.setValueFormatter(new PFAYAxisLabels(context, valuesSelectedItemPos, cache.getNumberScale()));
if ( valuesSelectedItemPos == StatisticsQuery.QUANTITY )
{
leftAxis.setGranularity(1f); // interval 1
}
YAxis rightAxis = this.chart.getAxisRight();
rightAxis.setEnabled(false);
}
示例2: setLineChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
/**
* Set the line chart pattern
* @param lineChart chart
* @param chartData pie chart data
* @param month data
* @param typeface Typeface font
*/
public static void setLineChart(Context context, LineChart lineChart, ChartData<?> chartData,
final String[] month, Typeface typeface) {
// apply styling
lineChart.getDescription().setEnabled(false);
lineChart.setDrawGridBackground(false);
// create a custom MarkerView (extend MarkerView) and specify the layout to use for it
SalaryMarker marker = new SalaryMarker(context, R.layout.marker_salary_detail);
marker.setChartView(lineChart); // For bounds control
lineChart.setMarker(marker);
//fix crash com.github.mikephil.charting.charts.Chart.drawMarkers(Chart.java:731)
lineChart.setDrawMarkers(false);
XAxis xAxis = lineChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTypeface(typeface);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(true);
xAxis.setValueFormatter(new LineChartValueFormatter(month));
xAxis.setLabelCount(month.length / 2, true);//xAxis label count
YAxis leftAxis = lineChart.getAxisLeft();
leftAxis.setTypeface(typeface);
leftAxis.setLabelCount(9, false);
leftAxis.setAxisMinimum(0f);
YAxis rightAxis = lineChart.getAxisRight();
rightAxis.setTypeface(typeface);
rightAxis.setDrawGridLines(false);
rightAxis.setAxisMinimum(0f);
Legend l = lineChart.getLegend();
l.setWordWrapEnabled(true);
l.setTypeface(typeface);
l.setFormSize(14f);
l.setTextSize(9f);
lineChart.setData((LineData) chartData);
lineChart.animateX(DURATION_SHORT);
}
示例3: initHeartRateChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void initHeartRateChart(LineChart mChart) {
mChart.setViewPortOffsets(0, 0, 0, 0);
mChart.setBackgroundColor(getResources().getColor(R.color.gold_pressed));
mChart.setDescription("Heart Rate");
mChart.setTouchEnabled(true);
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
mChart.setMaxHighlightDistance(300);
XAxis xAxis = mChart.getXAxis();
xAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
xAxis.setTextSize(11f);
xAxis.setTextColor(Color.WHITE);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false);
YAxis y = mChart.getAxisLeft();
y.setTypeface(BandApplication.INSTANCE.getTfLight());
y.setLabelCount(6, false);
y.setTextColor(Color.RED);
y.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
y.setDrawGridLines(false);
y.setAxisLineColor(Color.WHITE);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
y.setLabelCount(6, false);
y.setTextColor(Color.RED);
y.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
y.setDrawGridLines(false);
y.setAxisLineColor(Color.WHITE);
mChart.getLegend().setEnabled(false);
mChart.animateXY(2000, 2000);
}
示例4: setupChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void setupChart() {
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
mChart.setMaxVisibleValueCount(60);
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
xAxis.setSpaceBetweenLabels(2);
YAxisValueFormatter custom = new PercentFormatter();
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setLabelCount(8, false);
leftAxis.setValueFormatter(custom);
leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setSpaceTop(15f);
leftAxis.setAxisMinValue(0f);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setLabelCount(8, false);
rightAxis.setValueFormatter(custom);
rightAxis.setSpaceTop(15f);
rightAxis.setAxisMinValue(0f);
Legend legend = mChart.getLegend();
legend.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
legend.setForm(Legend.LegendForm.CIRCLE);
legend.setFormSize(9f);
legend.setTextSize(11f);
legend.setXEntrySpace(4f);
mChart.animateXY(1000, 1000);
}
示例5: getView
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
BarData data = getItem(position);
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(getContext()).inflate(
R.layout.list_item_barchart, null);
holder.chart = (BarChart) convertView.findViewById(R.id.chart);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// apply styling
data.setValueTypeface(mTfLight);
data.setValueTextColor(Color.BLACK);
holder.chart.getDescription().setEnabled(false);
holder.chart.setDrawGridBackground(false);
XAxis xAxis = holder.chart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTfLight);
xAxis.setDrawGridLines(false);
YAxis leftAxis = holder.chart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
leftAxis.setLabelCount(5, false);
leftAxis.setSpaceTop(15f);
YAxis rightAxis = holder.chart.getAxisRight();
rightAxis.setTypeface(mTfLight);
rightAxis.setLabelCount(5, false);
rightAxis.setSpaceTop(15f);
// set data
holder.chart.setData(data);
holder.chart.setFitBars(true);
// do not forget to refresh the chart
// holder.chart.invalidate();
holder.chart.animateY(700);
return convertView;
}
示例6: 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);
}
示例7: 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);
}
示例8: getView
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, Context c) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(c).inflate(
R.layout.list_item_linechart, null);
holder.chart = (LineChart) convertView.findViewById(R.id.chart);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// apply styling
// holder.chart.setValueTypeface(mTf);
holder.chart.getDescription().setEnabled(false);
holder.chart.setDrawGridBackground(false);
XAxis xAxis = holder.chart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(true);
YAxis leftAxis = holder.chart.getAxisLeft();
leftAxis.setTypeface(mTf);
leftAxis.setLabelCount(5, false);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
YAxis rightAxis = holder.chart.getAxisRight();
rightAxis.setTypeface(mTf);
rightAxis.setLabelCount(5, false);
rightAxis.setDrawGridLines(false);
rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
// set data
holder.chart.setData((LineData) mChartData);
// do not forget to refresh the chart
// holder.chart.invalidate();
holder.chart.animateX(750);
return convertView;
}
示例9: getView
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, Context c) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(c).inflate(
R.layout.list_item_barchart, null);
holder.chart = (BarChart) convertView.findViewById(R.id.chart);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// apply styling
holder.chart.getDescription().setEnabled(false);
holder.chart.setDrawGridBackground(false);
holder.chart.setDrawBarShadow(false);
XAxis xAxis = holder.chart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(true);
YAxis leftAxis = holder.chart.getAxisLeft();
leftAxis.setTypeface(mTf);
leftAxis.setLabelCount(5, false);
leftAxis.setSpaceTop(20f);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
YAxis rightAxis = holder.chart.getAxisRight();
rightAxis.setTypeface(mTf);
rightAxis.setLabelCount(5, false);
rightAxis.setSpaceTop(20f);
rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
mChartData.setValueTypeface(mTf);
// set data
holder.chart.setData((BarData) mChartData);
holder.chart.setFitBars(true);
// do not forget to refresh the chart
// holder.chart.invalidate();
holder.chart.animateY(700);
return convertView;
}
示例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_candlechart);
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 = (CandleStickChart) findViewById(R.id.chart1);
mChart.setBackgroundColor(Color.WHITE);
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.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
YAxis leftAxis = mChart.getAxisLeft();
// leftAxis.setEnabled(false);
leftAxis.setLabelCount(7, false);
leftAxis.setDrawGridLines(false);
leftAxis.setDrawAxisLine(false);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
// rightAxis.setStartAtZero(false);
// setting data
mSeekBarX.setProgress(40);
mSeekBarY.setProgress(100);
mChart.getLegend().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_linechart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarX.setProgress(45);
mSeekBarY.setProgress(100);
mSeekBarY.setOnSeekBarChangeListener(this);
mSeekBarX.setOnSeekBarChangeListener(this);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setViewPortOffsets(0, 0, 0, 0);
mChart.setBackgroundColor(Color.rgb(104, 241, 175));
// no description text
mChart.getDescription().setEnabled(false);
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
mChart.setMaxHighlightDistance(300);
XAxis x = mChart.getXAxis();
x.setEnabled(false);
YAxis y = mChart.getAxisLeft();
y.setTypeface(mTfLight);
y.setLabelCount(6, false);
y.setTextColor(Color.WHITE);
y.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
y.setDrawGridLines(false);
y.setAxisLineColor(Color.WHITE);
mChart.getAxisRight().setEnabled(false);
// add data
setData(45, 100);
mChart.getLegend().setEnabled(false);
mChart.animateXY(2000, 2000);
// dont forget to refresh the drawing
mChart.invalidate();
}
示例12: getView
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, Context c) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(c).inflate(
R.layout.list_item_linechart, null);
holder.chart = (LineChart) convertView.findViewById(R.id.chart);
holder.tvX = (TextView) convertView.findViewById(R.id.tvXMax);
convertView.setTag(holder);
convertView.setBackgroundResource(R.color.white);
} else {
holder = (ViewHolder) convertView.getTag();
}
// apply styling
// holder.chart.setValueTypeface(mTf);
holder.chart.getDescription().setEnabled(false);
holder.chart.setDrawGridBackground(false);
if(position == 0) holder.tvX.setText("vel_max : " + String.valueOf(maxValue));
if(position == 1) holder.tvX.setText("dis_max : " + String.valueOf(maxValue));
XAxis xAxis = holder.chart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(true);
xAxis.setDrawAxisLine(true);
//xAxis.setTextColor(Color.WHITE);
YAxis leftAxis = holder.chart.getAxisLeft();
leftAxis.setLabelCount(5, false);
//leftAxis.setTextColor(Color.WHITE);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
YAxis rightAxis = holder.chart.getAxisRight();
rightAxis.setLabelCount(5, false);
//rightAxis.setTextColor(Color.WHITE);
rightAxis.setDrawGridLines(false);
rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
// set data
holder.chart.setData((LineData) mChartData);
// do not forget to refresh the chart
// holder.chart.invalidate();
holder.chart.animateX(750);
return convertView;
}
示例13: init
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyle) {
setDrawBarShadow(false);
setDrawValueAboveBar(true);
getDescription().setEnabled(false);
setMaxVisibleValueCount(60);
setDrawGridBackground(false);
XAxis xAxis = getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
xAxis.setGranularity(1f);
xAxis.setLabelCount(7);
xAxis.setTextColor(Color.GRAY);
YAxis leftAxis = getAxisLeft();
leftAxis.setDrawGridLines(false);
leftAxis.setLabelCount(8, false);
leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setSpaceTop(15f);
leftAxis.setAxisMinimum(0f);
leftAxis.setTextColor(Color.GRAY);
YAxis rightAxis = getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setDrawAxisLine(false);
rightAxis.setLabelCount(8, false);
rightAxis.setDrawLabels(false);
rightAxis.setSpaceTop(15f);
rightAxis.setAxisMinimum(0f);
Legend l = getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
l.setForm(Legend.LegendForm.SQUARE);
l.setFormSize(9f);
l.setTextSize(11f);
l.setXEntrySpace(4f);
}
示例14: onCreate
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_coin_detail);
// overridePendingTransition(R.anim.right_in, R.anim.stay);
initToolbar("Coin Details", R.drawable.ic_back_arrow);
initUserAction("", 0, false);
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
coinTag = bundle.getString(Constants.COIN_TAG, "");
coinName = bundle.getString(Constants.COIN_NAME, "");
}
tvCoinName.setText(coinName);
mChart = (LineChart) findViewById(R.id.chart);
// mChart.setPadding(4,4,4,4);
// FIXME calculate offset for right
mChart.setViewPortOffsets(6, 30, 90, 60);
// no description text
mChart.getDescription().setEnabled(false);
mChart.setNoDataText("");
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
mChart.setMaxHighlightDistance(300);
XAxis x = mChart.getXAxis();
x.setTextColor(ContextCompat.getColor(this, R.color.colorText));
x.setPosition(XAxis.XAxisPosition.BOTTOM);
x.setAxisLineColor(Color.TRANSPARENT);
x.setDrawGridLines(false);
x.setAxisLineWidth(0f);
x.setGranularity(1f);
x.setValueFormatter(new MyXAxisValueFormatter());
x.setLabelRotationAngle(315);
YAxis y = mChart.getAxisRight();
// y.setTypeface();
y.setLabelCount(6, false);
y.setTextColor(ContextCompat.getColor(this, R.color.colorText));
y.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
y.setDrawGridLines(true);
y.setAxisLineColor(Color.TRANSPARENT);
y.setAxisLineWidth(0f);
y.setValueFormatter(new MyYAxisValueFormatter());
mChart.getAxisLeft().setEnabled(false);
// add data
getCoinDetails(coinTag);
// setData(45, 100);
mChart.getLegend().setEnabled(false);
mChart.animateX(1500);
// dont forget to refresh the drawing
// mChart.invalidate();
}
示例15: 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_coin_details);
initToolbar("Coin Graph", 0);
mChart = (LineChart) findViewById(R.id.chart);
mChart.setBackgroundColor(Color.TRANSPARENT);
// no description text
mChart.getDescription().setEnabled(false);
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
mChart.setMaxHighlightDistance(300);
XAxis x = mChart.getXAxis();
x.setTextColor(Color.RED);
x.setPosition(XAxis.XAxisPosition.BOTTOM);
x.setAxisLineColor(Color.BLUE);
x.setDrawGridLines(false);
x.setAxisLineWidth(2f);
YAxis y = mChart.getAxisRight();
// y.setTypeface();
y.setLabelCount(6, false);
y.setTextColor(Color.RED);
y.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
y.setDrawGridLines(false);
y.setAxisLineColor(Color.BLUE);
y.setAxisLineWidth(2f);
mChart.getAxisLeft().setEnabled(false);
// add data
setData(45, 100);
mChart.getLegend().setEnabled(false);
mChart.animateX(1000);
// dont forget to refresh the drawing
mChart.invalidate();
// TODO Testing
if (mChart.getData() != null) {
mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
mChart.invalidate();
}
}