Comments (6)
Sounds like there are two cases here:
- Multiple points in your adapter, but they all return the same Y value.
For this case, we should definitely be drawing a straight line, so this sounds like a bug for sure.
- A single point in your adapter.
This is something of an undefined edge-case. A line isn't appropriate, since it implies there are at least two points in the graph. A dot is generally more correct, but leaves us in an odd position. Spark tries to shrink the bounds of the graph as tightly as it can to the Sparkline. In the case of a dot, it really can't since a single point has no size. It leaves a lot of ambiguity in where the dot should be placed.
An easy work-around in your adapter would be to just duplicate the single point, if you wish to get a line. But that's assuming that problem 1 above is fixed.
from spark.
-
Yup, thats what I meant.
-
I can understand that, its a lot of logic for such a "minor" thing. Personally I dont mind, Ill work around it.
Thanks for the quick answers. Much appreciated!
from spark.
The root issue is that the scale we calculate is infinity
, due to a straight line technically having 0 height. A quick and dirty workaround until I can get the real fix out would be to add this to your SparkAdapter:
@Override
public RectF getDataBounds() {
RectF bounds = super.getDataBounds();
if (bounds.top == bounds.bottom) {
bounds.top -= 1;
bounds.bottom += 1;
}
return bounds;
}
It's basically just enforcing a height on the data bounds, leaving your line directly in the center. Hoping to get a real fix in for you later this week.
from spark.
Thanks a lot Dan! Im so thankful for finding your library, both for its functionality and for your quick responses. Will patiently wait for your fix as I have a few other things to tackle in the meanwhile myself. Thanks again!
from spark.
You're welcome! Very glad you like it!
from spark.
Just released 1.1.2, which should contain this fix!
from spark.
Related Issues (20)
- Does library support using List instead of float array? HOT 4
- question : support gradient color ? HOT 2
- [Request] New animation HOT 3
- Show min and max values. HOT 6
- Make use of Android annotations more consistent throughout library HOT 3
- Allow generic drawing effects HOT 3
- Setting cornerRadius to non-zero results in fill closing path also using radius HOT 1
- Fill with gradient HOT 3
- BaseLine dotted line sample HOT 2
- Thank you.. HOT 1
- Why doesn't onScrubbed include both x and y? HOT 6
- error: attribute spark_fillColor not found HOT 1
- Conditionally color sparkline HOT 1
- Android graph mismatch to actual charting data HOT 1
- shadow HOT 2
- Upgrade spark to androidx HOT 3
- 频繁调用notifyDataSetChanged, 导致native内存持续增高,且无法回收
- Using SparkAdapter with X and Y value and displaying both on onScrubbed() HOT 3
- can the scrubbing change from line to a button ? HOT 1
- Multiple lines in one chart? HOT 1
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 spark.