swimlane / ngx-charts

:bar_chart: Declarative Charting Framework for Angular
https://swimlane.github.io/ngx-charts/
MIT License
4.28k stars 1.15k forks source link

Incorrect legend placement with two charts of the same type #964

Open patrickchoi opened 5 years ago

patrickchoi commented 5 years ago

I'm submitting a ... (check one with "x")

Current behavior I have put two ngx-charts-bar-horizontal in the same page. When the legend display is set to true on both, the legend position of the 2nd chart is strangely attached to the 1st graph.

Expected behavior The legend should appear in line with the chart that it is attached to.

Reproduction of the problem Here is the code & screenshot. Note that the legend should appear with the 2nd chart, highlighted by the pink box.

2018-09-01 at 11 54 am

          <ng-template matTabContent>

            <div style="margin: 20px;">
              <ngx-charts-bar-horizontal
                [view]="view"
                [scheme]="colorScheme"
                [results]="feedback_data"
                [gradient]="gradient"
                [xAxis]="showXAxis"
                [yAxis]="showYAxis"
                [legend]="showLegend"
                [showXAxisLabel]="showXAxisLabel"
                [showYAxisLabel]="showYAxisLabel"
                [xAxisLabel]="xAxisLabel"
                [yAxisLabel]="yAxisLabel"
                (select)="onSelect($event)">
              </ngx-charts-bar-horizontal>
            </div>

            <div style="margin: 20px;">
              <ngx-charts-bar-horizontal
                [view]="star_view"
                [scheme]="colorScheme"
                [results]="patient_rating_arr"
                [gradient]="star_gradient"
                [xAxis]="star_showXAxis"
                [yAxis]="star_showYAxis"
                [legend]="star_showLegend"
                [showXAxisLabel]="star_showXAxisLabel"
                [showYAxisLabel]="star_showYAxisLabel"
                [xAxisLabel]="star_xAxisLabel"
                [yAxisLabel]="star_yAxisLabel"
                (select)="onSelect($event)">
              </ngx-charts-bar-horizontal>
            </div>
          </ng-template>

What is the motivation / use case for changing the behavior?

franklinpious commented 3 years ago

is there any fix available for this ?