Comments (4)
Ok, so you need the following two things:
- a stacked barchart / different values in one bar
- a combination of line- and barchart (because of your "limit" line)
I am currently working on implementing those features, but I cannot tell when exactly I will have the time to finish the implementation.
In the meantime, I suggest the following approach:
You can use multiple DataSets, each representing one color.
Example
Your limits are 10 and 20, and the colors representing the limits are red (below 10), yellow (below 20) and green (everything above 20).
The values you want to represent in the chart are 5, 25, and 15 on x-axis index 0, 1 and 2.
Now, you create a DataSet
that is represented by the color green, and contains all values above 20. In this example case, that would be the values 0, 25, and 0 (everything below 25 is 0).
As a next step, you create a DataSet
that represents the color yellow, and contains all values between 10 and 20. In this example, that would be the values 0, 20 and 15.
Last but not least, you create the DataSet
representing the color red. It will contain the values 5, 10 and 10. If you now combine these DataSets
and add them to the chart, everything below 10 should be red, between 10 and 20 yellow, and above 20 green.
For your limit line in the chart, I suggest you modify the BarLineChartBase
class of the library by adding the following code inside the onDraw(...)
method: (between drawData()
and drawHighlights()
)
drawData();
// draws a horizontal line through the whole chart at value 10
float[] pts = new float[] { 0f, 10f, mDeltaX, 10f };
transformPointArray(pts);
mDrawCanvas.drawLine(pts[0], pts[1], pts[2], pts[3], yourDesiredPaintObject);
drawHighlights();
// ...
from mpandroidchart.
Thank you so much.
from mpandroidchart.
Update: The latest commit now features LimitLines
that can be set to the data object that is handed to the chart.
LineData ld = new LineData(...);
LimitLine ll = new LimitLine(100f); // limit at 100
ll.set(...); // additional styling...
ld.addLimitLine(ll);
mLineChart.setData(ld);
from mpandroidchart.
@amagine @PhilJay I have the same issue as @amagine but I cannot understand what you guys are saying. Can you show me a simple example.
from mpandroidchart.
Related Issues (20)
- 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
- Multi same x data find index by closestToY in getEntryIndex function error
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.