How to remove the label in aBarChart. I have attached screenshot with what I want to remove marked in red. How do I remove that number?
Here is screenshot:
BarDataSet dataset = new BarDataSet(entries, "");
BarData data = new BarData(labels, dataset);
barChart.setData(data);
you need to add below line to hide label
dataSet.setDrawValues(false);
Related
I am using MPAndroidChart Library for showing a Bar Chart. Empty view for Data Bar Chart is showing "No chart data available":
Also I need to change this message. But it's not working for changing this I have used this code lines:
mChart.setNoDataText("No chart");
mChart.invalidate();
pieChart.setNoDataText();
use it and u will get your desired Text
also if you want some descriptive text then you can use
pieChart.setNoDataTextDescription();
First you can use:
chart.setNoDataText("Your description");
Then, you can customize through Paint object:
mChart.setNoDataText("Description that you want");
Paint p = mChart.getPaint(Chart.PAINT_INFO);
p.setTextSize(...);
p.setColor(...);
p.setTypeface(...);
Font: MPAndroidChart - Change message "No chart data available"
Have you added LineDataSet?
LineData xData = mChart.getData();
ILineDataSet x = xData.getDataSetByIndex(0);
x = createXSet();
xData.addDataSet(x);
xData.addEntry(new Entry(5f, 21, 0);
xData.notifyDataChanged();
mChart.notifyDataSetChanged();
mChart.setVisibleXRangeMaximum(30);
mChart.moveViewToX(xData.getEntryCount());
private LineDataSet createXSet(boolean drawPoints) {
LineDataSet set = new LineDataSet(null, "x");
set.setColor(Color.GREEN);
set.setLineWidth(2f);
set.setCircleRadius(2f);
set.setCircleColor(Color.WHITE);
set.setFillAlpha(65);
set.setFillColor(Color.GREEN);
set.setHighLightColor(Color.rgb(244, 117, 117));
set.setValueTextColor(Color.WHITE);
set.setValueTextSize(9f);
set.setDrawValues(false);
return set;
}
Make chart invisible until data is populated. This should solve the problem.
Below is my simple code for a line chart. If I use this code but only have one Entry, one point shows on the graph, which is good. If I add any more, like I have below, nothing at all shows, unless I add "newchart.animateX(3000);, in which case the chart shows for 3000ms and then disappears.... what gives?
LineChart newchart = (LineChart) findViewById(R.id.chart);
ArrayList<Entry> YAxis = new ArrayList<>();
Entry startingtemp = new Entry(0,3);
Entry next = new Entry(1,6);
YAxis.add(next);
YAxis.add(startingtemp);
LineDataSet temps = new LineDataSet(YAxis, "fuck");
ArrayList<ILineDataSet> dataSets = new ArrayList<>();
dataSets.add(temps);
LineData data = new LineData(dataSets);
newchart.setData(data);
newchart.animateX(3000);
newchart.invalidate();
Okay, the reason it wasn't working was because I added an x value of 1 before 0. when i switched the order in which i added the two entrys to the array, it started working fine.
I have a LineSeries
RadCartesianChartView chart = new RadCartesianChartView(context);
CartesianChartGrid cartesianChartGrid = new CartesianChartGrid();
cartesianChartGrid.setMajorYLinesRenderMode(GridLineRenderMode.INNER_AND_LAST);
cartesianChartGrid.setMajorXLinesRenderMode(GridLineRenderMode.INNER_AND_LAST);
cartesianChartGrid.setLineThickness(1);
cartesianChartGrid.setLineColor(Color.CYAN);
chart.setGrid(cartesianChartGrid);
LineSeries series = new LineSeries();
series.setStrokeColor(Color.GRAY);
But line is shown continuous without any point denoting the data point.
How can I show circles as data points on line.
To show the data points you have to add some methods in series.
series.setShowLabels(true);
And in case you need you can format labels in any java format you need
series.setLabelFormat("%.0f");
Hope it helps
Hello Guys I am New to Android. I am developing an App but stuck here. I want to set Random Text to TextView and I did it successfully but I am getting same text on all textview I put it. I want if the text set to one textview should not be show to other means its should not be repeat. Any help must be appreciated. I am posting some code here.
int[] array_set_up_text;
Random rand_set_up_text;
rand_set_up_text = new Random();
array_set_up_text = new int[] { R.string.set_up_text1, R.string.set_up_text2, R.string.set_up_text3,
R.string.set_up_text4, R.string.set_up_text5, R.string.set_up_text6, R.string.set_up_text7,
R.string.set_up_text8,R.string.set_up_text9,R.string.set_up_text10,R.string.set_up_text11,R.string.set_up_text12};
rand_text_set_up = rand_set_up_text.nextInt(array_set_up_text.length - 1);
text1.setText(array_set_up_text[rand_text_set_up]);
text2.setText(array_set_up_text[rand_text_set_up]);
text3.setText(array_set_up_text[rand_text_set_up]);
change your code to:
text1.setText(array_set_up_text[rand_set_up_text.nextInt(array_set_up_text.length)]);
text2.setText(array_set_up_text[rand_set_up_text.nextInt(array_set_up_text.length)]);
text3.setText(array_set_up_text[rand_set_up_text.nextInt(array_set_up_text.length)]);
You need to recall the nextInt() method each time:
text1.setText(array_set_up_text[rand_text_set_up]);
rand_set_up_text.nextInt()
text2.setText(array_set_up_text[rand_text_set_up]);
rand_set_up_text.nextInt()
text3.setText(array_set_up_text[rand_text_set_up]);
Your problem is this line
rand_text_set_up = rand_set_up_text.nextInt(array_set_up_text.length - 1);
You get a random position once, then don't update it.
Easiest solution is to do something like below
rand_text_set_up = rand_set_up_text.nextInt(array_set_up_text.length - 1);
text2.setText(array_set_up_text[rand_text_set_up]);
//Get a new random position.
rand_text_set_up = rand_set_up_text.nextInt(array_set_up_text.length - 1);
text3.setText(array_set_up_text[rand_text_set_up]);
//Get a new random position.
rand_text_set_up = rand_set_up_text.nextInt(array_set_up_text.length - 1);
text3.setText(array_set_up_text[rand_text_set_up]);
Basically i want to draw a graph where x-axis gives you the date and y axis gives u the count
I am getting data from server and parsing it in my two array's one is for count and other is for date
i am getting values in two array like this
SoapObject o=(SoapObject)p2.getProperty(xx);
UserCallStatusBean ld=new UserCallStatusBean();
if(o.getProperty("Month").toString().equals("anyType{}")){
ld.setDuration("");
}
else{
ld.setDuration(o.getProperty("Month").toString());
}
ld.setCount(Integer.parseInt(o.getProperty("Count").toString()));
CallStatus.add(ld);
GraphViewData o1=new GraphViewData(_iLoopCounter,Double.parseDouble(o.getProperty("Count").toString()));
String o2=new String(o.getProperty("Month").toString());
//String o2=new String(String.valueOf(_iLoopCounter));
arrData[xx]=o1;
arrXaxis[xx]=o2;
_iLoopCounter++;
After Getting the Value in two array i use Graph View Demo to create a grapg like
setContentView(R.layout.graphs);
// init example series data
exampleSeries = new GraphViewSeries(arrData);
// graph with dynamically genereated horizontal and vertical labels
GraphView graphView;
graphView = new BarGraphView(
this,"");
graphView.addSeries(exampleSeries); // data
graphView.setScalable(true);
graphView.setScrollable(true);
graphView.setViewPort(2,6);
graphView.setScrollable(true);
graphView.setHorizontalLabels(arrXaxis);
graphView.setGravity(Gravity.CENTER);
graphView.setBaselineAlignedChildIndex(4);
//graphView.setHorizontalLabels(labels);
LinearLayout layout = (LinearLayout) findViewById(R.id.graph1);
layout.addView(graphView);
Now My issue of concern is i am getting value of count on y-axis but i am also getting count of date on x-axis instead i want to show the date on x-axis
I Have read various articles to get string value on x-axis ,finded one to use Cutom lavel formatter , But didnt knw how to use so what i can do to get x-axis ? (Date Value)
I hope u understands ,Expecting Answer Pleasue will b aLl Mine
Thanks in advance