I'm using MPAndroid Chart , I'm trying to remove these 2 lines and I don't know how.
In my code I already have these:
chart.animateY(500);
chart.invalidate();
chart.setDrawGridBackground(false);
chart.setDrawBorders(false);
chart.setDoubleTapToZoomEnabled(true);
chart.setScaleEnabled(false);
chart.setTouchEnabled(false);
chart.getXAxis().setEnabled(false);
chart.getXAxis().setDrawLabels(false);
chart.getAxisLeft().setDrawLabels(false);
chart.getAxisRight().setDrawLabels(false);
chart.getLegend().setEnabled(false);
chart.getDescription().setEnabled(false);
chart.getXAxis().setDrawGridLines(false);
chart.getAxisRight().setDrawGridLines(false);
chart.getAxisLeft().setDrawGridLines(false);
chart.getXAxis().setDrawGridLines(false);
What is it that I am missing?
From the docs, setDrawAxisLine(boolean enabled): Set this to true if the line alongside the axis (axis-line) should be drawn or not.
In your case you could try with
chart.getAxisLet().setDrawAxisLine(false)
chart.getAxisRight().setDrawAxisLine(false)
Hope it helps!
Related
I'm developing an application with the GWT framework and Sencha GXT on the front-end.
I managed to display some data in a pie chart but I would also like to have a label inside the donut pie chart like . I looked at the demo provided by sencha as well as the "Chart" class but I don't see any cases where there is text inside a pie chart. Is it feasible ?
I'm using "Sencha GXT 4.0.0 - Sencha for GWT"
I finally found a solution, I just need to use the setX method in my textConfig so my code looks something like this :
TextSprite textConfig = new TextSprite();
textConfig.setFont("Arial");
textConfig.setTextBaseline(TextBaseline.MIDDLE);
textConfig.setFontSize(18);
textConfig.setTextAnchor(TextAnchor.MIDDLE);
textConfig.setZIndex(15);
textConfig.setX(-150);
150 worked for me but maybe it won't for you.
I'm trying to implement a custom barchart
which should look exactly like this. I tried mpChart but could only get this far
barDataSet = new BarDataSet(barEntries, "");
barData = new BarData(barDataSet);
barData.setBarWidth(.5f);
barChart.setData(barData);
barDataSet.setColors(getResources().getColor(R.color.colorPrimary));
barDataSet.setValueTextColor(Color.BLACK);
barDataSet.setDrawValues(false);
barChart.getXAxis().setDrawAxisLine(false);
barChart.setDrawGridBackground(false);
barChart.getXAxis().setDrawGridLines(false);
barChart.getAxisLeft().setDrawGridLines(false);
barChart.getAxisRight().setDrawGridLines(false);
barChart.getAxisLeft().setEnabled(false);
barChart.getAxisRight().setEnabled(false);
barChart.getLegend().setEnabled(false);
barChart.setPinchZoom(false);
barChart.setDescription(null);
barChart.setTouchEnabled(false);
barChart.setDoubleTapToZoomEnabled(false);
barChart.setExtraOffsets(20, 0, 0, 30);
XAxis xAxis = barChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextSize(14f);
xAxis.setTextColor(Color.BLACK);
xAxis.setYOffset(5);
xAxis.setDrawLabels(true);
xAxis.setGranularityEnabled(true);
xAxis.setGranularity(1f);
xAxis.setXOffset(30);
xAxis.setValueFormatter(new IndexAxisValueFormatter(xAxisLabel));
xAxis.setCenterAxisLabels(true);
barChart.invalidate();
I tried almost all possible examples and questions here, couldn't get the label to centre of the bars. Is it possible to put the labels exactly below the bars in non grouped bars? all the solutions I saw is only for grouped bars or combined charts.
I was plotting the x axis values from 1. when changed it to 0 and removed
xAxis.setCenterAxisLabels(true);
and i was able to centre the axis labels
You need to create a custom renderer for it.
Subclass BarChartRenderer and then call:
barChart.setRenderer(new MyBarChartRenderer(barChart, barChart.getAnimator(), barChart.getViewPortHandler()))
It will even allow you to alter the shape of it as described here.
But I think what you're looking for comes really close to this.
Download the MPAndroidChart Source from here. Then, you can customize the code according to your need and add it your project by
Clicking on File>New>Import Module.
I am creating a plot for my android app using graphview library, but the line chart is not showing all the data points.
I have already tried with different data sets, manually changing X-Y bound, but unable to fix.
this is the data set (x, y):
0.027616246868734515, 0.007854651482080012
0.02384627564469148, 0.00789924349849511
0.02117807669545499, 0.007941408464975257
0.020058627833574472, 0.007981469914748886
0.020072430035288694, 0.007994247157591203
0.02075702555156617, 0.008025737425449271
0.023093950612551192, 0.008067902299127112
0.026639815506611847, 0.008107586011190594
this is the graphview customization:
GridLabelRenderer gridLabel = chart.getGridLabelRenderer();
gridLabel.setHorizontalAxisTitle(xtitle);
gridLabel.setVerticalAxisTitle(ytitle);
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(5);
chart.getGridLabelRenderer().setLabelFormatter(new DefaultLabelFormatter(nf, nf));
chart.getViewport().scrollToEnd();
chart.getViewport().setXAxisBoundsManual(true);
chart.getViewport().setMinX(0);
chart.getViewport().setMaxX(0.040000);
chart.getGridLabelRenderer().setHumanRounding(false);
chart.getGridLabelRenderer().setNumHorizontalLabels(6);
This is showing data points 0,1,2,3,4,7 and missing 5,6.
I have already tried with default X and Y bound, but that is showing just one datapoint.
if anyone wants to know:
It draws vertical lines as expected in 4.1.0 but not 4.2.0 or 4.2.1.
I have an issue regarding "SKHeading". When i use (SKMapSettings.SKHeadingMode.ROTATING_MAP) and starts navigation i am getting a triangle on my navigated route which define a header i want to edit that header to smaller one but i am not able to find it in code can you please suggest me how to do that one. So that i can make that header triangle small and play around with it.Below is my code:
SKNavigationSettings navigationSettings = new SKNavigationSettings();
navigationSettings.setNavigationType(SKNavigationSettings.SKNavigationType.SIMULATION);
navigationSettings.setPositionerVerticalAlignment(-0.25f);
navigationSettings.setShowRealGPSPositions(true);
navigationSettings.setShowStreetNamesPopusOnRoute(true);
navigationSettings.setDistanceUnit(SKMaps.SKDistanceUnitType.DISTANCE_UNIT_MILES_FEET);
navigationSettings.getSpeedWarningThresholdInCity();
SKNavigationManager sknavigation = SKNavigationManager.getInstance();
sknavigation.setMapView(mapView);
sknavigation.setNavigationListener(this);
sknavigation.startNavigation(navigationSettings);
navigationInProgress = true;
mapView.centerOnCurrentPosition(17, true, 500);
mapView.getMapSettings().setHeadingMode(SKMapSettings.SKHeadingMode.ROTATING_MAP);
startOrientationSensor();
This is the line which creates that triangle.
mapView.getMapSettings().setHeadingMode(SKMapSettings.SKHeadingMode.ROTATING_MAP
Need to remove/edit this red circle triangle.
i have found the solution for this issue if anyone face such kind of issue you just have to comment or make the value of this line
navigationSettings.setShowRealGPSPositions(true);
this line has to look like below:
navigationSettings.setShowRealGPSPositions(false);
I created a Vaadin pie chart with following code.
Chart chart = new Chart(ChartType.PIE);
DataSeries dataSeries = new DataSeries("Logins");
chart.getConfiguration().setSeries(dataSeries);
I need to update my chart dynamically. I tried following (this code gets executed whenever new data is available).
adding new item:
dataSeries.add(new DataSeriesItem("New item", value), true, false);
updating existing item:
DataSeriesItem dataSeriesItem = dataSeries.get(0);
dataSeriesItem.setY(newValue);
dataSeries.update(dataSeriesItem);
But none of the above worked.
The only solution I could find is clearing the chart (chart.clear()), re, populating the data series and re drawing the chart (chart.drawChart()).
This method is not optimal since it re-draws the chart, and also the selection in the chart gets lost.
Does pie chart support dynamic updating? Can anyone suggest a way to fix this?
Try to call chart.getConfiguration().addSeries(dataSeries) before updating items. If that doesn't work, I think you should re-draw your chart.
I had the same problem and fixed it with chart.drawChart() after updating the data series in configurations (chart.getConfiguration.setSeries(newSeries)).
In my case (vaadin version 7.6.3), chart.clear() was not required.
There are other more complicated ways like vaadin-push plugin as well which I didn't find necessary for my case.
I know this question is old, but I will share how I solved this problem to Chart Pie in DChart 1.7.0.
DataSeries dataSeries = new DataSeries();
dataSeries.newSeries();
dataSeries.add( "Food", 500);
dataSeries.add( "Clothes", 1000);
chart.setDataSeries(dataSeries);
chart.show(); //this will update the chart in the browser;
Late to the question, but I encountered similar problem in 2020, I solved it using below code:
dataSeries.clear();
dataSeries.add(new DataSeriesItem("Expense", 120));
dataSeries.add(new DataSeriesItem("Saving", 20));
dataSeries.add(new DataSeriesItem("Balance", 100));
chart.getConfiguration().setSeries(dataSeries);
chart.drawChart();