本文整理汇总了Java中com.github.mikephil.charting.charts.LineChart.setViewPortOffsets方法的典型用法代码示例。如果您正苦于以下问题:Java LineChart.setViewPortOffsets方法的具体用法?Java LineChart.setViewPortOffsets怎么用?Java LineChart.setViewPortOffsets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.charts.LineChart
的用法示例。
在下文中一共展示了LineChart.setViewPortOffsets方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareChart
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
private void prepareChart(@NonNull LineChart chart) {
chart.getDescription().setEnabled(false);
chart.setTouchEnabled(false);
chart.setDragEnabled(false);
chart.setScaleEnabled(false);
chart.setHighlightPerDragEnabled(false);
chart.setPinchZoom(false);
chart.setDrawGridBackground(true);
chart.getLegend().setEnabled(false);
chart.getAxisRight().setEnabled(false);
chart.getAxisLeft().setEnabled(false);
chart.getXAxis().setEnabled(false);
chart.setViewPortOffsets(0, 0, 0, 0);
}
示例2: initChart
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
private void initChart(@NonNull LineChart chart) {
chart.getDescription().setEnabled(false);
chart.setTouchEnabled(false);
chart.setDragEnabled(false);
chart.setScaleEnabled(false);
chart.setHighlightPerDragEnabled(false);
chart.setPinchZoom(false);
chart.setDrawGridBackground(false);
chart.getLegend().setEnabled(false);
chart.getAxisRight().setEnabled(false);
chart.getXAxis().setEnabled(false);
chart.getAxisLeft().setEnabled(false);
chart.getXAxis().setEnabled(false);
chart.setViewPortOffsets(0, 0, 0, 0);
}
示例3: initHeartRateChart
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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.charts.LineChart; //导入方法依赖的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);
}
示例5: configureWeatherChart
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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;
}
示例6: onCreateView
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View V = inflater.inflate(R.layout.tide_fragment, container, false);
// Setup the tide chart
LineChart tideChart = (LineChart) V.findViewById(R.id.tide_chart);
tideChart.setDrawBorders(false);
tideChart.setDescription("");
tideChart.setPinchZoom(false);
tideChart.setDoubleTapToZoomEnabled(false);
tideChart.setDrawMarkerViews(false);
tideChart.setTouchEnabled(false);
tideChart.setViewPortOffsets(0f, 0f, 0f, 0f);
// X Axis
XAxis xAxis = tideChart.getXAxis();
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false);
xAxis.setDrawLabels(false);
// Y Axis
YAxis leftYAxis = tideChart.getAxisLeft();
YAxis rightYAxis = tideChart.getAxisRight();
leftYAxis.setDrawGridLines(false);
rightYAxis.setDrawGridLines(false);
leftYAxis.setDrawAxisLine(false);
rightYAxis.setDrawAxisLine(false);
leftYAxis.setDrawLabels(false);
rightYAxis.setDrawLabels(false);
leftYAxis.setDrawZeroLine(false);
rightYAxis.setDrawZeroLine(false);
// Legend
tideChart.getLegend().setEnabled(false);
return V;
}
示例7: setupChart
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
private void setupChart(LineChart chart, LineData data, int color) {
((LineDataSet) data.getDataSetByIndex(0)).setCircleColorHole(color);
// no description text
chart.getDescription().setEnabled(false);
// mChart.setDrawHorizontalGrid(false);
//
// enable / disable grid background
chart.setDrawGridBackground(false);
// chart.getRenderer().getGridPaint().setGridColor(Color.WHITE & 0x70FFFFFF);
// enable touch gestures
chart.setTouchEnabled(true);
// enable scaling and dragging
chart.setDragEnabled(true);
chart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
chart.setPinchZoom(false);
chart.setBackgroundColor(color);
// set custom chart offsets (automatic offset calculation is hereby disabled)
chart.setViewPortOffsets(10, 0, 10, 0);
// add data
chart.setData(data);
// get the legend (only possible after setting data)
Legend l = chart.getLegend();
l.setEnabled(false);
chart.getAxisLeft().setEnabled(false);
chart.getAxisLeft().setSpaceTop(40);
chart.getAxisLeft().setSpaceBottom(40);
chart.getAxisRight().setEnabled(false);
chart.getXAxis().setEnabled(false);
// animate calls invalidate()...
chart.animateX(2500);
}
示例8: onCreate
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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);
}
示例9: onCreate
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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();
}
示例10: setupChart
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
private void setupChart(LineChart chart, LineData data, int color) {
((LineDataSet) data.getDataSetByIndex(0)).setCircleColorHole(color);
chart.getDescription().setEnabled(false);
chart.setDrawGridBackground(false);
chart.setTouchEnabled(false);
chart.setDragEnabled(false);
chart.setScaleEnabled(true);
chart.setPinchZoom(false);
chart.setBackgroundColor(color);
chart.setViewPortOffsets(0, 23, 0, 0);
chart.setData(data);
Legend l = chart.getLegend();
l.setEnabled(false);
chart.getAxisLeft().setEnabled(true);
chart.getAxisLeft().setDrawGridLines(false);
chart.getAxisLeft().setDrawAxisLine(false);
chart.getAxisLeft().setSpaceTop(10);
chart.getAxisLeft().setSpaceBottom(30);
chart.getAxisLeft().setAxisLineColor(0xFFFFFF);
chart.getAxisLeft().setTextColor(0xFFFFFF);
chart.getAxisLeft().setDrawTopYLabelEntry(true);
chart.getAxisLeft().setLabelCount(10);
chart.getXAxis().setEnabled(true);
chart.getXAxis().setDrawGridLines(false);
chart.getXAxis().setDrawAxisLine(false);
chart.getXAxis().setAxisLineColor(0xFFFFFF);
chart.getXAxis().setTextColor(0xFFFFFF);
Typeface tf = Typeface.DEFAULT;
// X Axis
XAxis xAxis = chart.getXAxis();
xAxis.setTypeface(tf);
xAxis.removeAllLimitLines();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
xAxis.setTextColor(Color.argb(150, 255, 255, 255));
if (displayType == 1 || displayType == 2) // Week and Month
xAxis.setValueFormatter(new WeekXFormatter());
else if (displayType == 0) // Day
xAxis.setValueFormatter(new HourXFormatter());
else
xAxis.setValueFormatter(new YearXFormatter()); // Year
// Y Axis
YAxis leftAxis = chart.getAxisLeft();
leftAxis.removeAllLimitLines();
leftAxis.setTypeface(tf);
leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
leftAxis.setTextColor(Color.argb(150, 255, 255, 255));
leftAxis.setValueFormatter(new DontShowNegativeFormatter(displayInUsd));
chart.getAxisRight().setEnabled(false); // Deactivates horizontal lines
chart.animateX(1300);
chart.notifyDataSetChanged();
}
示例11: onCreate
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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();
}
示例12: setupChart
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
private void setupChart(LineChart chart, LineData data, int color) {
// no description text
chart.setDescription("");
chart.setNoDataTextDescription("You need to provide data for the chart.");
// mChart.setDrawHorizontalGrid(false);
//
// enable / disable grid background
chart.setDrawGridBackground(false);
// chart.getRenderer().getGridPaint().setGridColor(Color.WHITE & 0x70FFFFFF);
// enable touch gestures
chart.setTouchEnabled(true);
// enable scaling and dragging
chart.setDragEnabled(true);
chart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
chart.setPinchZoom(false);
chart.setBackgroundColor(color);
// set custom chart offsets (automatic offset calculation is hereby disabled)
chart.setViewPortOffsets(10, 0, 10, 0);
// add data
chart.setData(data);
// get the legend (only possible after setting data)
Legend l = chart.getLegend();
l.setEnabled(false);
chart.getAxisLeft().setEnabled(false);
chart.getAxisRight().setEnabled(false);
chart.getXAxis().setEnabled(false);
// animate calls invalidate()...
chart.animateX(2500);
}
示例13: onCreate
import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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, 20, 0, 0);
mChart.setBackgroundColor(Color.rgb(104, 241, 175));
// no description text
mChart.setDescription("");
// 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);
tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
XAxis x = mChart.getXAxis();
x.setEnabled(false);
YAxis y = mChart.getAxisLeft();
y.setTypeface(tf);
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();
}