Comments (11)
Hi, I'm not working on that. I don't understand what's the problem and why many people ask about that. Legend can be created as separated view so you and anybody else could create it on your own. It is even a good idea to separate legend from chart view because legend view don't have to be invalidated so often. Data sharing between chart and legend is also not an issue. What's more everyone want the legend to look in a different way.
So I have no plans to add legend until someone provide or propose some viable solution.
from hellocharts-android.
Hi, thanks for your feedback:) I didn't plan to add legend or title as I've explained in issue #4 but already few people have asked about it so I'll keep this issue open. If I find some time I'll try to implement it.
from hellocharts-android.
Sorry, I should have searched. Yeah, probably keep the issue open for a bit.
It's easy to implement anyway, with a RelativeLayout
and by setting a TextView
at an absolute position I'm able to get a chart title.
from hellocharts-android.
@lecho I too think legends and title are part of the graph and should be implemented as a part of this great and beautiful library's API.
from hellocharts-android.
Ok:) I'll try to do this in next few days.
from hellocharts-android.
@lecho Could you give us an example of how to make a legend out of the chart? Which components you use for this?
from hellocharts-android.
@douglasjunior Hi, legend component is not finished yet, for now you need to create legend on your own.
from hellocharts-android.
@lecho The legend is the only thing holding me back from using this library. Do you have an updated ETA for it being implemented?
from hellocharts-android.
Sorry, for now time is the issue, I can't promise anything in that matter.
from hellocharts-android.
hello, when will be this api ready?
from hellocharts-android.
Hi all,
if someone still need to add titles as legend to their charts,this is my own implementation:
public void addTitles(LineChartView chart, List<Line> lines,
String[] titles, int textSize, String backgroundColor, int backgrounfAlpha) {
if (lines.size() != titles.length) {
return;
}
// set a linear layout container
LinearLayout listOfTitles = new LinearLayout(getActivity());
listOfTitles.setOrientation(LinearLayout.VERTICAL);
LayoutParams LLParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
listOfTitles.setLayoutParams(LLParams);
// set radius corners
GradientDrawable shape = new GradientDrawable();
shape.setCornerRadius(8);
shape.setColor(Color.parseColor(backgroundColor));
shape.setAlpha(backgrounfAlpha);
listOfTitles.setBackground(shape);
TextView[] textViewTitles = new TextView[titles.length];
for (int i = 0; i < titles.length; i++) {
textViewTitles[i] = new TextView(getActivity());
textViewTitles[i].setTextColor(lines.get(i).getColor());
textViewTitles[i].setText(titles[i]);
textViewTitles[i].setTextSize(textSize);
listOfTitles.addView(textViewTitles[i]);
}
// get chart parent
ViewGroup v = (ViewGroup) chart.getParent();
v.addView(listOfTitles);
listOfTitles.bringToFront();
// make the view draggable
listOfTitles.setOnTouchListener(this);
}
if you want to make the legend draggable :
1 - add implements OnTouchListener to your activity
and then :
float dX = 0;
float dY = 0;
@Override
public boolean onTouch(View view, MotionEvent event) {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
dX = view.getX() - event.getRawX();
dY = view.getY() - event.getRawY();
break;
case MotionEvent.ACTION_MOVE:
view.setY(event.getRawY() + dY);
view.setX(event.getRawX() + dX);
break;
default:
return false;
}
return true;
}
Thanks @lecho for the library!
from hellocharts-android.
Related Issues (20)
- y axis value only shows three digits. i.e, 0,300,600,900,200,500,800,100 etc. I need to show it as 0,300,600,900,1200,1500,1800,2100 HOT 1
- groovy.lang.MissingPropertyException: Could not set unknown property 'name' for object of type org.gradle.api.publish.maven.internal.publication.DefaultMavenPom.
- How to change Background Color Label?
- setCurrentViewport different result on Run and ApplyChanges
- Hellocharts android library not rendering chart when there is a single value or when y axis values are same HOT 2
- "setHasGradientToTransparent" Are Missing on LineChart with Kotlin HOT 3
- How to set axis number to Text in column chart? HOT 1
- Cannot use line.setHasGradientToTransparent() method
- Is it possible to obtain values from the generated graph?
- Importing it as Module
- linechart with multicolor data line
- Compatibility with AndroidX HOT 1
- Horizontal spacing between points
- 关于一个点问题(已解决)
- About the problem that the y-axis is not displayed.
- Unsupported Modules Detected
- HelloCharts
- library configuration
- LineChartView can not make steps of 0.5f
- 垂直折线图
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 hellocharts-android.