本文整理汇总了Java中com.github.mikephil.charting.components.YAxis.removeAllLimitLines方法的典型用法代码示例。如果您正苦于以下问题:Java YAxis.removeAllLimitLines方法的具体用法?Java YAxis.removeAllLimitLines怎么用?Java YAxis.removeAllLimitLines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.components.YAxis
的用法示例。
在下文中一共展示了YAxis.removeAllLimitLines方法的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: updateTargetArea
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void updateTargetArea() {
YAxis leftAxis = mPlot.getAxisLeft();
leftAxis.removeAllLimitLines();
LimitLine limitLineMax = new LimitLine(
GLUCOSE_TARGET_MAX
);
limitLineMax.setLineColor(Color.TRANSPARENT);
leftAxis.addLimitLine(limitLineMax);
LimitLine limitLineMin = new LimitLine(
GLUCOSE_TARGET_MIN,
getResources().getString(R.string.pref_glucose_target_area)
);
limitLineMin.setTextSize(10f);
limitLineMin.setLineColor(Color.argb(60, 100, 100, 120));
limitLineMin.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_TOP);
leftAxis.addLimitLine(limitLineMin);
}
示例3: setup
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
/**
* 设置字体
*
* @param chart
*/
protected void setup(Chart<?> chart) {
mTy = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
chart.setDescription("");
chart.setNoDataTextDescription("You need to provide data for the chart.");
chart.setTouchEnabled(true);
if (chart instanceof BarLineChartBase) {
BarLineChartBase mChart = (BarLineChartBase) chart;
mChart.setDrawGridBackground(false);
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setPinchZoom(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines
leftAxis.setTypeface(mTy);
leftAxis.setTextSize(8f);
leftAxis.setTextColor(Color.WHITE);
XAxis xAxis = mChart.getXAxis();
xAxis.setLabelRotationAngle(-50);//设置x轴字体显示角度
xAxis.setTypeface(mTy);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextSize(8f);
xAxis.setTextColor(Color.WHITE);
mChart.getAxisRight().setEnabled(false);
}
}
示例4: setup
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
protected void setup(Chart<?> chart) {
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
// no description text
chart.getDescription().setEnabled(false);
// enable touch gestures
chart.setTouchEnabled(true);
if (chart instanceof BarLineChartBase) {
BarLineChartBase mChart = (BarLineChartBase) chart;
mChart.setDrawGridBackground(false);
// 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);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines
leftAxis.setTypeface(mTf);
leftAxis.setTextSize(8f);
leftAxis.setTextColor(Color.DKGRAY);
leftAxis.setValueFormatter(new PercentFormatter());
XAxis xAxis = mChart.getXAxis();
xAxis.setTypeface(mTf);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextSize(8f);
xAxis.setTextColor(Color.DKGRAY);
mChart.getAxisRight().setEnabled(false);
}
}
示例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: setup
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
protected void setup(Chart<?> chart) {
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
// no description text
chart.setDescription("");
chart.setNoDataTextDescription("You need to provide data for the chart.");
// enable touch gestures
chart.setTouchEnabled(true);
if (chart instanceof BarLineChartBase) {
BarLineChartBase mChart = (BarLineChartBase) chart;
mChart.setDrawGridBackground(false);
// 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);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines
leftAxis.setTypeface(mTf);
leftAxis.setTextSize(8f);
leftAxis.setTextColor(Color.WHITE);
// leftAxis.setValueFormatter(new PercentFormatter());
XAxis xAxis = mChart.getXAxis();
xAxis.setLabelRotationAngle(-50);//设置x轴字体显示角度
xAxis.setTypeface(mTf);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextSize(8f);
xAxis.setTextColor(Color.WHITE);
mChart.getAxisRight().setEnabled(false);
}
}
示例7: setup
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
protected void setup(Chart<?> chart) {
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
// no description text
chart.setDescription("");
chart.setNoDataTextDescription("You need to provide data for the chart.");
// enable touch gestures
chart.setTouchEnabled(true);
if (chart instanceof BarLineChartBase) {
BarLineChartBase mChart = (BarLineChartBase) chart;
mChart.setDrawGridBackground(false);
// 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);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines
leftAxis.setTypeface(mTf);
leftAxis.setTextSize(8f);
leftAxis.setTextColor(Color.DKGRAY);
leftAxis.setValueFormatter(new PercentFormatter());
XAxis xAxis = mChart.getXAxis();
xAxis.setTypeface(mTf);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextSize(8f);
xAxis.setTextColor(Color.DKGRAY);
mChart.getAxisRight().setEnabled(false);
}
}
示例8: addEntries
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void addEntries() {
mTotalStepsChart.setSingleEntryYValue(mSteps.getTotalSteps());
YAxis stepsPerMinuteCurrentYAxis = mStepsPerMinuteCurrentChart.getAxisLeft();
int maxStepsPerMinute = mSteps.getMaxStepsPerMinute();
LimitLine target = new LimitLine(maxStepsPerMinute);
stepsPerMinuteCurrentYAxis.removeAllLimitLines();
stepsPerMinuteCurrentYAxis.addLimitLine(target);
int stepsPerMinute = mSteps.getStepsPerMinute(true);
mStepsPerMinuteCurrentChart.setSingleEntryYValue(stepsPerMinute);
if (!addHistoryDataSet(false)) {
return;
}
ChartData data = mStepsPerMinuteHistoryChart.getData();
data.addXValue("");
if (stepsPerMinute < 0) {
stepsPerMinute = 0;
}
mHistorySet.addEntry(new Entry(stepsPerMinute, data.getXValCount() - 1));
int hr = getCurrentHeartRate();
if (hr < 0) {
hr = 0;
}
mHeartRateSet.addEntry(new Entry(hr, data.getXValCount() - 1));
}
示例9: 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);
}
示例10: 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);
}
示例11: setupChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的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();
}
示例12: updateLastScanChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
public void updateLastScanChart() {
SharedPreferences sharedPrefs = PreferenceManager
.getDefaultSharedPreferences(this.getApplicationContext());
ImageView iv_unit;
iv_unit = (ImageView)findViewById(R.id.iv_unit);
if(sharedPrefs.getString("pref_unit", "mg/dl").equals("mg/dl")) {
iv_unit.setImageResource(R.drawable.unit_mgdl);
}else{
iv_unit.setImageResource(R.drawable.unit_mmoll);
}
LineChart cv_LastScan = (LineChart) findViewById(R.id.cv_LastScan);
if(sharedPrefs.getBoolean("pref_nightmode", false)) {
cv_LastScan.setBackgroundColor(getResources().getColor(R.color.colorBackgroundDark));
}else{
cv_LastScan.setBackgroundColor(getResources().getColor(R.color.colorBackgroundLight));
}
LineData getData = cv_LastScan.getData();
if(getData != null) {
YAxis yAxisLeft = cv_LastScan.getAxisLeft();
yAxisLeft.removeAllLimitLines();
yAxisLeft.setDrawLimitLinesBehindData(true);
yAxisLeft.resetAxisMaxValue();
if (cv_LastScan.getData() != null && !sharedPrefs.getString("pref_default_range", "0.0").equals("")) {
if (cv_LastScan.getData().getDataSets().get(0).getYMax() < Float.valueOf(sharedPrefs.getString("pref_default_range", "0.0"))) { //Todo: platz für highlight
yAxisLeft.setAxisMaxValue(Float.valueOf(sharedPrefs.getString("pref_default_range", "0.0")));
}
}
LimitLine ll_max = new LimitLine(Float.valueOf(sharedPrefs.getString("pref_zb_max", "-100.0")), getResources().getString(R.string.pref_zb_max));
ll_max.setLineWidth(4f);
ll_max.setTextSize(12f);
LimitLine ll_min = new LimitLine(Float.valueOf(sharedPrefs.getString("pref_zb_min", "-100.0")), getResources().getString(R.string.pref_zb_min));
ll_min.setLineWidth(4f);
ll_min.setTextSize(12f);
ll_min.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_BOTTOM);
Legend legend = cv_LastScan.getLegend();
legend.setEnabled(false);
// set an alternative background color
if (sharedPrefs.getBoolean("pref_nightmode", false)) {
ll_max.setLineColor(getResources().getColor(R.color.colorZielbereichDark));
ll_max.setTextColor(getResources().getColor(R.color.colorZielbereichDark));
ll_min.setLineColor(getResources().getColor(R.color.colorZielbereichDark));
ll_min.setTextColor(getResources().getColor(R.color.colorZielbereichDark));
} else {
ll_max.setLineColor(getResources().getColor(R.color.colorZielbereichLight));
ll_max.setTextColor(getResources().getColor(R.color.colorZielbereichLight));
ll_min.setLineColor(getResources().getColor(R.color.colorZielbereichLight));
ll_min.setTextColor(getResources().getColor(R.color.colorZielbereichLight));
}
yAxisLeft.addLimitLine(ll_max);
yAxisLeft.addLimitLine(ll_min);
cv_LastScan.notifyDataSetChanged();
cv_LastScan.invalidate();
}
}
示例13: refresh
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
public void refresh() {
SharedPreferences sharedPrefs = PreferenceManager
.getDefaultSharedPreferences(view.getContext().getApplicationContext());
ImageView iv_unit;
iv_unit = (ImageView)view.findViewById(R.id.iv_unit);
if(sharedPrefs.getString("pref_unit", "mg/dl").equals("mg/dl")) {
iv_unit.setImageResource(R.drawable.unit_mgdl);
}else{
iv_unit.setImageResource(R.drawable.unit_mmoll);
}
LineChart cv_LastScan = (LineChart) view.findViewById(R.id.cv_LastScan);
YAxis yAxisLeft = cv_LastScan.getAxisLeft();
yAxisLeft.removeAllLimitLines();
LimitLine ll_max = new LimitLine(Float.valueOf(sharedPrefs.getString("pref_zb_max", "-100.0")), getResources().getString(R.string.pref_zb_max));
ll_max.setLineWidth(4f);
ll_max.setTextSize(12f);
LimitLine ll_min = new LimitLine(Float.valueOf(sharedPrefs.getString("pref_zb_min", "-100.0")), getResources().getString(R.string.pref_zb_min));
ll_min.setLineWidth(4f);
ll_min.setTextSize(12f);
ll_min.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_BOTTOM);
Legend legend = cv_LastScan.getLegend();
legend.setEnabled(false);
// set an alternative background color
if(sharedPrefs.getBoolean("pref_nightmode", false)) {
cv_LastScan.setBackgroundColor(getResources().getColor(R.color.colorBackgroundDark));
ll_max.setLineColor(getResources().getColor(R.color.colorZielbereichDark));
ll_max.setTextColor(getResources().getColor(R.color.colorZielbereichDark));
ll_min.setLineColor(getResources().getColor(R.color.colorZielbereichDark));
ll_min.setTextColor(getResources().getColor(R.color.colorZielbereichDark));
}else{
cv_LastScan.setBackgroundColor(getResources().getColor(R.color.colorBackgroundLight));
ll_max.setLineColor(getResources().getColor(R.color.colorZielbereichLight));
ll_max.setTextColor(getResources().getColor(R.color.colorZielbereichLight));
ll_min.setLineColor(getResources().getColor(R.color.colorZielbereichLight));
ll_min.setTextColor(getResources().getColor(R.color.colorZielbereichLight));
}
yAxisLeft.addLimitLine(ll_max);
yAxisLeft.addLimitLine(ll_min);
/* if(cv_LastScan.getData() != null) {
if( cv_LastScan.getData().getDataSets().get(0).getYMax() < Float.valueOf(sharedPrefs.getString("pref_default_range", "0.0"))) {
yAxisLeft.setAxisMaxValue(Float.valueOf(sharedPrefs.getString("pref_default_range", "0.0")));
}
}*/
ArrayList<Entry> yVals = new ArrayList<Entry>();
yVals.add(new Entry(Float.valueOf(sharedPrefs.getString("pref_zb_max", "-100.0")), 0));
yVals.add(new Entry(Float.valueOf(sharedPrefs.getString("pref_zb_max", "-100.0")), cv_LastScan.getXAxis().getValues().size() - 1));
LineDataSet setarea = new LineDataSet(yVals, "area");
setarea.setLineWidth(4f);
setarea.setDrawCircleHole(false);
setarea.setDrawCircles(false);
setarea.setDrawValues(false);
setarea.setDrawCubic(false);
setarea.setDrawHighlightIndicators(false);
ArrayList<LineDataSet> areaSets = new ArrayList<LineDataSet>();
areaSets.add(setarea); // add the datasets
// create a data object with the datasets
if(cv_LastScan.getXAxis().getValues().size() > 2) {
LineData ld_area = new LineData(cv_LastScan.getXAxis().getValues(), areaSets);
cv_LastScan.setData(ld_area);
}
}
示例14: initChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
public void initChart() {
mChart.setDescription("");
mChart.setDragEnabled(false);
mChart.setScaleEnabled(false);
mChart.setPinchZoom(false);
GraphMarkerView markerView = new GraphMarkerView(mChart.getContext(), R.layout.trackdota_graph_marker);
mChart.setMarkerView(markerView);
mChart.setHighlightEnabled(false);
XAxis xAxis = mChart.getXAxis();
xAxis.removeAllLimitLines();
xAxis.setDrawLimitLinesBehindData(true);
xAxis.setDrawGridLines(true);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.removeAllLimitLines();
leftAxis.setStartAtZero(false);
LimitLine limitLine = new LimitLine(0f);
limitLine.setLineColor(Color.WHITE);
limitLine.setLineWidth(2f);
leftAxis.addLimitLine(limitLine);
mChart.setBackgroundColor(Color.BLACK);
mChart.setDrawBorders(false);
mChart.getLegend().setEnabled(false);
mChart.setDoubleTapToZoomEnabled(false);
mChart.setDrawGridBackground(false);
leftAxis.setValueFormatter(new ValueFormatter() {
@Override
public String getFormattedValue(float value) {
return String.valueOf((int) value);
}
});
leftAxis.setTextColor(Color.WHITE);
mChart.getAxisRight().setEnabled(false);
//mChart.animateX(2500);
clearChart();
}
示例15: SetupChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
public void SetupChart() {
lineChart = (LineChart) myLayout.findViewById(R.id.chart);
lineChart.setDescription("");
lineChart.setDrawBorders(false);
lineChart.setNoDataTextDescription("You need to provide data for the chart.");
lineChart.setDrawGridBackground(false);
lineChart.setOnChartValueSelectedListener(this);
lineChart.setTouchEnabled(true);
lineChart.setDragEnabled(false);
lineChart.setPinchZoom(false);
lineChart.setScaleXEnabled(true);
lineChart.setScaleYEnabled(true);
lineChart.invalidate();
LineData data = new LineData();
data.setValueTextColor(Color.WHITE);
// add empty data
lineChart.setData(data);
// get the legend (only possible after setting data)
Legend l = lineChart.getLegend();
l.setEnabled(false);
// x axis setup
XAxis xl = lineChart.getXAxis();
xl.setTextColor(Color.WHITE);
xl.setDrawGridLines(false);
xl.setAvoidFirstLastClipping(false);
xl.setSpaceBetweenLabels(3);
xl.setEnabled(true);
xl.setDrawAxisLine(false);
xl.removeAllLimitLines();
//right y axis setup
YAxis rightAxis = lineChart.getAxisRight();
rightAxis.setEnabled(false);
//left y axis setup
YAxis leftAxis = lineChart.getAxisLeft();
leftAxis.setTextColor(Color.WHITE);
leftAxis.setLabelCount(6, true);
leftAxis.setAxisMaxValue(400f);
leftAxis.setAxisMinValue(0f);
leftAxis.setDrawGridLines(false);
leftAxis.setStartAtZero(false);
leftAxis.setEnabled(true);
leftAxis.setDrawAxisLine(false);
leftAxis.setDrawZeroLine(false);
leftAxis.setGranularityEnabled(false);
//define min max line
LimitLine max = new LimitLine(150f);
max.enableDashedLine(10f, 10f, 0f);
LimitLine min = new LimitLine(50f);
min.enableDashedLine(10f, 10f, 0f);
// reset all limit lines to avoid overlapping lines
leftAxis.removeAllLimitLines();
//add min max line
leftAxis.addLimitLine(max);
leftAxis.addLimitLine(min);
lineChart.invalidate();
}