本文整理汇总了Java中com.github.mikephil.charting.components.Legend.LegendForm类的典型用法代码示例。如果您正苦于以下问题:Java LegendForm类的具体用法?Java LegendForm怎么用?Java LegendForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LegendForm类属于com.github.mikephil.charting.components.Legend包,在下文中一共展示了LegendForm类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.github.mikephil.charting.components.Legend.LegendForm; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_barchart_sinus);
mSinusData = FileUtils.loadBarEntriesFromAssets(getAssets(), "othersine.txt");
tvX = (TextView) findViewById(R.id.tvValueCount);
mSeekBarX = (SeekBar) findViewById(R.id.seekbarValues);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.getDescription().setEnabled(false);
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
// draw shadows for each bar that show the maximum value
// mChart.setDrawBarShadow(true);
// mChart.setDrawXLabels(false);
mChart.setDrawGridBackground(false);
// mChart.setDrawYLabels(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
leftAxis.setLabelCount(6, false);
leftAxis.setAxisMinimum(-2.5f);
leftAxis.setAxisMaximum(2.5f);
leftAxis.setGranularityEnabled(true);
leftAxis.setGranularity(0.1f);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setTypeface(mTfLight);
rightAxis.setLabelCount(6, false);
rightAxis.setAxisMinimum(-2.5f);
rightAxis.setAxisMaximum(2.5f);
rightAxis.setGranularity(0.1f);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarX.setProgress(150); // set data
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
l.setForm(LegendForm.SQUARE);
l.setFormSize(9f);
l.setTextSize(11f);
l.setXEntrySpace(4f);
mChart.animateXY(2000, 2000);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:70,代码来源:BarChartActivitySinus.java
示例2: onCreate
import com.github.mikephil.charting.components.Legend.LegendForm; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_realtime_linechart);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
// enable description text
mChart.getDescription().setEnabled(true);
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setDrawGridBackground(false);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(true);
// set an alternative background color
mChart.setBackgroundColor(Color.LTGRAY);
LineData data = new LineData();
data.setValueTextColor(Color.WHITE);
// add empty data
mChart.setData(data);
// get the legend (only possible after setting data)
Legend l = mChart.getLegend();
// modify the legend ...
l.setForm(LegendForm.LINE);
l.setTypeface(mTfLight);
l.setTextColor(Color.WHITE);
XAxis xl = mChart.getXAxis();
xl.setTypeface(mTfLight);
xl.setTextColor(Color.WHITE);
xl.setDrawGridLines(false);
xl.setAvoidFirstLastClipping(true);
xl.setEnabled(true);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
leftAxis.setTextColor(Color.WHITE);
leftAxis.setAxisMaximum(100f);
leftAxis.setAxisMinimum(0f);
leftAxis.setDrawGridLines(true);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:60,代码来源:RealtimeLineChartActivity.java
示例3: onCreate
import com.github.mikephil.charting.components.Legend.LegendForm; //导入依赖的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);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarX.setProgress(45);
mSeekBarY.setProgress(100);
mSeekBarY.setOnSeekBarChangeListener(this);
mSeekBarX.setOnSeekBarChangeListener(this);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawGridBackground(false);
// no description text
mChart.getDescription().setEnabled(false);
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(true);
// set an alternative background color
// mChart.setBackgroundColor(Color.GRAY);
// create a custom MarkerView (extend MarkerView) and specify the layout
// to use for it
MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
mv.setChartView(mChart); // For bounds control
mChart.setMarker(mv); // Set the marker to the chart
XAxis xl = mChart.getXAxis();
xl.setAvoidFirstLastClipping(true);
xl.setAxisMinimum(0f);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setInverted(true);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
// add data
setData(25, 50);
// // restrain the maximum scale-out factor
// mChart.setScaleMinima(3f, 3f);
//
// // center the view to a specific position inside the chart
// mChart.centerViewPort(10, 50);
// get the legend (only possible after setting data)
Legend l = mChart.getLegend();
// modify the legend ...
l.setForm(LegendForm.LINE);
// dont forget to refresh the drawing
mChart.invalidate();
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:75,代码来源:InvertedLineChartActivity.java
示例4: onCreate
import com.github.mikephil.charting.components.Legend.LegendForm; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_barchart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
// mChart.setDrawYLabels(false);
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setSpaceBetweenLabels(2);
YAxisValueFormatter custom = new MyYAxisValueFormatter();
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTf);
leftAxis.setLabelCount(8, false);
leftAxis.setValueFormatter(custom);
leftAxis.setPosition(YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setSpaceTop(15f);
leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setTypeface(mTf);
rightAxis.setLabelCount(8, false);
rightAxis.setValueFormatter(custom);
rightAxis.setSpaceTop(15f);
rightAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.BELOW_CHART_LEFT);
l.setForm(LegendForm.SQUARE);
l.setFormSize(9f);
l.setTextSize(11f);
l.setXEntrySpace(4f);
// l.setExtra(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc",
// "def", "ghj", "ikl", "mno" });
// l.setCustom(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc",
// "def", "ghj", "ikl", "mno" });
setData(12, 50);
// setting data
mSeekBarY.setProgress(50);
mSeekBarX.setProgress(12);
mSeekBarY.setOnSeekBarChangeListener(this);
mSeekBarX.setOnSeekBarChangeListener(this);
// mChart.setDrawLegend(false);
}
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:80,代码来源:BarChartActivity.java
示例5: onCreate
import com.github.mikephil.charting.components.Legend.LegendForm; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_barchart_sinus);
mSinusData = FileUtils.loadBarEntriesFromAssets(getAssets(),"othersine.txt");
tvX = (TextView) findViewById(R.id.tvValueCount);
mSeekBarX = (SeekBar) findViewById(R.id.seekbarValues);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
// draw shadows for each bar that show the maximum value
// mChart.setDrawBarShadow(true);
// mChart.setDrawXLabels(false);
mChart.setDrawGridBackground(false);
// mChart.setDrawYLabels(false);
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTf);
leftAxis.setLabelCount(6, false);
leftAxis.setAxisMinValue(-2.5f);
leftAxis.setAxisMaxValue(2.5f);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setTypeface(mTf);
rightAxis.setLabelCount(6, false);
rightAxis.setAxisMinValue(-2.5f);
rightAxis.setAxisMaxValue(2.5f);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarX.setProgress(150); // set data
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.BELOW_CHART_LEFT);
l.setForm(LegendForm.SQUARE);
l.setFormSize(9f);
l.setTextSize(11f);
l.setXEntrySpace(4f);
mChart.animateXY(2000, 2000);
}
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:69,代码来源:BarChartActivitySinus.java
示例6: onCreate
import com.github.mikephil.charting.components.Legend.LegendForm; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_realtime_linechart);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
// no description text
mChart.setDescription("");
mChart.setNoDataTextDescription("You need to provide data for the chart.");
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setDrawGridBackground(false);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(true);
// set an alternative background color
mChart.setBackgroundColor(Color.LTGRAY);
LineData data = new LineData();
data.setValueTextColor(Color.WHITE);
// add empty data
mChart.setData(data);
Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
// get the legend (only possible after setting data)
Legend l = mChart.getLegend();
// modify the legend ...
// l.setPosition(LegendPosition.LEFT_OF_CHART);
l.setForm(LegendForm.LINE);
l.setTypeface(tf);
l.setTextColor(Color.WHITE);
XAxis xl = mChart.getXAxis();
xl.setTypeface(tf);
xl.setTextColor(Color.WHITE);
xl.setDrawGridLines(false);
xl.setAvoidFirstLastClipping(true);
xl.setSpaceBetweenLabels(5);
xl.setEnabled(true);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(tf);
leftAxis.setTextColor(Color.WHITE);
leftAxis.setAxisMaxValue(100f);
leftAxis.setAxisMinValue(0f);
leftAxis.setDrawGridLines(true);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
}
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:65,代码来源:RealtimeLineChartActivity.java
示例7: onCreate
import com.github.mikephil.charting.components.Legend.LegendForm; //导入依赖的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);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarX.setProgress(45);
mSeekBarY.setProgress(100);
mSeekBarY.setOnSeekBarChangeListener(this);
mSeekBarX.setOnSeekBarChangeListener(this);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawGridBackground(false);
// no description text
mChart.setDescription("");
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(true);
// set an alternative background color
// mChart.setBackgroundColor(Color.GRAY);
// create a custom MarkerView (extend MarkerView) and specify the layout
// to use for it
MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
// set the marker to the chart
mChart.setMarkerView(mv);
XAxis xl = mChart.getXAxis();
xl.setAvoidFirstLastClipping(true);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setInverted(true);
leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
// add data
setData(25, 50);
// // restrain the maximum scale-out factor
// mChart.setScaleMinima(3f, 3f);
//
// // center the view to a specific position inside the chart
// mChart.centerViewPort(10, 50);
// get the legend (only possible after setting data)
Legend l = mChart.getLegend();
// modify the legend ...
// l.setPosition(LegendPosition.LEFT_OF_CHART);
l.setForm(LegendForm.LINE);
// dont forget to refresh the drawing
mChart.invalidate();
}
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:76,代码来源:InvertedLineChartActivity.java
示例8: setLegend
import com.github.mikephil.charting.components.Legend.LegendForm; //导入依赖的package包/类
/**
* More details about legend customization: https://github.com/PhilJay/MPAndroidChart/wiki/Legend
*/
@ReactProp(name = "legend")
public void setLegend(T chart, ReadableMap propMap) {
Legend legend = chart.getLegend();
if (BridgeUtils.validate(propMap, ReadableType.Boolean, "enabled")) {
legend.setEnabled(propMap.getBoolean("enabled"));
}
// Styling
if (BridgeUtils.validate(propMap, ReadableType.String, "textColor")) {
legend.setTextColor(Color.parseColor(propMap.getString("textColor")));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "textSize")) {
legend.setTextSize((float) propMap.getDouble("textSize"));
}
if (BridgeUtils.validate(propMap, ReadableType.String, "fontFamily") ||
BridgeUtils.validate(propMap, ReadableType.Number, "fontStyle")) {
legend.setTypeface(BridgeUtils.parseTypeface(chart.getContext(), propMap, "fontStyle", "fontFamily"));
}
// Wrapping / clipping avoidance
if (BridgeUtils.validate(propMap, ReadableType.Boolean, "wordWrapEnabled")) {
legend.setWordWrapEnabled(propMap.getBoolean("wordWrapEnabled"));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "maxSizePercent")) {
legend.setMaxSizePercent((float) propMap.getDouble("maxSizePercent"));
}
// Customizing
if (BridgeUtils.validate(propMap, ReadableType.String, "position")) {
legend.setPosition(LegendPosition.valueOf(propMap.getString("position").toUpperCase()));
}
if (BridgeUtils.validate(propMap, ReadableType.String, "form")) {
legend.setForm(LegendForm.valueOf(propMap.getString("form").toUpperCase()));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "formSize")) {
legend.setFormSize((float) propMap.getDouble("formSize"));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "xEntrySpace")) {
legend.setXEntrySpace((float) propMap.getDouble("xEntrySpace"));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "yEntrySpace")) {
legend.setYEntrySpace((float) propMap.getDouble("yEntrySpace"));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "formToTextSpace")) {
legend.setFormToTextSpace((float) propMap.getDouble("formToTextSpace"));
}
// Custom labels & colors
if (BridgeUtils.validate(propMap, ReadableType.Map, "custom")) {
ReadableMap customMap = propMap.getMap("custom");
if (BridgeUtils.validate(customMap, ReadableType.Array, "colors") &&
BridgeUtils.validate(customMap, ReadableType.Array, "labels")) {
ReadableArray colorsArray = customMap.getArray("colors");
ReadableArray labelsArray = customMap.getArray("labels");
if (colorsArray.size() == labelsArray.size()) {
// TODO null label should start a group
// TODO -2 color should avoid drawing a form
String[] labels = BridgeUtils.convertToStringArray(labelsArray);
String[] colors = BridgeUtils.convertToStringArray(colorsArray);
int[] colorsParsed = new int[colors.length];
for (int i = 0; i < colors.length; i++) {
colorsParsed[i] = Color.parseColor(colors[i]);
}
legend.setCustom(colorsParsed, labels);
}
}
}
// TODO resetCustom function
// TODO extra
chart.invalidate(); // TODO is this necessary? Looks like enabled is not refreshing without it
}
开发者ID:mskec,项目名称:react-native-mp-android-chart,代码行数:82,代码来源:ChartBaseManager.java
注:本文中的com.github.mikephil.charting.components.Legend.LegendForm类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论