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

The option to place the labels on the bottom #21

Closed
jsong0605 opened this issue Jun 19, 2017 · 4 comments
Closed

The option to place the labels on the bottom #21

jsong0605 opened this issue Jun 19, 2017 · 4 comments

Comments

@jsong0605
Copy link

jsong0605 commented Jun 19, 2017

Description

AFAIK, the labels are rendered on the upper-side of the chart by default.
There's no option to manipulate the position of labels, so far.

The easiest way (but bothering ;() is increasing the 'y' value of element manually.
However, changing the 'y' value by hand may cause a blink.
Because, this re-rendering follows the default rendering on the default position.

I'd like to place the label on the bottom by handling the option which could be a solution to the above problem at the same time.

If you guys have a possible way, please add it to the following release.

I believe that there must be other users who seriously need it.

Thanks ~ :)

Steps to check or reproduce

        var chart = bb.generate({
            bindto: "#_temperature",
            interaction: {
                enabled: false
            },
            legend: {
                show: false
            },
            data: {
                x: "x",
                columns: [
                    ['x', 1, 2, 3, 4, 5],
                    ['data1', 7, 9, 13, 16, 20],
                    ['data2', 2, 2, 5, 7, 10]
                ],
                labels: true
            },
            axis: {
                x: {
                    show: false
                },
                y: {
                    show: false
                }
            },
            tooltip: {
                show: false
            },
            point:   {
                show: false
            }
        });

issue

@netil
Copy link
Member

netil commented Jun 19, 2017

@jsong0605 thanks for suggestion!
Actually there's no option for that, if you need to manipulate label text position, you should do handling directly.

For ex., below option will set text lower than the original position.

var chart = bb.generate({
	...
	onrendered: function() {
	        d3.selectAll(".bb-texts .bb-text").each(function() {
		        var text = d3.select(this);
		        text.attr("y", (+text.attr("y") + 20))
	        });
	}
});

image

We will take in considering for the next release. thanks!

@jsong0605
Copy link
Author

I really appreciate your answer! ~ :)

As far as I'm concerned, the 'onrendered' function follows the default rendering on the default position.

So, the blicking problem still remains to be resolved.

Could I please have a solution for that matter, if you have one~ ?

@netil
Copy link
Member

netil commented Jun 20, 2017

@jsong0605 you mean flickering of the text?

well, in that occasion to avoid flickering, set opacity to 0 for text nodes and re-set to 1 on onrendered callback.

.bb-texts text.bb-text {
     opacity: 0;
}
var chart = bb.generate({
	...
        onrendered: function() {
	    d3.selectAll(".bb-texts .bb-text").each(function() {
	      var text = d3.select(this);
	
	      text
	        .attr("y", (+text.attr("y") + 20))
	        .style("opacity", "1");
	    });
        }
});

Checkout the online demo :

@jsong0605
Copy link
Author

Yes, that's the issue what I meant.

Thanks for the detail solution to detour the issue. :)

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

No branches or pull requests

2 participants