Support
Quality
Security
License
Reuse
kandi has reviewed hellocharts-android and discovered the below as its top functions. This is intended to give you an instant insight into hellocharts-android implemented functionality, and help decide if they suit your requirements.
Line chart(cubic lines, filled lines, scattered points)
Column chart(grouped, stacked, negative values)
Pie chart
Bubble chart
Combo chart(columns/lines)
Preview charts(for column chart and line chart)
Zoom(pinch to zoom, double tap zoom), scroll and fling
Custom and auto-generated axes(top, bottom, left, right, inside)
Animations
Download and Import
dependencies{
compile 'com.github.lecho:hellocharts-library:1.5.8@aar'
}
Usage
<lecho.lib.hellocharts.view.LineChartView
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="match_parent" />
License
HelloCharts
Copyright 2014 Leszek Wach
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Hellocharts android library not rendering chart when there is a single value or when y axis values are same
float ymax= maxyvalue +10f;
final Viewport v = new Viewport(chart.getMaximumViewport());
v.top =ymax; //max value
v.bottom = 0f; //min value
chart.setMaximumViewport(v);
chart.setCurrentViewport(v);
QUESTION
Hellocharts android library not rendering chart when there is a single value or when y axis values are same
Asked 2020-Apr-15 at 07:57Am using hellochart library https://github.com/lecho/hellocharts-android to show a linechart in my app.
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);
}
}
ANSWER
Answered 2020-Apr-15 at 07:57This is the the solution i finally found, To set the viewport manually.
float ymax= maxyvalue +10f;
final Viewport v = new Viewport(chart.getMaximumViewport());
v.top =ymax; //max value
v.bottom = 0f; //min value
chart.setMaximumViewport(v);
chart.setCurrentViewport(v);
Hope it will help somebody in future.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit