本文整理汇总了Java中com.github.mikephil.charting.components.LimitLine.setLabelPosition方法的典型用法代码示例。如果您正苦于以下问题:Java LimitLine.setLabelPosition方法的具体用法?Java LimitLine.setLabelPosition怎么用?Java LimitLine.setLabelPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.components.LimitLine
的用法示例。
在下文中一共展示了LimitLine.setLabelPosition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateTargetArea
import com.github.mikephil.charting.components.LimitLine; //导入方法依赖的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.LimitLine; //导入方法依赖的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.LimitLine; //导入方法依赖的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: drawWaveformChart
import com.github.mikephil.charting.components.LimitLine; //导入方法依赖的package包/类
private void drawWaveformChart() {
final short[] wave = AudioTest.getRecordedWave();
List<Entry> entries = new ArrayList<>();
int frameRate = audioTest.getOptimalFrameRate();
for (int i = 0; i < wave.length; i++) {
float timeStamp = (float) i / frameRate * 1000f;
entries.add(new Entry(timeStamp, (float) wave[i]));
}
LineDataSet dataSet = new LineDataSet(entries, "Waveform");
dataSet.setColor(Color.BLACK);
dataSet.setValueTextColor(Color.BLACK);
dataSet.setCircleColor(ContextCompat.getColor(getContext(), R.color.DarkGreen));
dataSet.setCircleRadius(1.5f);
dataSet.setCircleColorHole(Color.DKGRAY);
LineData lineData = new LineData(dataSet);
chart.setData(lineData);
LimitLine line = new LimitLine(audioTest.getThreshold(), "Threshold");
line.setLineColor(Color.RED);
line.setLabelPosition(LimitLine.LimitLabelPosition.LEFT_TOP);
line.setLineWidth(2f);
line.setTextColor(Color.DKGRAY);
line.setTextSize(10f);
chart.getAxisLeft().addLimitLine(line);
final Description desc = new Description();
desc.setText("Wave [digital level -32768 to +32767] vs. Time [ms]");
desc.setTextSize(12f);
chart.setDescription(desc);
chart.getLegend().setEnabled(false);
chart.invalidate();
chartLayout.setVisibility(View.VISIBLE);
}
示例5: getChartLimitLine
import com.github.mikephil.charting.components.LimitLine; //导入方法依赖的package包/类
private LimitLine getChartLimitLine(float value, String label) {
LimitLine line = new LimitLine(value, label);
float scaledDensity = getResources().getDisplayMetrics().scaledDensity;
line.setLineWidth(2f);
line.enableDashedLine(12f, 12f, 0);
line.setLabelPosition(LimitLine.LimitLabelPosition.LEFT_BOTTOM);
line.setTextSize(10 * scaledDensity);
line.setTextColor(ContextCompat.getColor(this, R.color.text));
return line;
}
示例6: updateLastScanChart
import com.github.mikephil.charting.components.LimitLine; //导入方法依赖的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();
}
}
示例7: refresh
import com.github.mikephil.charting.components.LimitLine; //导入方法依赖的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);
}
}
示例8: setData
import com.github.mikephil.charting.components.LimitLine; //导入方法依赖的package包/类
private void setData(int count, float range) {
ArrayList<String> xVals = new ArrayList<String>();
for (int i = 0; i < count; i++) {
xVals.add((i) + "");
}
ArrayList<Entry> yVals = new ArrayList<>();
for (int i = 0; i < count; i++) {
float mult = (range + 1);
float val = (float) (Math.random() * mult) + 3;// + (float)
// ((mult *
// 0.1) / 10);
yVals.add(new Entry(val, i));
}
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
// set1.setFillAlpha(110);
// set1.setFillColor(Color.RED);
// set the line to be drawn like this "- - - - - -"
set1.enableDashedLine(10f, 5f, 0f);
set1.setColor(Color.BLACK);
set1.setCircleColor(Color.BLACK);
set1.setLineWidth(1f);
set1.setCircleSize(4f);
set1.setFillAlpha(65);
set1.setFillColor(Color.BLACK);
// set1.setShader(new LinearGradient(0, 0, 0, mChart.getHeight(),
// Color.BLACK, Color.WHITE, Shader.TileMode.MIRROR));
ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
dataSets.add(set1); // add the datasets
// create a data object with the datasets
LineData data = new LineData(xVals, dataSets);
LimitLine ll1 = new LimitLine(130f);
ll1.setLineWidth(4f);
ll1.enableDashedLine(10f, 10f, 0f);
ll1.setLabelPosition(LimitLine.LimitLabelPosition.POS_RIGHT);
LimitLine ll2 = new LimitLine(130f);
ll2.setLineWidth(4f);
ll2.enableDashedLine(10f, 10f, 0f);
ll2.setLabelPosition(LimitLine.LimitLabelPosition.POS_RIGHT);
//YAxis.YAxisLabelPosition leftAxis = mChart.getY
// set data
mChart.setData(data);
}
示例9: setData
import com.github.mikephil.charting.components.LimitLine; //导入方法依赖的package包/类
private void setData(List<TemperatureEntry> logSessionList) {
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
int ttt = Integer.MIN_VALUE;
ArrayList<Entry> yVals = new ArrayList<>();
ArrayList<String> xVals = new ArrayList<>();
SimpleDateFormat df = new SimpleDateFormat(mDateFormat.split(" ")[1]);
for (int i = 0; i < logSessionList.size(); i++) {
TemperatureEntry temperatureEntry = logSessionList.get(i);
xVals.add(df.format(temperatureEntry.getTimestamp()));
Entry chartEntry = new Entry(logSessionList.get(i).getTemperature(), i, temperatureEntry);
yVals.add(chartEntry);
if (mLogSession.getTargetTemperature() != null &&
temperatureEntry.getTemperature() >= mLogSession.getTargetTemperature() &&
ttt == Integer.MIN_VALUE)
{
ttt = i;
}
if (temperatureEntry.getTemperature() < min) min = temperatureEntry.getTemperature();
if (temperatureEntry.getTemperature() > max) max = temperatureEntry.getTemperature();
}
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(yVals, getString(R.string.temperature));
// set1.setFillAlpha(110);
// set1.setFillColor(Color.RED);
// set the line to be drawn like this "- - - - - -"
set1.enableDashedLine(10f, 5f, 0f);
set1.setColor(Color.BLACK);
set1.setCircleColor(Color.BLACK);
set1.setLineWidth(2f);
set1.setDrawValues(false);
set1.setCircleSize(4f);
set1.setFillAlpha(65);
set1.setFillColor(Color.BLACK);
// set1.setShader(new LinearGradient(0, 0, 0, mChart.getHeight(),
// Color.BLACK, Color.WHITE, Shader.TileMode.MIRROR));
ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
dataSets.add(set1); // add the datasets
// create a data object with the datasets
LineData data = new LineData(xVals, dataSets);
YAxis leftAxis = mChart.getAxisLeft();
if (mLogSession.getTargetTemperature() != null) {
String timeToTarget = "Target temperature";
if (ttt != Integer.MIN_VALUE) {
long duration = (logSessionList.get(ttt).getTimestamp().getTime() - logSessionList.get(0).getTimestamp().getTime()) / 1000;
timeToTarget = "Time to target temperature: " + String.format("%d:%02d:%02d", duration / 3600, (duration % 3600) / 60, (duration % 60));
}
LimitLine ll1 = new LimitLine(mLogSession.getTargetTemperature(), timeToTarget);
ll1.setLineWidth(4f);
ll1.enableDashedLine(10f, 10f, 0f);
ll1.setLabelPosition(LimitLine.LimitLabelPosition.POS_RIGHT);
ll1.setTextSize(10f);
leftAxis.addLimitLine(ll1);
}
leftAxis.setStartAtZero(true);
leftAxis.setAxisMaxValue(max + 10);
leftAxis.setAxisMinValue(min-10);
mChart.getAxisRight().setEnabled(false);
// set data
mChart.setData(data);
mChart.invalidate();
}