This question already has an answer here:
这个问题已经有了答案:
- Styles in component for D3.js do not show in angular 2 6 answers
- D3组件的样式。在角度为2的6个答案中不显示js
I'm using Angular 2.0 TypeScript and d3.js libary for creating grafic. I'm trying to apply css on asix ( most importand shape-rendering: crispEdges;
). Do you have any idea?
我用的是角2。0打字稿和d3。用于创建嫁接。我正在尝试在asix上应用css(最重要的和图形渲染:crispedge;)你知道吗?
here is the code
这是代码
var vis = d3.select("#visualisation"),
WIDTH = 1000,
HEIGHT = 500,
MARGINS = {
top: 20,
right: 20,
bottom: 20,
left: 50
},
xRange = d3.scale.linear()
.range([MARGINS.left, WIDTH - MARGINS.right])
.domain([d3.min(this.calculationResults, function(d) { return d.time;}),
d3.max(this.calculationResults, function(d) { return d.time;})]),
yRange = d3.scale.linear()
.range([HEIGHT - MARGINS.top, MARGINS.bottom])
.domain([d3.min(this.calculationResults, function(d) { return d.force; }),
d3.max(this.calculationResults, function(d) { return d.force;})]),
xAxis = d3.svg.axis()
.scale(xRange)
.ticks(10)
.tickSize(5)
.tickSubdivide(true),
yAxis = d3.svg.axis()
.scale(yRange)
.ticks(10)
.tickSize(5)
.orient("left")
.tickSubdivide(true);
vis.append("svg:g")
.attr("class", "x axis")
.attr("transform", "translate(0," + (HEIGHT - MARGINS.bottom) + ")")
.call(xAxis);
vis.append("svg:g")
.attr("class", "y axis")
.attr("transform", "translate(" + (MARGINS.left) + ",0)")
.call(yAxis);
and css code
和css代码
.axis path, .axis line
{
fill: none;
stroke: #777;
shape-rendering: crispEdges;
}
.tick
{
stroke-dasharray: 1, 2;
}
please share your answer :)
请分享你的答案:
1 个解决方案
#1
6
I'm not sure but this should help you,
我不确定,但这对你有帮助,
encapsulation mode
封装模式
and/or
和/或
piercing CSS combinators >>>, /deep/
and ::shadow
穿透CSS组合器>>>,/deep/ and::shadow
look here - Styles in component for D3.js do not show in angular 2
看看这里——D3的组件样式。在角度2中不显示js
Best luck !
最好的运气!
#1
6
I'm not sure but this should help you,
我不确定,但这对你有帮助,
encapsulation mode
封装模式
and/or
和/或
piercing CSS combinators >>>, /deep/
and ::shadow
穿透CSS组合器>>>,/deep/ and::shadow
look here - Styles in component for D3.js do not show in angular 2
看看这里——D3的组件样式。在角度2中不显示js
Best luck !
最好的运气!