本文整理汇总了Java中com.github.mikephil.charting.components.YAxis.addLimitLine方法的典型用法代码示例。如果您正苦于以下问题:Java YAxis.addLimitLine方法的具体用法?Java YAxis.addLimitLine怎么用?Java YAxis.addLimitLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.components.YAxis
的用法示例。
在下文中一共展示了YAxis.addLimitLine方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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));
}
示例5: setChartAverage
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
/**
* Needs calling chart.invalidate() afterwards
* @param chart
* @param data
* @param average
*/
private void setChartAverage(BarChart chart, DetailsData data, boolean average) {
YAxis axis = chart.getAxisRight();
if(axis.getLimitLines().size() > 0) {
//If line exists remove and make new one
//(can't simply change value, 3rd party limitation)
axis.getLimitLines().remove(0);
}
if(average) {
boolean mode = mPresenter.getMode();
LimitLine line = getChartLimitLine(data.getAverage(mode), data.getAverageLabel(mode));
axis.addLimitLine(line);
line.setEnabled(true);
}
}
示例6: 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);
}
示例7: 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();
}
}
示例8: 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);
}
}
示例9: 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();
}
示例10: 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();
}
示例11: setLineChartStylingAndRefreshChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
/**
* Set the line charts styling
*
* @param lineData the data to style
*/
private void setLineChartStylingAndRefreshChart(LineData lineData) {
// style axis
YAxis leftAxis = chart.getAxisLeft();
leftAxis.setAxisMinValue(0f);
leftAxis.setDrawGridLines(false);
leftAxis.setTextSize(15);
YAxis rightAxis = chart.getAxisRight();
rightAxis.setDrawLabels(false);
rightAxis.setDrawGridLines(false);
XAxis xAxis = chart.getXAxis();
xAxis.setDrawGridLines(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawLabels(false);
// add threshold limit line
String thresholdDescription = "";
LimitLine limitLine = new LimitLine(100f, thresholdDescription);
limitLine.setLineColor(Color.RED);
limitLine.setLineWidth(1f);
limitLine.setTextColor(Color.RED);
limitLine.setTextSize(15f);
if (leftAxis.getLimitLines().size() < 1)
leftAxis.addLimitLine(limitLine);
// add legend
Legend l = chart.getLegend();
l.setFormSize(10f);
l.setForm(Legend.LegendForm.CIRCLE);
l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
l.setTextSize(12f);
l.setTextColor(Color.BLACK);
l.setXEntrySpace(5f);
l.setYEntrySpace(5f);
String[] labels = {Strings.getStringByRId(R.string.median_performance), Strings.getStringByRId(R.string.median_performance_forecast), Strings.getStringByRId(R.string.pre_operation_performance)};
int[] colors = {ContextCompat.getColor(activity.getApplicationContext(), R.color.colorPrimary), ContextCompat.getColor(activity.getApplicationContext(), R.color.colorPrimaryLight), Color.RED};
l.setCustom(colors, labels);
// style chart and refresh
chart.setDescription("");
chart.setPinchZoom(false);
chart.setDoubleTapToZoomEnabled(false);
chart.setDrawGridBackground(false);
chart.setData(lineData);
chart.invalidate();
}