function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
병훈 송병훈 송 

Javascript Library in Lightning Component

How to, Javascript Library in Salesforce Lightning Component?

I want make Draw Flow Chart in Lightning Component, (just draw)

I found this : https://gojs.net/latest/samples/flowchart.html 

I want apply Library in Lightning Component


I made component, and Component Code is  : 
 
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" > 
<aura:handler name="init" value="{!this}" action="{!c.doInit}" /> 
<ltng:require scripts="{!join($Resource.Tree + '/release/go.js', $Resource.Tree + '/assets/js/goSamples.js')}"/> </aura:component>

Controller Code is : 
 
({  
    init: function() {
        if (window.goSamples) goSamples();  // init for these samples -- you don't need to call this
        var ab = go.GraphObject.make;  // for conciseness in defining templates
        
        myDiagram =
            ab(go.Diagram, 'myDiagramDiv',  // must name or refer to the DIV HTML element
              {
                  initialContentAlignment: go.Spot.Center,
                  allowDrop: true,  // must be true to accept drops from the Palette
                  'LinkDrawn': showLinkLabel,  // this DiagramEvent listener is defined below
                  'LinkRelinked': showLinkLabel,
                  scrollsPageOnFocus: false,
                  'undoManager.isEnabled': true  // enable undo & redo
              })
        
        // when the document is modified, add a "*" to the title and enable the "Save" button
        myDiagram.addDiagramListener('Modified', function(e) {
            var button = document.getElementById('SaveButton');
            if (button) button.disabled = !myDiagram.isModified;
            var idx = document.title.indexOf('*');
            if (myDiagram.isModified) {
                if (idx < 0) document.title += '*';
            } else {
                if (idx >= 0) document.title = document.title.substr(0, idx);
            }
        }
	}
})



does not saved.... error

How can I do?​

plz
Help me
Best Answer chosen by 병훈 송
Ravi Dutt SharmaRavi Dutt Sharma
Hi,

Are you getting a compile time error? If yes, can you pleae share the error.

One more thing - the code which you have in init method should actually be  inside the afterScriptsLoaded method like below:
 
<ltng:require scripts="{!join($Resource.Tree + '/release/go.js', $Resource.Tree + '/assets/js/goSamples.js')}" afterScriptsLoaded="{!c.scriptsLoaded}"/>

 

All Answers

Ravi Dutt SharmaRavi Dutt Sharma
Hi,

Are you getting a compile time error? If yes, can you pleae share the error.

One more thing - the code which you have in init method should actually be  inside the afterScriptsLoaded method like below:
 
<ltng:require scripts="{!join($Resource.Tree + '/release/go.js', $Resource.Tree + '/assets/js/goSamples.js')}" afterScriptsLoaded="{!c.scriptsLoaded}"/>

 
This was selected as the best answer
Anand Kumar 289Anand Kumar 289
is your component ready ?? working properly ??