question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Grouped Vertical Bar Chart background black when transformed to canvas

See original GitHub issue

I’m submitting a … (check one with “x”)

  • bug report - search github for a similar issue or PR before submitting
  • feature request
  • support request - use StackOverflow (add the ngx-charts tag) or the gitter chat for support questions

Current behavior I’m using html2canvas to transform some ngx-charts to a canvas. Only the “Grouped Vertical Bar Chart” gets a black background then. I guess it has something to do with the .ngx-charts .grid-panel.odd rect but had no luck with trying everything in CSS that came to my mind. All other charts I use don’t show this behaviour.

Expected behavior The background (maybe grind-panel) should not become black when transformed to a canvas element.

Reproduction of the problem

Check this Stackblitz I created where you see the difference when rendering the normal & the grouped bar chart: https://vertical-bar-chart-smoh7c.stackblitz.io/ https://stackblitz.com/edit/vertical-bar-chart-smoh7c

Please tell us about your environment: macOS 10.13.4, WebStorm 2018.1.1, npm

  • ngx-charts version: 8.0.2

  • Angular version: 6.0.3

  • Browser: [ Chrome, Safari, Firefox ]

  • Language: Typescript, ES6

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

3reactions
sagarp2901commented, Jun 6, 2019

This is how I solved it, by setting the fill attribute on the rect elements:

let rectElements = Array.from(document.getElementsByTagName('rect'));
  if (rectElements.length > 0) {
    rectElements.forEach(rect => {
      rect.setAttribute('fill', '#ffffff');
    });
  }
0reactions
javiermrzcommented, Oct 10, 2019

@sagarp2901 I think that is not really clean. Put this in your css and it will do the job:

.gridpanel {
  fill: #ffffff;
}

or

rect{
  fill: #ffffff;
}

I prefer the first one, as it is more specific. However, these are not valid solutions, because they will print every element of the grid in white color, instead of a white-gray-white-gray grid. Has anyone found a better solution?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Demo: A Bar chart with a dark background | RGraph.net
This is a grouped Bar chart with two bars per group which uses red and blue graduated fills. The background grid has been...
Read more >
Dark background style sheet — Matplotlib 3.6.2 documentation
This example demonstrates the "dark_background" style, which uses white for elements that are typically black (text, borders, etc). Note that not all plot...
Read more >
Tips and tricks for formatting in reports - Power BI
Apply a theme to the entire report; Change the color of a single data point; Conditional formatting; Base the colors of a chart...
Read more >
Bar chart appearance and behavior - MATLAB - MathWorks
Bar Graph Type · BarLayout — Arrangement of bars 'grouped' (default) | 'stacked' · BarWidth — Relative width of individual bars 0.8 (default)...
Read more >
Bar Charts - NCL Graphics
Setting fill colors specifically for a vertically-oriented bar chart: ... the outline is drawn after the color fill, and a black line and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found