Comments (5)
Thank you for your input.
Are the labels also cut on a vertical axis? Or is this just your screenshot?
Currently the chart does not support wrapping the legend. But I am working on an update that allows wrapping right now.
What you can do is call
Legend l = mChart.getLegend();
l.setFormToTextSpace(..); // make space smaller
l.setFormSize(...); // make form smaller
...to save some space.
You can also edit the library and change the text size of the legend labels.
A method for this is also coming in the next update.
A little suggestion: If you have limited space and are using a legend anyway, you can call
mChart.setDrawXValues(false);
which will save some space inside the chart ant make it look better.
Regards,
Phil
from mpandroidchart.
They are cut on bottom a little bit when you are using PieChar from what I noticed.
I handled this already with changing this lane in your library from:
posY = getHeight() - mLegend.getOffsetBottom() / 2f - formSize / 2f;
to:
posY = getHeight() - mLegend.getOffsetBottom() / 2f - formSize / 2f - 4f;
in your Chart.java at 659lane.
If you could point me out where to extend the Chart Object on screen so I can fit the wrapped Legend here I'd make it myself.
At the moment I am able to wrap it by editing your library but if I have many records I do not have space to place it. So if there is option to extend a space under graph without making graph bigger itself, that would be nice.
Obviously if it would be too much work to you now, I will wait for library update :)
Thanks for suggestion mate, but this is temp graph just to show the legend issue. I learned the basics from your readme.
Also thanks for saving space tip, but I have to make graph with 15 objects inside so in this particular case it won't help me much, sadly.
from mpandroidchart.
Thank you for pointing out the issue concerning the vertical clipping. I must have not noticed this during testing and will fix it in the next update.
The PieChart legend in general has some issues I need to fix, so you will probably have to wait for the next update.
Also check out the example project because the readme by far does not list up and explain all features and is outdated in some cases (due to the huge amount of changes I made during the past weeks).
Regards,
Phil
from mpandroidchart.
I just fixed the issue concerning the vertical clipping. It will be published in the next update.
If you want to fix it right away, you need to replace the calculateOffsets()
method of the PieChart
with this method:
@Override
protected void calculateOffsets() {
if (mLegend == null)
return;
// setup offsets for legend
if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART) {
mLegend.setOffsetRight(mLegend.getMaximumEntryLength(mLegendLabelPaint));
mLegendLabelPaint.setTextAlign(Align.LEFT);
} else if (mLegend.getPosition() == LegendPosition.BELOW_CHART_LEFT
|| mLegend.getPosition() == LegendPosition.BELOW_CHART_RIGHT) {
mLegend.setOffsetBottom(mLegendLabelPaint.getTextSize() * 3.5f);
}
if (mDrawLegend) {
mOffsetBottom = Math.max(mOffsetBottom, mLegend.getOffsetBottom());
}
mLegend.setOffsetTop(mOffsetTop);
mLegend.setOffsetLeft(mOffsetLeft);
prepareContentRect();
float scaleX = (float) ((getWidth() - mOffsetLeft - mOffsetRight) / mDeltaX);
float scaleY = (float) ((getHeight() - mOffsetBottom - mOffsetTop) / mDeltaY);
Matrix val = new Matrix();
val.postTranslate(0, -mYChartMin);
val.postScale(scaleX, -scaleY);
mMatrixValueToPx.set(val);
Matrix offset = new Matrix();
offset.postTranslate(mOffsetLeft, getHeight() - mOffsetBottom);
mMatrixOffset.set(offset);
}
... and undo all changes you made to the legend drawing.
Regards,
Phil
from mpandroidchart.
Thanks for your time and answers, I replaced the method already thanks for that listing too.
Have fun with coding and good luck with your library
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.