6

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?

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

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

please share your answer :)

Lazar Krstic
  • 91
  • 2
  • 8

1 Answers1

7

I'm not sure but this should help you,

encapsulation mode

and/or

piercing CSS combinators >>>, /deep/ and ::shadow

look here - Styles in component for D3.js do not show in angular 2

Best luck !

Community
  • 1
  • 1
micronyks
  • 54,797
  • 15
  • 112
  • 146