本文整理汇总了Java中com.github.mikephil.charting.components.LimitLine.setTextSize方法的典型用法代码示例。如果您正苦于以下问题:Java LimitLine.setTextSize方法的具体用法?Java LimitLine.setTextSize怎么用?Java LimitLine.setTextSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.components.LimitLine
的用法示例。
在下文中一共展示了LimitLine.setTextSize方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: setHightLimitLine
import com.github.mikephil.charting.components.LimitLine; //导入方法依赖的package包/类
/**
* 设置高限制线
*
* @param high
* @param name
*/
public void setHightLimitLine(float high, String name, int color) {
if (name == null) {
name = "高限制线";
}
LimitLine hightLimit = new LimitLine(high, name);
hightLimit.setLineWidth(4f);
hightLimit.setTextSize(10f);
hightLimit.setLineColor(color);
hightLimit.setTextColor(color);
leftAxis.addLimitLine(hightLimit);
mBarChart.invalidate();
}
示例4: setLowLimitLine
import com.github.mikephil.charting.components.LimitLine; //导入方法依赖的package包/类
/**
* 设置低限制线
*
* @param low
* @param name
*/
public void setLowLimitLine(int low, String name) {
if (name == null) {
name = "低限制线";
}
LimitLine hightLimit = new LimitLine(low, name);
hightLimit.setLineWidth(4f);
hightLimit.setTextSize(10f);
leftAxis.addLimitLine(hightLimit);
mBarChart.invalidate();
}
示例5: 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);
}
示例6: 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;
}
示例7: addLimitLine
import com.github.mikephil.charting.components.LimitLine; //导入方法依赖的package包/类
/**
* Adds a LimitLine to the given chart.
*
* @param chart LineChart
* @param value value for the LimitLine
* @param format decimal format
*/
private void addLimitLine(LineChart chart, float value, String format) {
LimitLine ll = new LimitLine(value);
ll.setLabel(String.format(format, value));
ll.setLineColor(ContextCompat.getColor(getContext(), R.color.text87));
ll.setLineWidth(0.2f);
ll.setTextSize(11);
ll.setTextColor(ContextCompat.getColor(getContext(), R.color.text87));
YAxis leftAxis = chart.getAxisLeft();
leftAxis.addLimitLine(ll);
leftAxis.setDrawLimitLinesBehindData(true);
}
示例8: setUpBarChart
import com.github.mikephil.charting.components.LimitLine; //导入方法依赖的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);
}
示例9: 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();
}
}
示例10: 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);
}
}
示例11: setLineChartStylingAndRefreshChart
import com.github.mikephil.charting.components.LimitLine; //导入方法依赖的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();
}
示例12: 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();
}