-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New legend position option: "inset" #326
Conversation
pjschreifels
commented
Jun 6, 2014
Adds an option to inset the legend.
Thank you for this PR. I merged this with some fixes. Thanks! |
Beautiful. Glad I could contribute. |
What's the implementation look like for this? Is there a class name to hook into with css? |
Instead of using bottom (the default) or right position for the legend, use "inset". There are a few options for an inset legend; you may anchor it to the "top-left", "top-right", "bottom-left", or "bottom-right". You can also provide a x or y offset, that will move the legend away from the edge of the chart. Finally, you must explicitly set the number of items in the legend, so that it sets the proper vertical size. For example: legend: {
position: "inset",
inset: {
anchor: "top-left",
x: 10
y: 10
step: 3
}
} The inset legend follows the class conventions of C3 in general, so you may override the styles of the legend as you like. |
If step is not specified, the legend get the full height of the chart. Shouldn't step get step number automatically? |
When I submitted the PR, the step number was being set automatically, but that was changed by masayiuki before it was merged. I'm not sure why. |
I'm sorry. I made a bug. @pjschreifels is right. |
This works fine and it looks nice, thank you @pjschreifels and @masayuki0812 . However I think there is still a small bug, when you unload and load again the old legend does not get discarted. Here is a demo (click "update" to see the problem) |
@leo-mck Thank you for your reporting. You're right. There was a bug. I think it's been fixed now. |