本文整理匯總了Java中com.github.mikephil.charting.components.Legend.setEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java Legend.setEnabled方法的具體用法?Java Legend.setEnabled怎麽用?Java Legend.setEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.mikephil.charting.components.Legend
的用法示例。
在下文中一共展示了Legend.setEnabled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: prepareLegend
import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
/**
* Create a legend based on a dummy chart. The legend
* is used by all charts and is positioned
* across the top of the screen.
* @param data - CombinedData used to generate the legend
*/
private void prepareLegend(final CombinedData data){
//The dummy chart is never shown, but it's legend is.
final CombinedChart dummyChart = (CombinedChart) mRoot.findViewById(R.id.legend);
dummyChart.getPaint(Chart.PAINT_DESCRIPTION).setTextAlign(Paint.Align.CENTER);
dummyChart.getXAxis().setEnabled(false);
dummyChart.getAxisRight().setEnabled(false);
dummyChart.getAxisLeft().setEnabled(false);
final Description description = new Description();
description.setText("");
description.setTextSize(10f);
dummyChart.setDescription(description);
dummyChart.setBackgroundColor(Color.WHITE);
dummyChart.setDrawGridBackground(false);
dummyChart.setData(data);
final Legend l = dummyChart.getLegend();
l.setEnabled(true);
// The positioning of the legend effectively
// hides the dummy chart from view.
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
dummyChart.invalidate();
}
示例2: customizePieChart
import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
private void customizePieChart() {
pieChart.setUsePercentValues(true);
pieChart.setDescription(" ");
pieChart.setDrawHoleEnabled(true);
pieChart.setHoleColor(Color.TRANSPARENT);
pieChart.setHoleRadius(15);
pieChart.setTransparentCircleRadius(20);
pieChart.setRotationAngle(0);
pieChart.setRotationEnabled(true);
pieChart.animateY(2000);
pieChart.setCenterTextSize(12);
pieChart.setCenterTextColor(ContextCompat.getColor(getContext(), R.color.colorGraphite));
pieChart.setDrawSliceText(false);
Legend l = pieChart.getLegend();
l.setEnabled(false);
}
示例3: onCreate
import com.github.mikephil.charting.components.Legend; //導入方法依賴的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_noseekbar);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setBackgroundColor(Color.WHITE);
mChart.setGridBackgroundColor(mFillColor);
mChart.setDrawGridBackground(true);
mChart.setDrawBorders(true);
// no description text
mChart.getDescription().setEnabled(false);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
Legend l = mChart.getLegend();
l.setEnabled(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setAxisMaximum(900f);
leftAxis.setAxisMinimum(-250f);
leftAxis.setDrawAxisLine(false);
leftAxis.setDrawZeroLine(false);
leftAxis.setDrawGridLines(false);
mChart.getAxisRight().setEnabled(false);
// add data
setData(100, 60);
mChart.invalidate();
}
示例4: setData
import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
private void setData(int count, float range) {
ArrayList<Entry> yVals = new ArrayList<Entry>();
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(i * 0.001f, val));
}
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
set1.setColor(Color.BLACK);
set1.setLineWidth(0.5f);
set1.setDrawValues(false);
set1.setDrawCircles(false);
set1.setMode(LineDataSet.Mode.LINEAR);
set1.setDrawFilled(false);
// create a data object with the datasets
LineData data = new LineData(set1);
// set data
mChart.setData(data);
// get the legend (only possible after setting data)
Legend l = mChart.getLegend();
l.setEnabled(false);
}
示例5: initBatteryChart
import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
private void initBatteryChart() {
mBatteryChart = findViewById(R.id.batteryPieChart);
// configure pie chart
mBatteryChart.setUsePercentValues(true);
mBatteryChart.setDescription(new Description());
// enable hole and configure
mBatteryChart.setDrawHoleEnabled(true);
Legend legend = mBatteryChart.getLegend();
legend.setEnabled(false);
}
示例6: configChart
import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
private void configChart(Station station, PieChart mChart) {
mChart.setDescription("");
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
mChart.setCenterText(getString(R.string.base_state));
mChart.setDrawHoleEnabled(true);
mChart.setHoleColorTransparent(true);
mChart.setUsePercentValues(false);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setTouchEnabled(false);
mChart.setRotationEnabled(false);
mChart.setRotationAngle(0);
setData(mChart, station);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
// mChart.spin(2000, 0, 360);
Legend l = mChart.getLegend();
l.setEnabled(false);
l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
}
示例7: setPieChart
import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
/**
* Set the pie pattern
* @param pieChart chart
* @param chartData pie chart data
* @param title chart title
* @param tf Typeface font
*/
public static void setPieChart(PieChart pieChart, ChartData<?> chartData,
SpannableString title, Typeface tf) {
chartData.setValueFormatter(new PercentFormatter());
chartData.setValueTextSize(11f);
chartData.setValueTextColor(Color.BLACK);
chartData.setValueTypeface(tf);
pieChart.setUsePercentValues(true);
pieChart.getDescription().setEnabled(false);
pieChart.setExtraOffsets(5, 10, 5, 5);
pieChart.setDragDecelerationFrictionCoef(0.95f);
pieChart.setCenterTextTypeface(tf);
pieChart.setCenterText(title);
pieChart.setExtraOffsets(20.f, 0.f, 20.f, 0.f);
pieChart.setDrawHoleEnabled(true);
pieChart.setHoleColor(Color.WHITE);
pieChart.setTransparentCircleColor(Color.WHITE);
pieChart.setTransparentCircleAlpha(110);
pieChart.setHoleRadius(58f);
pieChart.setTransparentCircleRadius(61f);
pieChart.setDrawCenterText(true);
pieChart.setRotationAngle(0);
pieChart.setRotationEnabled(true);// enable rotation of the chart by touch
pieChart.setHighlightPerTapEnabled(true);
pieChart.setEntryLabelTextSize(10f);
Legend l = pieChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setEnabled(false);
pieChart.setData((PieData) chartData);
pieChart.animateY(DURATION_MEDIUM, Easing.EasingOption.EaseInOutQuad);
pieChart.highlightValues(null);// undo all highlights
pieChart.invalidate();
}
示例8: initLineChart
import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
/**
* 初始化LineChart
*/
private void initLineChart() {
//設置支持觸控
mBarChart.setTouchEnabled(true); // 設置是否可以觸摸
mBarChart.setDragEnabled(false);// 是否可以拖拽
mBarChart.setScaleEnabled(false);// 是否可以縮放
mBarChart.setBackgroundColor(Color.WHITE);//背景顏色
mBarChart.setDrawGridBackground(false); //網格
mBarChart.setDrawBarShadow(false);//背景陰影
mBarChart.setHighlightFullBarEnabled(false);//設置高光
mBarChart.setDrawBorders(false);//顯示邊界
mBarChart.getXAxis().setDrawGridLines(false);//是否顯示豎直標尺線
mBarChart.getAxisLeft().setDrawGridLines(false);//是否顯示橫直標尺線
mBarChart.getAxisRight().setEnabled(false);//是否顯示最右側豎線
mBarChart.setDescription(null);
//設置動畫效果
mBarChart.animateY(1000, Easing.EasingOption.Linear);
mBarChart.animateX(1000, Easing.EasingOption.Linear);
//折線圖例 標簽 設置
Legend legend = mBarChart.getLegend();
legend.setForm(Legend.LegendForm.LINE);
legend.setTextSize(11f);
//顯示位置
legend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
legend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
legend.setOrientation(Legend.LegendOrientation.HORIZONTAL);
legend.setDrawInside(false);
legend.setEnabled(false);
//XY軸的設置
//X軸設置顯示位置在底部
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setGranularity(1f);
//保證Y軸從0開始,不然會上移一點
leftAxis.setAxisMinimum(0f);
rightAxis.setAxisMinimum(0f);
}
示例9: setData
import com.github.mikephil.charting.components.Legend; //導入方法依賴的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<Entry>();
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.setColor(Color.BLACK);
set1.setLineWidth(0.5f);
set1.setDrawValues(false);
set1.setDrawCircles(false);
set1.setDrawCubic(false);
set1.setDrawFilled(false);
// create a data object with the datasets
LineData data = new LineData(xVals, set1);
// set data
mChart.setData(data);
// get the legend (only possible after setting data)
Legend l = mChart.getLegend();
l.setEnabled(false);
}
示例10: initializeChart
import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
private void initializeChart() {
chart.setUsePercentValues(true);
chart.getDescription().setEnabled(false);
chart.setDragDecelerationFrictionCoef(0.95f);
chart.setCenterText(generateCenterSpannableText());
chart.setExtraOffsets(15.f, 15.f, 15.f, 15.f);
chart.setDrawHoleEnabled(true);
chart.setHoleColor(Color.WHITE);
chart.setTransparentCircleColor(Color.WHITE);
chart.setTransparentCircleAlpha(110);
chart.setHoleRadius(58f);
chart.setTransparentCircleRadius(61f);
chart.setDrawCenterText(true);
chart.setRotationAngle(0);
// enable rotation of the chart by touch
chart.setRotationEnabled(true);
chart.setHighlightPerTapEnabled(true);
// add a selection listener
chart.setOnChartValueSelectedListener(this);
Legend l = chart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
l.setEnabled(true);
}
示例11: getFormattedPieChart
import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
/**
* Formats a pie chart in a standardized way
* @param c Context
* @param p Pie chart
* @param shouldShowLegend
* @return the PieChart, whose data must be set and invalidated
*/
public static PieChart getFormattedPieChart(Context c, PieChart p, boolean shouldShowLegend) {
Legend cLegend = p.getLegend();
if (shouldShowLegend) {
cLegend.setEnabled(true);
cLegend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
cLegend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
cLegend.setOrientation(Legend.LegendOrientation.HORIZONTAL);
cLegend.setDrawInside(false);
cLegend.setForm(Legend.LegendForm.CIRCLE);
cLegend.setTextSize(15);
cLegend.setWordWrapEnabled(true);
} else {
cLegend.setEnabled(false);
}
p.setDrawEntryLabels(false);
p.setDescription(EMPTY_CHART_DESCRIPTION);
p.setHoleRadius(60f);
p.setTransparentCircleRadius(65f);
p.setCenterTextSize(20);
if (SettingsActivity.getTheme(c) == SettingsActivity.THEME_NOIR) {
int colorPrimaryNoir = ContextCompat.getColor(c, R.color.colorPrimaryNoir);
int colorPrimaryTextNoir = ContextCompat.getColor(c, R.color.colorPrimaryTextNoir);
p.setHoleColor(colorPrimaryNoir);
p.setTransparentCircleColor(colorPrimaryNoir);
p.setCenterTextColor(colorPrimaryTextNoir);
cLegend.setTextColor(colorPrimaryTextNoir);
}
p.setRotationEnabled(false);
p.setOnChartValueSelectedListener(new PieChartListener(p));
return p;
}
示例12: getFormattedLineChart
import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
/**
* Formats a line chart in a standardized manner
* @param c App context
* @param chart LineChart to format
* @param listener Listener to attach to chart
* @param xLabels Labels to use for the x-axis
* @param valueFormatter True if large value formatter should be used
* @param skip Number of values to skip
* @param legend True if show legend, false if hide legend
* @return Formatted linechart
*/
public static LineChart getFormattedLineChart(Context c, LineChart chart, OnChartValueSelectedListener listener, List<String> xLabels, boolean valueFormatter, int skip, boolean legend) {
Legend cLegend = chart.getLegend();
cLegend.setEnabled(legend);
XAxis xAxis = chart.getXAxis();
xAxis.setGranularity(skip);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setValueFormatter(new XAxisLabelFormatter(xLabels));
YAxis yAxisRight = chart.getAxisRight();
yAxisRight.setEnabled(false);
YAxis yAxisLeft = chart.getAxisLeft();
if (valueFormatter) {
yAxisLeft.setValueFormatter(new LargeNumberAxisFormatter(c));
}
if (SettingsActivity.getTheme(c) == SettingsActivity.THEME_NOIR) {
int textColorNoir = ContextCompat.getColor(c, R.color.colorPrimaryTextNoir);
cLegend.setTextColor(textColorNoir);
xAxis.setTextColor(textColorNoir);
yAxisLeft.setTextColor(textColorNoir);
}
chart.setDoubleTapToZoomEnabled(false);
chart.setDescription(EMPTY_CHART_DESCRIPTION);
chart.setDragEnabled(true);
chart.setScaleYEnabled(false);
chart.setDrawGridBackground(false);
chart.setOnChartValueSelectedListener(listener);
return chart;
}
示例13: initChart
import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
/**
* 初始化圖表
*
* @param chart 原始圖表
* @return 初始化後的圖表
*/
public static LineChart initChart(LineChart chart) {
// 不顯示數據描述
chart.getDescription().setEnabled(false);
// 沒有數據的時候,顯示“暫無數據”
chart.setNoDataText("暫無數據");
// 不顯示表格顏色
chart.setDrawGridBackground(false);
// 不可以縮放
chart.setScaleEnabled(false);
// 不顯示y軸右邊的值
chart.getAxisRight().setEnabled(false);
// 不顯示圖例
Legend legend = chart.getLegend();
legend.setEnabled(false);
// 向左偏移15dp,抵消y軸向右偏移的30dp
chart.setExtraLeftOffset(-15);
XAxis xAxis = chart.getXAxis();
// 不顯示x軸
xAxis.setDrawAxisLine(false);
// 設置x軸數據的位置
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextColor(Color.WHITE);
xAxis.setTextSize(12);
xAxis.setGridColor(Color.parseColor("#30FFFFFF"));
// 設置x軸數據偏移量
xAxis.setYOffset(-12);
YAxis yAxis = chart.getAxisLeft();
// 不顯示y軸
yAxis.setDrawAxisLine(false);
// 設置y軸數據的位置
yAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
// 不從y軸發出橫向直線
yAxis.setDrawGridLines(false);
yAxis.setTextColor(Color.WHITE);
yAxis.setTextSize(12);
// 設置y軸數據偏移量
yAxis.setXOffset(30);
yAxis.setYOffset(-3);
yAxis.setAxisMinimum(0);
//Matrix matrix = new Matrix();
// x軸縮放1.5倍
//matrix.postScale(1.5f, 1f);
// 在圖表動畫顯示之前進行縮放
//chart.getViewPortHandler().refresh(matrix, chart, false);
// x軸執行動畫
//chart.animateX(2000);
chart.invalidate();
return chart;
}
示例14: setupChart
import com.github.mikephil.charting.components.Legend; //導入方法依賴的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);
}
示例15: onCreate
import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_piechart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setProgress(10);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (PieChart) findViewById(R.id.chart1);
mChart.setUsePercentValues(true);
mChart.getDescription().setEnabled(false);
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
mChart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));
mChart.setCenterText(generateCenterSpannableText());
mChart.setExtraOffsets(20.f, 0.f, 20.f, 0.f);
mChart.setDrawHoleEnabled(true);
mChart.setHoleColor(Color.WHITE);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setRotationAngle(0);
// enable rotation of the chart by touch
mChart.setRotationEnabled(true);
mChart.setHighlightPerTapEnabled(true);
// mChart.setUnit(" €");
// mChart.setDrawUnitsInChart(true);
// add a selection listener
mChart.setOnChartValueSelectedListener(this);
setData(4, 100);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
// mChart.spin(2000, 0, 360);
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setEnabled(false);
}