Add ability to position the legend top|right|bottom|left.
Lets just do bottom for now. See this for example: https://www.screencast.com/t/5RzCSE8KjsjN
Is there a branch open with this feature being implemented yet?
There is a branch, but is behind master a lot https://github.com/swimlane/ngx-charts/tree/legend-position
Is there an issue with the implementation other than being behind so far? I'd be interested in looking into the getting the feature into the main project.
Yes, in that branch we tried to prototype an approach using flexbox for the layout and positioning of the legend, but we ran into a synchronization issue in the dimensions, so we postponed it for a future release. Feel free to take a look into it though. Ideas for another approach would also be appreciated.
Do we have an ETA on when this is going to be released? I am spending a lot of hours trying to force the legend on top or bottom!! :(
+1 we would also love this feature.
Hi All,
I have been looking for this solution also, for all day.
But when i come up here, and finding that this future is not available, so i decided to use any hack
way to get legends at bottom.
<ngx-charts-pie-chart
[scheme]="colorScheme"
[results]="single"
[legend]="showLegend"
[explodeSlices]="explodeSlices"
[labels]="showLabels"
[doughnut]="doughnut"
[gradient]="gradient"
(select)="onSelect($event)">
</ngx-charts-pie-chart>
and bellow i added span with label class:
<div>
<span class="label label-danger label-xs"> </span>
<span class="legend-label-text">
Outstanding Amount</span>
<span class="label label-success"> </span>
<span class="legend-label-text">
Received Amount
</span></div>
and inside component.css i added this css
.label {
border-radius: 50%;
font-size: 9px;
font-weight: 500;
padding: 3px 8px;
text-transform: uppercase;
}

this solution look really nice on my side, and if someone is looking to get legends at bottom while
using pie charts, i think this can be good trick to get legends at bottom, while from defaults legends are on right side of the pie
I am trying similarly using heavy-handed CSS, the only thing I can't do is get the advanced pie to grow larger. It is constrained in a col-3 in BootStrap4 and inheriting that width. :/
+1
+1
Just sharing our knowledge. we have a similar requirement to position the legend to the left. nk and i solved this via css. We realized that since there are two divs (for the chart, and one for the legend), we float right the chart.
For our requirement,
.ngx-charts {
float: right !important;
position: relative !important;
}
That's it. A quick work around. We have to set the width of the legend too namely these
Hope this is useful to others facing the same requirement.
If you want it bellow -
ngx-charts-legend.chart-legend {
width: auto;
clear: both;
display: block;
margin:0 auto;
& > div {
display:block;
width: auto !important;
}
.legend-wrap {
min-width:200px;
text-align:center;
margin:0 auto;
float:none;
}
.legend-title{
display:none;
}
.legend-labels{
width: auto;
display:inline-block;
text-align:center;
margin:0 auto;
background:none;
float:none;
padding:0;
margin-left: -13%;
margin-top: -13%;
}
}
I moved the legend to the bottom using bellow SCSS, then i resized the chart SVG to get the full width
.ngx-charts-outer {
height: 100%;
display: flex;
flex-direction: column-reverse;
}
@include media-breakpoint-up(md) {
.legend-labels {
display: flex;
}
.f-18{
font-size: 16px;
}
}
.chart-legend {
& div:first-child{
position: absolute;
bottom: 0px;
width: 90% !important;
padding-left: 5px;
// padding-bottom: 10px;
}
}
Hi,
I am using ngx-charts-pie-chart , legends are not coming properly. Can anyone help me please.
I am attaching screenshot also.I want legends width to be 100%

I personally wanted the legend on top of a pie chart, and this is how I've achieved that based on this SO answer:
.ngx-charts-outer {
display: table;
.ngx-charts {
float: left !important;
position: relative !important;
display: table-footer-group;
}
.chart-legend {
width: 100% !important;
display: table-header-group;
}
}
After that, there is a div that will cut off inside of the .chart-legend class, so you need to use JS to change that inline style width. We can do that after the view has rendered by wrapping the chart in a parent and accessing the DOM with the ElementRef type.
ngAfterViewInit() {
this.chartparent.nativeElement.getElementsByClassName('chart-legend')[0].children[0].style.width = '100%';
}
Hacky for sure, but got me on my way to the next feature.
We have had success getting the legend to the top of the chart, but have not had any luck getting the chart to expand to fill the columns where the legend used to be. Any help is greatly appreciated, thanks!!!
FWIW, you can achieve the desired effect by using ngClass and adding CSS for top, left, bottom, right positions by over riding .ngx-charts-outer to display: flex and then modifying either flex-flow: column-reverse (top), flex-direction: row-reverse (left), and flex-flow: column (bottom). It's then a matter of a little javascript calculating to adjust white spacing in DIVs.
Is it possible to set the legend position to top?
:/
I have two diagrams in two separate angular components and I need to visualize the diagrams as in the image
How could I do it ...
@tamueka I do recommend posting such question on StackOverflow, please use the issues to address any bug on the library.
For you question, you can easily set each pie-chart using any kind of grid by wrappping them on col class.
I do recommend creating a parent component with the grid stuff and then place inside each col div, the pie-chart component with custom configuration per chart. The left one should have disabled legends while the right one could handle the legend data.
I have two diagrams in two separate angular components and I need to visualize the diagrams as in the image
How could I do it ...
Have you finished the implementation?
How can i show legend in the bottom of pie chart?
How can i show legend in the bottom of pie chart?
legendPosition = "'bottom'";
Please refer to my example and explanations in http://yuezhizizhang.github.io/swimlane/ngx-charts/2019/10/01/donut-chart-with-ngx-charts.html
No way to position the legend on top of a pie chart? :(
+1! A solution to this would be much appreciated!
+1!
Most helpful comment
+1 we would also love this feature.