andredumas / techan.js

A visual, technical analysis and charting (Candlestick, OHLC, indicators) library built on D3.
http://techanjs.org/
MIT License
2.4k stars 534 forks source link

Custom class per supstance #241

Closed benoist closed 5 years ago

benoist commented 5 years ago

Hi,

How can I add a custom class for a substance? I would like to have supstances on the same side with different colors. The substance takes a value, start and end, but I would like to add a class to that as well so I can change the color in the CSS. Is there a way to do that already, or does that require a library change?

Thanks!!

benoist commented 5 years ago

NVM, found a way to do it :)

svg.selectAll("g.supstances")
  .datum(supstanceData)
  .call(supstance)
  .call((a) => a.selectAll(".scope-supstance").attr("class", (d) => ".scope-supstance " + d.color));