Java Code Examples for com.github.mikephil.charting.components.Legend#setYEntrySpace()
The following examples show how to use
com.github.mikephil.charting.components.Legend#setYEntrySpace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PieChartItem.java From memorize with MIT License | 4 votes |
@SuppressLint("InflateParams") @Override public View getView(int position, View convertView, Context c) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = LayoutInflater.from(c).inflate( R.layout.stats_item_piechart, null); holder.chart = convertView.findViewById(R.id.chart); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // apply styling holder.chart.getDescription().setEnabled(false); holder.chart.setHoleRadius(52f); holder.chart.setTransparentCircleRadius(57f); holder.chart.setCenterText(mCenterText); holder.chart.setCenterTextSize(9f); holder.chart.setUsePercentValues(true); holder.chart.setExtraOffsets(5, 10, 50, 10); mChartData.setValueFormatter(new PercentFormatter()); mChartData.setValueTextSize(11f); mChartData.setValueTextColor(Color.WHITE); // set data holder.chart.setData((PieData) mChartData); Legend l = holder.chart.getLegend(); l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT); l.setOrientation(Legend.LegendOrientation.VERTICAL); l.setDrawInside(false); l.setYEntrySpace(0f); l.setYOffset(0f); holder.chart.animateY(900); return convertView; }
Example 2
Source File: InventoryReportFragment.java From mobikul-standalone-pos with MIT License | 4 votes |
private void setSalesProductChart(List<SalesProductReportModel> soldProducts) { binding.productChart.setUsePercentValues(true); binding.productChart.getDescription().setEnabled(false); // binding.productChart.setExtraOffsets(5, 10, 10, 5); // holder.chart.setExtraOffsets(5, 10, 50, 10); binding.productChart.setDragDecelerationFrictionCoef(0.95f); binding.productChart.setCenterText(generateCenterSpannableText()); binding.productChart.setDrawHoleEnabled(true); binding.productChart.setHoleColor(Color.WHITE); binding.productChart.setTransparentCircleColor(Color.WHITE); binding.productChart.setTransparentCircleAlpha(90); binding.productChart.setHoleRadius(50f); binding.productChart.setTransparentCircleRadius(55f); binding.productChart.setDrawCenterText(true); binding.productChart.setRotationAngle(0); // enable rotation of the chart by touch binding.productChart.setRotationEnabled(true); binding.productChart.setHighlightPerTapEnabled(true); // binding.productChart.setUnit(" €"); // binding.productChart.setDrawUnitsInChart(true); // add a selection listener // binding.productChart.setOnChartValueSelectedListener(this); setData(soldProducts, 10); binding.productChart.animateY(1400, Easing.EasingOption.EaseInOutQuad); // binding.productChart.spin(2000, 0, 360); Legend l = binding.productChart.getLegend(); l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT); l.setOrientation(Legend.LegendOrientation.VERTICAL); l.setDrawInside(false); // l.setXEntrySpace(7f); l.setYEntrySpace(0f); l.setYOffset(0f); // entry label styling binding.productChart.setEntryLabelColor(Color.WHITE); binding.productChart.setEntryLabelTextSize(12f); }
Example 3
Source File: RadarChartActivity.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_radarchart); setTitle("RadarChartActivity"); chart = findViewById(R.id.chart1); chart.setBackgroundColor(Color.rgb(60, 65, 82)); chart.getDescription().setEnabled(false); chart.setWebLineWidth(1f); chart.setWebColor(Color.LTGRAY); chart.setWebLineWidthInner(1f); chart.setWebColorInner(Color.LTGRAY); chart.setWebAlpha(100); // create a custom MarkerView (extend MarkerView) and specify the layout // to use for it MarkerView mv = new RadarMarkerView(this, R.layout.radar_markerview); mv.setChartView(chart); // For bounds control chart.setMarker(mv); // Set the marker to the chart setData(); chart.animateXY(1400, 1400, Easing.EaseInOutQuad); XAxis xAxis = chart.getXAxis(); xAxis.setTypeface(tfLight); xAxis.setTextSize(9f); xAxis.setYOffset(0f); xAxis.setXOffset(0f); xAxis.setValueFormatter(new ValueFormatter() { private final String[] mActivities = new String[]{"Burger", "Steak", "Salad", "Pasta", "Pizza"}; @Override public String getFormattedValue(float value) { return mActivities[(int) value % mActivities.length]; } }); xAxis.setTextColor(Color.WHITE); YAxis yAxis = chart.getYAxis(); yAxis.setTypeface(tfLight); yAxis.setLabelCount(5, false); yAxis.setTextSize(9f); yAxis.setAxisMinimum(0f); yAxis.setAxisMaximum(80f); yAxis.setDrawLabels(false); Legend l = chart.getLegend(); l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER); l.setOrientation(Legend.LegendOrientation.HORIZONTAL); l.setDrawInside(false); l.setTypeface(tfLight); l.setXEntrySpace(7f); l.setYEntrySpace(5f); l.setTextColor(Color.WHITE); }
Example 4
Source File: BarChartActivityMultiDataset.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_barchart); setTitle("BarChartActivityMultiDataset"); tvX = findViewById(R.id.tvXMax); tvX.setTextSize(10); tvY = findViewById(R.id.tvYMax); seekBarX = findViewById(R.id.seekBar1); seekBarX.setMax(50); seekBarX.setOnSeekBarChangeListener(this); seekBarY = findViewById(R.id.seekBar2); seekBarY.setOnSeekBarChangeListener(this); chart = findViewById(R.id.chart1); chart.setOnChartValueSelectedListener(this); chart.getDescription().setEnabled(false); // chart.setDrawBorders(true); // scaling can now only be done on x- and y-axis separately chart.setPinchZoom(false); chart.setDrawBarShadow(false); chart.setDrawGridBackground(false); // 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(chart); // For bounds control chart.setMarker(mv); // Set the marker to the chart seekBarX.setProgress(10); seekBarY.setProgress(100); Legend l = chart.getLegend(); l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT); l.setOrientation(Legend.LegendOrientation.VERTICAL); l.setDrawInside(true); l.setTypeface(tfLight); l.setYOffset(0f); l.setXOffset(10f); l.setYEntrySpace(0f); l.setTextSize(8f); XAxis xAxis = chart.getXAxis(); xAxis.setTypeface(tfLight); xAxis.setGranularity(1f); xAxis.setCenterAxisLabels(true); xAxis.setValueFormatter(new ValueFormatter() { @Override public String getFormattedValue(float value) { return String.valueOf((int) value); } }); YAxis leftAxis = chart.getAxisLeft(); leftAxis.setTypeface(tfLight); leftAxis.setValueFormatter(new LargeValueFormatter()); leftAxis.setDrawGridLines(false); leftAxis.setSpaceTop(35f); leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true) chart.getAxisRight().setEnabled(false); }
Example 5
Source File: HalfPieChartActivity.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_piechart_half); setTitle("HalfPieChartActivity"); chart = findViewById(R.id.chart1); chart.setBackgroundColor(Color.WHITE); moveOffScreen(); chart.setUsePercentValues(true); chart.getDescription().setEnabled(false); chart.setCenterTextTypeface(tfLight); chart.setCenterText(generateCenterSpannableText()); chart.setDrawHoleEnabled(true); chart.setHoleColor(Color.WHITE); chart.setTransparentCircleColor(Color.WHITE); chart.setTransparentCircleAlpha(110); chart.setHoleRadius(58f); chart.setTransparentCircleRadius(61f); chart.setDrawCenterText(true); chart.setRotationEnabled(false); chart.setHighlightPerTapEnabled(true); chart.setMaxAngle(180f); // HALF CHART chart.setRotationAngle(180f); chart.setCenterTextOffset(0, -20); setData(4, 100); chart.animateY(1400, Easing.EaseInOutQuad); Legend l = chart.getLegend(); l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER); l.setOrientation(Legend.LegendOrientation.HORIZONTAL); l.setDrawInside(false); l.setXEntrySpace(7f); l.setYEntrySpace(0f); l.setYOffset(0f); // entry label styling chart.setEntryLabelColor(Color.WHITE); chart.setEntryLabelTypeface(tfRegular); chart.setEntryLabelTextSize(12f); }
Example 6
Source File: PieChartItem.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@SuppressLint("InflateParams") @Override public View getView(int position, View convertView, Context c) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = LayoutInflater.from(c).inflate( R.layout.list_item_piechart, null); holder.chart = convertView.findViewById(R.id.chart); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // apply styling holder.chart.getDescription().setEnabled(false); holder.chart.setHoleRadius(52f); holder.chart.setTransparentCircleRadius(57f); holder.chart.setCenterText(mCenterText); holder.chart.setCenterTextTypeface(mTf); holder.chart.setCenterTextSize(9f); holder.chart.setUsePercentValues(true); holder.chart.setExtraOffsets(5, 10, 50, 10); mChartData.setValueFormatter(new PercentFormatter()); mChartData.setValueTypeface(mTf); mChartData.setValueTextSize(11f); mChartData.setValueTextColor(Color.WHITE); // set data holder.chart.setData((PieData) mChartData); Legend l = holder.chart.getLegend(); l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT); l.setOrientation(Legend.LegendOrientation.VERTICAL); l.setDrawInside(false); l.setYEntrySpace(0f); l.setYOffset(0f); // do not forget to refresh the chart // holder.chart.invalidate(); holder.chart.animateY(900); return convertView; }
Example 7
Source File: PieChartActivity.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_piechart); setTitle("PieChartActivity"); tvX = findViewById(R.id.tvXMax); tvY = findViewById(R.id.tvYMax); seekBarX = findViewById(R.id.seekBar1); seekBarY = findViewById(R.id.seekBar2); seekBarX.setOnSeekBarChangeListener(this); seekBarY.setOnSeekBarChangeListener(this); chart = findViewById(R.id.chart1); chart.setUsePercentValues(true); chart.getDescription().setEnabled(false); chart.setExtraOffsets(5, 10, 5, 5); chart.setDragDecelerationFrictionCoef(0.95f); chart.setCenterTextTypeface(tfLight); chart.setCenterText(generateCenterSpannableText()); 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); // chart.setUnit(" €"); // chart.setDrawUnitsInChart(true); // add a selection listener chart.setOnChartValueSelectedListener(this); seekBarX.setProgress(4); seekBarY.setProgress(10); chart.animateY(1400, Easing.EaseInOutQuad); // chart.spin(2000, 0, 360); Legend l = chart.getLegend(); l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT); l.setOrientation(Legend.LegendOrientation.VERTICAL); l.setDrawInside(false); l.setXEntrySpace(7f); l.setYEntrySpace(0f); l.setYOffset(0f); // entry label styling chart.setEntryLabelColor(Color.WHITE); chart.setEntryLabelTypeface(tfRegular); chart.setEntryLabelTextSize(12f); }
Example 8
Source File: PieChartActivity.java From iMoney with Apache License 2.0 | 4 votes |
@Override protected void initData() { ivBack.setVisibility(View.VISIBLE); ivSetting.setVisibility(View.GONE); tvTitle.setText("饼状图"); // 初始化字体库 mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); pieChart.setDescription("目前android市场的占比情况"); // 设置内部圆的半径 pieChart.setHoleRadius(52f); // 设置包裹内部圆的半径 pieChart.setTransparentCircleRadius(67f); pieChart.setCenterText("Android\n市场占比"); // 设置中间显示的文本的字体 pieChart.setCenterTextTypeface(mTf); // 设置中间显示的文本的字体大小 pieChart.setCenterTextSize(18f); // 显示的各个部分的占比和是否为100% pieChart.setUsePercentValues(true); // 产生饼状图的数据 PieData mChartData = generateDataPie(); // 设置显示数据的格式 mChartData.setValueFormatter(new PercentFormatter()); mChartData.setValueTypeface(mTf); // 设置显示各个部分的文字的字体大小 mChartData.setValueTextSize(11f); // 设置显示各个部分的文字的字体颜色 mChartData.setValueTextColor(Color.RED); // set data pieChart.setData(mChartData); //获取图示的说明结构 Legend l = pieChart.getLegend(); //设置显示的位置 l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART); //设置几项说明在Y轴方向的间距 l.setYEntrySpace(10f); //设置第一项距离y轴顶部的间距 l.setYOffset(30f); // do not forget to refresh the chart // pieChart.invalidate(); pieChart.animateXY(900, 900); }
Example 9
Source File: BarChartActivityMultiDataset.java From Stayfit with Apache License 2.0 | 4 votes |
@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(""); // mChart.setDrawBorders(true); // scaling can now only be done on x- and y-axis separately mChart.setPinchZoom(false); mChart.setDrawBarShadow(false); mChart.setDrawGridBackground(false); // create a custom MarkerView (extend MarkerView) and specify the layout // to use for it MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view); // define an offset to change the original position of the marker // (optional) // mv.setOffsets(-mv.getMeasuredWidth() / 2, -mv.getMeasuredHeight()); // set the marker to the chart mChart.setMarkerView(mv); mSeekBarX.setProgress(10); mSeekBarY.setProgress(100); tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); Legend l = mChart.getLegend(); l.setPosition(LegendPosition.RIGHT_OF_CHART_INSIDE); l.setTypeface(tf); l.setYOffset(0f); l.setYEntrySpace(0f); l.setTextSize(8f); XAxis xl = mChart.getXAxis(); xl.setTypeface(tf); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setTypeface(tf); leftAxis.setValueFormatter(new LargeValueFormatter()); leftAxis.setDrawGridLines(false); leftAxis.setSpaceTop(30f); leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true) mChart.getAxisRight().setEnabled(false); }
Example 10
Source File: RadarChartActivitry.java From Stayfit with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_radarchart); mChart = (RadarChart) findViewById(R.id.chart1); tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); mChart.setDescription(""); mChart.setWebLineWidth(1.5f); mChart.setWebLineWidthInner(0.75f); mChart.setWebAlpha(100); // 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); setData(); mChart.animateXY( 1400, 1400, Easing.EasingOption.EaseInOutQuad, Easing.EasingOption.EaseInOutQuad); XAxis xAxis = mChart.getXAxis(); xAxis.setTypeface(tf); xAxis.setTextSize(9f); YAxis yAxis = mChart.getYAxis(); yAxis.setTypeface(tf); yAxis.setLabelCount(5, false); yAxis.setTextSize(9f); yAxis.setAxisMinValue(0f); Legend l = mChart.getLegend(); l.setPosition(LegendPosition.RIGHT_OF_CHART); l.setTypeface(tf); l.setXEntrySpace(7f); l.setYEntrySpace(5f); }
Example 11
Source File: PieChartItem.java From Stayfit with Apache License 2.0 | 4 votes |
@Override public View getView(int position, View convertView, Context c) { ViewHolder holder = null; if (convertView == null) { holder = new ViewHolder(); convertView = LayoutInflater.from(c).inflate( R.layout.list_item_piechart, null); holder.chart = (PieChart) convertView.findViewById(R.id.chart); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // apply styling holder.chart.setDescription(""); holder.chart.setHoleRadius(52f); holder.chart.setTransparentCircleRadius(57f); holder.chart.setCenterText(mCenterText); holder.chart.setCenterTextTypeface(mTf); holder.chart.setCenterTextSize(9f); holder.chart.setUsePercentValues(true); holder.chart.setExtraOffsets(5, 10, 50, 10); mChartData.setValueFormatter(new PercentFormatter()); mChartData.setValueTypeface(mTf); mChartData.setValueTextSize(11f); mChartData.setValueTextColor(Color.WHITE); // set data holder.chart.setData((PieData) mChartData); Legend l = holder.chart.getLegend(); l.setPosition(LegendPosition.RIGHT_OF_CHART); l.setYEntrySpace(0f); l.setYOffset(0f); // do not forget to refresh the chart // holder.chart.invalidate(); holder.chart.animateY(900); return convertView; }
Example 12
Source File: PieChartActivity.java From Stayfit with Apache License 2.0 | 4 votes |
@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.setDescription(""); 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.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(3, 100); mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad); // mChart.spin(2000, 0, 360); Legend l = mChart.getLegend(); l.setPosition(LegendPosition.RIGHT_OF_CHART); l.setXEntrySpace(7f); l.setYEntrySpace(0f); l.setYOffset(0f); }
Example 13
Source File: ChartBaseManager.java From react-native-mp-android-chart with MIT License | 4 votes |
/** * 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 }