Skip to content
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

Rotate label #4

Closed
hnguye34 opened this issue Apr 14, 2021 · 3 comments
Closed

Rotate label #4

hnguye34 opened this issue Apr 14, 2021 · 3 comments

Comments

@hnguye34
Copy link

Hello,

Is it possible to rotate the label 90° ?
I tried to rotate de context, as following, before/after the call to addText but it does not work.
The angle parameter is not used by Flot so it cannot work neither.

barLabels.context.rotate(270 * Math.PI / 180);
barLabels.addText(layer, px, py, text, series.labels.font, angle, width, halign, valign); (Line 146)

Thanks for any idea !

@cleroux
Copy link
Owner

cleroux commented Apr 15, 2021

I haven't used flot in several years so I have only tested this on version 0.8.3 which was the last stable version before the new maintainers took over. (v0.8.3 is still available here http://www.flotcharts.org/downloads/ or in the example directory of this repository)

It's unfortunate Flot wasn't updated to support rotated text because it's actually pretty easy. You will need to modify jquery.flot.js or download the modified version from this repository (Please see the notes I added to the README).

In jquery.flot.js at the end of Canvas.prototype.AddText(), add the CSS transform to rotate the text.

        position.element.css({
            top: Math.round(y),
            left: Math.round(x),
            'text-align': halign,
            transform: 'rotate('+angle+'deg)'  // Add this line
        });

I have updated this plugin to support the angle option, updated the README and added an example.

image

I hope this helps. I'm closing this issue since I think this is the best solution I can offer.

@cleroux cleroux closed this as completed Apr 15, 2021
@hnguye34
Copy link
Author

It 's working well. Thank you for your help !

@hnguye34
Copy link
Author

Reopened by accident

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants