Forum Discussion
How do I use vertical orientation
- 9 years ago
Hi,
I don't have access to source code which was used to create your barchart visual.
Now I may be wrong... though I can assume this type of barchart may have been built using d3.js
coding approach. Actually a lot of visuals found Custom Visual Gallery were basically built using
a d3.js coding approach including the main barChart tutorial found on Github.
So I'd say that pretty often label orientation can be dealt with transform rotate attribute.
As an example the following code with x-axis labelsvg.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + height + ")") .call(xAxis) .selectAll("text") .style("text-anchor", "end") .attr("dx", "-.8em") .attr("dy", "-.55em") .attr("transform", "rotate(-90)" ); //<---- 90 angle rotationwould produce something similar to this
while the same code with only minor rotate parameter modification:svg.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + height + ")") .call(xAxis) .selectAll("text") .style("text-anchor", "end") .attr("dx", "-.8em") .attr("dy", "-.55em") .attr("transform", "rotate(-45)" ); //<-- 45 angle rotationwould render something similar to this:
Note that this is pretty basic d3.js stuff... if you can send a copy of the source code you're using
then I maybe I could take a closer look at it and come up with something more accurate...Hope this helps
Hi,
I don't have access to source code which was used to create your barchart visual.
Now I may be wrong... though I can assume this type of barchart may have been built using d3.js
coding approach. Actually a lot of visuals found Custom Visual Gallery were basically built using
a d3.js coding approach including the main barChart tutorial found on Github.
So I'd say that pretty often label orientation can be dealt with transform rotate attribute.
As an example the following code with x-axis label
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.selectAll("text")
.style("text-anchor", "end")
.attr("dx", "-.8em")
.attr("dy", "-.55em")
.attr("transform", "rotate(-90)" ); //<---- 90 angle rotationwould produce something similar to this
while the same code with only minor rotate parameter modification:
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.selectAll("text")
.style("text-anchor", "end")
.attr("dx", "-.8em")
.attr("dy", "-.55em")
.attr("transform", "rotate(-45)" ); //<-- 45 angle rotationwould render something similar to this:
Note that this is pretty basic d3.js stuff... if you can send a copy of the source code you're using
then I maybe I could take a closer look at it and come up with something more accurate...
Hope this helps
- epark7 years agoRegular Visitor
Hi,
I was searching for the same subject and found your suggestion.
I am using Power Bi default visual (Clustered Column Chart) and willing to accomplish rotating the X axis.
Where do I apply the code you shared?