swimlane / ngx-charts

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

header style inside legend conflicts with the global header class #1247

Open jkjha opened 5 years ago

jkjha commented 5 years ago

Describe the bug With VMware Clairty Design (https://vmware.github.io/clarity/), when I use any chart, its legend breaks styling and displays an ugly black box. This is probably because the header tag used in the legend conflicts with Clarity's global header tag.

Please see this stackblitz.: https://stackblitz.com/edit/clarity-eguqas?file=app/app.component.ts

To Reproduce Steps to reproduce the behavior:

  1. Use ngx chart in VMware clarity desing system with legend On.

Expected behavior The black box legend should not be visible. Screenshots If applicable, add screenshots to help explain your problem.

Demo Provide an online demo (stackblitz, codesandbox, or similar) where the issue can be reproduced https://stackblitz.com/edit/clarity-eguqas?file=app/app.component.ts

ngx-charts version "@swimlane/ngx-charts": "^12.0.1",

Please let me know if you need any more info.

tofiqquadri commented 5 years ago

One way to solve this issue is using ViewEncapsulation.Shadow in your component that uses ngx chart.

Note: If you use this then your application styles won't get applies to the components under shadow dom but this might be what you are looking for.

tofiqquadri commented 5 years ago

I figured out the Solution for this issue as I also have VM Ware clarity and Ngx Chart due to which the Ngx chart header inherits VMWare clarity header styles. To fix it follow these steps:

.no-clarity-header {

  .chart-legend {

    .header,
    header {
      display: -webkit-box;
      display: inherit;
      color: inherit;
      height: inherit;
      white-space: nowrap;
    }

    header,
    header.header-1 {
      background-color: inherit;
    }
  }

}
<div class="areachart-wrapper no-clarity-header">

    <ngx-charts-area-chart 
        [view]="view" 
        [scheme]="colorScheme" 
        [results]="data" 
        [gradient]="gradient" 
        [xAxis]="showXAxis"
        [yAxis]="showYAxis" 
        [legend]="showLegend" 
        [showXAxisLabel]="showXAxisLabel" 
        [showYAxisLabel]="showYAxisLabel"
        [xAxisLabel]="xAxisLabel" 
        [yAxisLabel]="yAxisLabel" 
        [autoScale]="autoScale" 
        [curve]="curve" 
        (select)="onSelect($event)">
    </ngx-charts-area-chart>

 </div>

This has worked perfectly fine for me. Here is the demo image:

image

jkjha commented 5 years ago

Great thanks @tofiqquadri , this seems to work well. However I will keep this bug open for swimline team to fix from there side as well.

tofiqquadri commented 3 years ago

It has been more than a year and the issue is still open @jkjha ngx-charts should fix this now and if the issue is resolved close it.

mrqc commented 3 years ago

The ugly thing here is, that I want to focus on my data analysis but instead I have to focus on workarounds for this library. ;(