I am in the process of porting my ionic 3 app to ionic 4. I use D3 for the creation of a meter.
None of the styling I have in my .scss file is working with the meter. The meter shape is correct but filled with black.
To create a simpler test cast I create a box directly in html with svg. I use a .scss class box to fill the color blue.
I also create a circle with D3 and use the style attribute to fill the circle with the color red.
I finally create another circle with D3 and use the .attr('class', '') to fill in the circle with the color green.
Here is the html:
<ion-header>
<ion-toolbar>
<ion-title>meter</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<svg width="50" height="50">
<rect x="0" y="0" width="50" height="50" class="box" />
</svg>
<div id="cir-1"></div>
<div id="cir-2"></div>
</ion-content>
Here is the code:
const circleOne = d3.select('#cir-1')
.append('svg')
.attr('width', 100)
.attr('height', 100);
circleOne.append('circle')
.style('stroke', 'gray')
.style('fill', 'red')
.attr('r', 40)
.attr('cx', 50)
.attr('cy', 50);
const circleTwo = d3.select('#cir-2')
.append('svg')
.attr('width', 150)
.attr('height', 150);
circleTwo.append('circle')
.attr('class', 'circle-style')
.attr('r', 40)
.attr('cx', 100)
.attr('cy', 100);
Here is the .scss:
.circle-style {
fill: green;
}
.box {
fill: blue;
}
The first two cases work, but the last case (which I am trying to get to work) where I use .attr('class', '') does not. It is black instead of green.
Here is a screenshot showing that the class was attached to the circle.
Any help for be greatly appreciated.
Thanks,
Brent