You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When i try to generate the graph with a single value, it is just showing an empty graph (It is supposed to show a single dot in the graph indicating the value right?).
The problem also persists if the first and second y axis value is same (When there is just 2 values).
Any ideas why this weird problem occurs?
The code am using is given below
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
List<String> datelist = new ArrayList<String>();
List<Float> weightlist = new ArrayList<Float>();
datelist.add("12/Apr/2020");
weightlist.add(72f);
datelist.add("13/Apr/2020");
weightlist.add(72f);
LineChartView chart = findViewById(R.id.chart);
List<AxisValue> axisValues = new ArrayList<AxisValue>();
List<PointValue> values = new ArrayList<PointValue>();
for (int i = 0; i < datelist.size(); ++i) {
values.add(new PointValue(i, weightlist.get(i)));
axisValues.add(new AxisValue(i).setLabel(datelist.get(i)));
}
Line line = new Line(values).setColor(Color.BLUE).setCubic(false);
line.setHasLabels(true);
List<Line> lines = new ArrayList<Line>();
lines.add(line);
LineChartData data = new LineChartData();
data.setLines(lines);
data.setAxisXBottom(new Axis(axisValues));
data.setAxisYLeft(new Axis());
chart.setLineChartData(data);
}
}
The text was updated successfully, but these errors were encountered:
Hi, if suddenly someone will help after so much time
final Viewport v = new Viewport(charts[chart].getMaximumViewport());
v.top = (max > 0 ? max : 100);
v.bottom = min;
charts[chart].setMaximumViewport(v);
charts[chart].setCurrentViewport(v);
I solved this problem by adding extra lines of transparent color at ymin - someFudgeFactor and ymax + someFudgeFactor. This will add some padding to the top and bottom of the chart and will solve the problem with the preview chart, too, if you're using that.
When i try to generate the graph with a single value, it is just showing an empty graph (It is supposed to show a single dot in the graph indicating the value right?).
The problem also persists if the first and second y axis value is same (When there is just 2 values).
Any ideas why this weird problem occurs?
The code am using is given below
The text was updated successfully, but these errors were encountered: