inductiveautomation / ignition-sdk-examples

Ignition SDK Example Projects
164 stars 92 forks source link

Passing Properties into SVG (Prospective Components) #61

Closed jnylaan closed 3 years ago

jnylaan commented 3 years ago

Hello, I am having an issue passing dynamic text into an svg, I am trying to do this through the .tsx file .

Path to file: \ignition-sdk-examples\perspective-component\web\packages\client\typescript\components

`export class Conv extends Component<ComponentProps, any> { render() { // The props we're interested in. const { props: { url}, emit } = this.props; // Read the 'url' property provided by the perspective gateway via the component 'props'.

    // Note that the topmost piece of dom requires the application of events, style and className as shown below
    // otherwise the layout won't work, or any events configured will fail. See render of MessengerComponent in Messenger.tsx
    return (
       <div>   
           {...emit()}   
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100%" height="100%">
            <circle cx="50" cy="50" r="50" fill="orange"/>
            <text x="50" y="60" text-anchor="middle">{url}</text>
        </svg>
        </div>
    );
}

}`

jnylaan commented 3 years ago

image