本文整理汇总了Java中com.github.mikephil.charting.components.Legend.setFormToTextSpace方法的典型用法代码示例。如果您正苦于以下问题:Java Legend.setFormToTextSpace方法的具体用法?Java Legend.setFormToTextSpace怎么用?Java Legend.setFormToTextSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.components.Legend
的用法示例。
在下文中一共展示了Legend.setFormToTextSpace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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_barchart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.getDescription().setEnabled(false);
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(40);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(false);
mChart.setHighlightFullBarEnabled(false);
// change the position of the y-labels
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setValueFormatter(new MyAxisValueFormatter());
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
mChart.getAxisRight().setEnabled(false);
XAxis xLabels = mChart.getXAxis();
xLabels.setPosition(XAxisPosition.TOP);
// mChart.setDrawXLabels(false);
// mChart.setDrawYLabels(false);
// setting data
mSeekBarX.setProgress(12);
mSeekBarY.setProgress(100);
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
l.setFormSize(8f);
l.setFormToTextSpace(4f);
l.setXEntrySpace(6f);
// mChart.setDrawLegend(false);
}
示例2: 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_barchart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
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.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(false);
// change the position of the y-labels
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setValueFormatter(new MyYAxisValueFormatter());
leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
mChart.getAxisRight().setEnabled(false);
XAxis xLabels = mChart.getXAxis();
xLabels.setPosition(XAxisPosition.TOP);
// mChart.setDrawXLabels(false);
// mChart.setDrawYLabels(false);
// setting data
mSeekBarX.setProgress(12);
mSeekBarY.setProgress(100);
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.BELOW_CHART_RIGHT);
l.setFormSize(8f);
l.setFormToTextSpace(4f);
l.setXEntrySpace(6f);
// mChart.setDrawLegend(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_age_distribution);
setTitle("Age Distribution Austria");
mChart = (HorizontalBarChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawGridBackground(false);
mChart.setDescription("");
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.getAxisLeft().setEnabled(false);
mChart.getAxisRight().setAxisMaxValue(25f);
mChart.getAxisRight().setAxisMinValue(-25f);
mChart.getAxisRight().setDrawGridLines(false);
mChart.getAxisRight().setDrawZeroLine(true);
mChart.getAxisRight().setLabelCount(7, false);
mChart.getAxisRight().setValueFormatter(new CustomFormatter());
mChart.getAxisRight().setTextSize(9f);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTH_SIDED);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false);
xAxis.setTextSize(9f);
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.BELOW_CHART_RIGHT);
l.setFormSize(8f);
l.setFormToTextSpace(4f);
l.setXEntrySpace(6f);
// IMPORTANT: When using negative values in stacked bars, always make sure the negative values are in the array first
ArrayList<BarEntry> yValues = new ArrayList<BarEntry>();
yValues.add(new BarEntry(new float[]{ -10, 10 }, 0));
yValues.add(new BarEntry(new float[]{ -12, 13 }, 1));
yValues.add(new BarEntry(new float[]{ -15, 15 }, 2));
yValues.add(new BarEntry(new float[]{ -17, 17 }, 3));
yValues.add(new BarEntry(new float[]{ -19, 20 }, 4));
yValues.add(new BarEntry(new float[]{ -19, 19 }, 5));
yValues.add(new BarEntry(new float[]{ -16, 16 }, 6));
yValues.add(new BarEntry(new float[]{ -13, 14 }, 7));
yValues.add(new BarEntry(new float[]{ -10, 11 }, 8));
yValues.add(new BarEntry(new float[]{ -5, 6 }, 9));
yValues.add(new BarEntry(new float[]{ -1, 2 }, 10));
BarDataSet set = new BarDataSet(yValues, "Age Distribution");
set.setValueFormatter(new CustomFormatter());
set.setValueTextSize(7f);
set.setAxisDependency(YAxis.AxisDependency.RIGHT);
set.setBarSpacePercent(40f);
set.setColors(new int[] {Color.rgb(67,67,72), Color.rgb(124,181,236)});
set.setStackLabels(new String[]{
"Men", "Women"
});
String []xVals = new String[]{"0-10", "10-20", "20-30", "30-40", "40-50", "50-60", "60-70", "70-80", "80-90", "90-100", "100+"};
BarData data = new BarData(xVals, set);
mChart.setData(data);
mChart.invalidate();
}
示例4: setLegend
import com.github.mikephil.charting.components.Legend; //导入方法依赖的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
}