1

In d3, I make a lot of elements like this:

this.title = svg.append('text')
    .attr('class', 'graph-title')
    .text('blah blah blah');

I was hoping I could put that class in the CSS local to the component creating this svg, but you can't refer to the local css this way. What I did above would only work if I put the relevant style into the global CSS, which for reusability reasons is not what I'd like to do.

Is there some way I can programmatically add the local css class to this dynamically-created element?

1
  • 1
    It's not clear what you're asking. What is the local component? What do you want to achieve by mixing this classes? Maybe there is a workaround for your problem. Commented Sep 5, 2016 at 4:05

1 Answer 1

1

You can use >>> (or /deep/) to address dynamically added elements that don't get the encspsulation attributes (_ng_content...) added from styles added to components:

:host >>> graph-title {
  ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.