加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular 2.0和D3.js不对svg应用Css

发布时间:2020-12-17 17:46:03 所属栏目:安全 来源:网络整理
导读:参见英文答案 Styles in component for D3.js do not show in angular 2????????????????????????????????????6个 我正在使用Angular 2.0 TypeScript和d3.js libary来创建grafic.我正在尝试在asix上应用css(大多数importand shape-rendering:crispEdges;).
参见英文答案 > Styles in component for D3.js do not show in angular 2????????????????????????????????????6个
我正在使用Angular 2.0 TypeScript和d3.js libary来创建grafic.我正在尝试在asix上应用css(大多数importand shape-rendering:crispEdges;).你有什么主意吗?

这是代码

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; }),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);

和css代码

.axis path,.axis line
{
      fill: none;
      stroke: #777;
      shape-rendering: crispEdges; 
}
.tick
{
      stroke-dasharray: 1,2;
}

请分享你的答案:)

解决方法

我不确定,但这对你有帮助,

封装模式

和/或

刺穿CSS组合器>>>,/ deep /和:: shadow

看这里 – Styles in component for D3.js do not show in angular 2

好运 !

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读