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.
Related
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 would like to read the current angle from my Ev3GyroSensor, however the returned value is always 0.
I tested multiple Ports nothing worked.
If I test the sensor with the LeJOS integrated Tool, everything works fine.
EV3GyroSensor ev3GyroSensor = new EV3GyroSensor(SensorPort.S4);
SampleProvider sampleProvider = ev3GyroSensor.getAngleAndRateMode();
float[] sample = new float[sampleProvider.sampleSize()];
sampleProvider.fetchSample(sample, 0);
System.out.println(sample[0]);
//I move the robot with my hand
Delay.msDelay(3000);
sampleProvider.fetchSample(sample, 0);
System.out.println(sample[0]);
ev3GyroSensor.close();
try using only angle mode, from my experience, angle and rate mode doesn't always work correctly.
There is also a possibility that you are reading the rate from the sample, but I'm not really sure.
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!
I am using aspose-slides-17.3-jdk16.jar for java. I have created the Area Chart using IChartDataWorkbook. I have used multiple series to plot area chart and following image is the chart output, where the data labels are overlapped.
Is there any way to organize or fit the data labels properly?
#Chandra Shekar,
I have observed your requirements and like to mention that you can try using different options label.getDataLabelFormat().setLabelPosition() and label.getDataLabelFormat().setShowLabelAsDataCallout(true) methods on your end to set the individual label positions for chart data points. You can please try using following sample code on your end and may alter this as per your requirements on your end.
public static void TestAreaChart()
{
Presentation pres = new Presentation();
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Area, 50, 50, 500, 400);
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat()
.setShowLabelAsDataCallout(true);
chart.getChartData().getSeries().get_Item(0).getLabels().get_Item(2).getDataLabelFormat()
.setShowLabelAsDataCallout(true);
chart.getChartData().getSeries().get_Item(0).getLabels().get_Item(2).getDataLabelFormat()
.setPosition(LegendDataLabelPosition.OutsideEnd);
pres.save("C:\\Aspose Data\\AreaChart.pptx", SaveFormat.Pptx);
}
I am working as Support developer/ Evangelist at Aspose.
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);