Comments (12)
So your problem is that you can set the scale minimum so that the user cannot fully zoom out the x-axis, but the starting position is not correct / cannot be changed?
from mpandroidchart.
Yes. Exactly. Since it is a timeline chart, I would like to start from last which will be latest entry.
from mpandroidchart.
Very well. Thankfully, that does not look like that a major issue to me.
I am going to look into that problem within the next hours and will hopefully be able to push a quick fix alongside with some other changes until tomorrow night (Europe), at the latest.
from mpandroidchart.
Thanks Phil.
from mpandroidchart.
I have now implemented this feature in my local commit. The only problem for me is that I don't think it's good enough yet :-)
I will try to change the implementation to a way that is satisfying for me within the next few hours to push on master or push the features current implementation to the experimental banch.
from mpandroidchart.
Allright, the implementation is now complete and pushed to master.
You can see an example in the ExampleProject inside the LineChartActivity
.
The basic functionality is as follows.
The new method centerViewPort(int xIndex, float val)
makes it possible to aim the center of the view to a specific position inside the chart, described by the index on the x-axis and the value on the y-axis. This also works very well in combination with the setScaleMinima(...)
method.
Example:
A chart containing 50 entries ranging from 0-1000 with their values.
Chart.setData(...);
// restrain x-axis
Chart.setScaleMinima(3f, 1f);
// center view to index 50 and value 500
Chart.centerViewPort(50, 500f);
//.. now view is positioned on the right side of the chart on the x-axis and centered on the y-axis
from mpandroidchart.
Thanks Phil. I'm going to test it right away !!
from mpandroidchart.
Allright. Please let me know if it works and if you are having any problems.
from mpandroidchart.
Sorry. It took time to get back. centerViewPort works fine. But i have to click somewhere on the Chart to make it work. Tried invalidating the chart after calling centerViewPort. But still doesn't work.
mChart.setData(data);
mChart.invalidate();
mChart.centerViewPort(11, 92);
mChart.invalidate();
from mpandroidchart.
Thank you for your response.
Indeed, there still was a minor issue in the implementation of the centerViewPort(...)
method that caused the problem you described.
I managed to track down the bug and fix it.
It should now work as expected.
Just for the record, this is the correct implementation (you can also find it in the example project):
// first, set data
mChart.setData(...);
// restrain the maximum zoomout level, e.g.
mChart.setScaleMinima(3f, 3f);
// center the "camera" to your desired position
mChart.centerViewPort(xIndex, value);
// there should be no further need for calling invalidate()
from mpandroidchart.
It works fine now !! Thanks.
from mpandroidchart.
Still met this problem with the latest release, the chart show correctly only after touch it
from mpandroidchart.
Related Issues (20)
- Android Studio: disabled warning when using SDK features unavailable at SDK 21 (e.g. @FunctionalInterface or streaming)? HOT 1
- Barchart is not displaying properly for 15 days. HOT 2
- Granularity is not working when set to 6f.
- Highlight issues after i applied RoundedSlicesPieChartRenderer in piechart
- 可以设置初始化Y轴数据的数量 之后一个一个的动态加载吗?
- Help: Dotted Background
- 使用implementation ("com.github.PhilJay:MPAndroidChart:v3.0.2")报错
- Values above the Horizontal bars Disappears when I zoomed in
- dataSet.gradientColors = gradientColors not working
- Fatal Exception: java.lang.NegativeArraySizeException HOT 4
- LineDataSet: shader with multiple color
- Getting crash while selection camera cropping only in Android 10
- How to rotate the Tooltip arrow Based on the touch points
- Documentation Link Failed! HOT 4
- When drawing Bezier curves vertically in LineChart, the curve flickers.
- Fatal Exception: java.lang.NullPointerException Attempt to read from null array
- Fatal Exception: java.lang.ArrayIndexOutOfBoundsException
- Crash app with large data
- 如何绘制x轴带图片
- com.github.mikephil.charting.utils.Utils drawImage When the width and height are unequal, it may lead to deformation of the drawn icon
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mpandroidchart.