AstroDraw / AstroChart

A free and open-source TypeScript library for generating SVG charts to display planets in astrology.
https://astrodraw.github.io
MIT License
200 stars 51 forks source link

AstroChart use in React? #20

Closed skayka closed 2 years ago

skayka commented 2 years ago

Hello good men.

I tried to use AstroChart in React and couldn't do it.

Is there a known way to use it with React?

Thank you and sorry if I wrote this in the wrong place.

afucher commented 2 years ago

Hey @skayka , In the current version, to use in React, you need to:

  1. Download the latest version from releases
  2. add it manually to the index.html
    <script src="/vendor/astrochart.js"></script>
  3. Call astrochart inside useEffect from a component
    useEffect(() => {
    const data = {
      "planets":{"Moon":[0], "Sun":[30], "Mercury":[60] },
      "cusps":[300, 340, 30, 60, 75, 90, 116, 172, 210, 236, 250, 274]  
    }
    const chart = new window.astrology.Chart( 'paper', 600, 600);
    chart.radix( data );    
    })

I'm actually working on a new version of AstroChart to make it easier, but I have no estimation to finish it. Also, I started a documentation that uses AstroChart with React, you can take a look here

skayka commented 2 years ago

Thank you, it worked.

Wow, your chart is awesome! Thank you.

Would you please be so kind to tell me if there is a way to change a font?

Thank you so much for you help.

afucher commented 2 years ago

What do you mean by change font?