SharePoint Script Editor

Muhamad Fahrurrozi 41 Reputation points
2022-11-24T06:08:01.88+00:00

Dear All,

I have tried to use this with Modern Script Editor.
263729-image.png

And it's worked as expected. But, I'm wondering to use SharePoint List as a data source like this one, I have tried but the chart not displayed.

Regards

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,211 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,789 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Tong Zhang_MSFT 9,141 Reputation points
    2022-11-25T06:00:17.357+00:00

    Hi @Muhamad Fahrurrozi ,

    According to my research and testing, I can successfully use the code in the article you provided to create an organization chart for SharePoint list items. Here is my test code, please use the code in the attachment and check if it works: 264069-test-1-1.txt

    Note: Select Enable classic _spPageContextInfo
    264030-01.png

    My test result:

    264078-image.png

    List:

    264079-image.png

    Hope it can help you. Thanks for your understanding.

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

  2. Muhamad Fahrurrozi 41 Reputation points
    2022-11-25T07:30:07.107+00:00

    Hi @Tong Zhang_MSFT ,

    Thank you for your response.

    Is it possible to put a hyperlink? So, when I click "Joe Derek" or "Michael Jordan" it will redirect to specific Link. Structure column SharePoint List like below image. I have tried using this below html and it works, but it would be perfect if possible to put Link in SharePoint List directly, not a code.

    <html>  
      <head>  
        <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>  
        <script type="text/javascript">  
          google.charts.load('current', {packages:["orgchart"]});  
          google.charts.setOnLoadCallback(drawChart);  
      
          function drawChart() {  
            var data = new google.visualization.DataTable();  
            data.addColumn('string', 'Name');  
            data.addColumn('string', 'Manager');  
            data.addColumn('string', 'ToolTip');  
      
            // For each orgchart box, provide the name, manager, and tooltip to show.  
            data.addRows([  
              [{'v':'<p style="color:green;">Head</p>'}, '', ''],  
    		   [{'v':'<p style="color:green;">Sub-Head</p>'},  
               '<p style="color:green;">Head</p>', ''],  
    		   [{'v':'<a href="https://sharepoint.com" style="color:orange;" target="_blank">SharePoint Team</a>'},  
               '<p style="color:green;">Sub-Head</p>', '']  
            ]);  
      
            // Create the chart.  
            var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));  
            // Draw the chart, setting the allowHtml option to true for the tooltips.  
            chart.draw(data, {'allowHtml':true});  
          }  
       </script>  
        </head>  
      <body>  
        <div id="chart_div"></div>  
      </body>  
    </html>  
    

    264165-image.png
    264134-image.png
    264120-image.png