Sisense Community logo
     
    • Community Feedback
    • Chapters
    • Events
    • Forums
      • Help and How To
      • Product Feedback Forum
      • Strategy & Use Cases
    • Blogs
    • KB Docs
      • KB Docs
      • Add-Ons & Plug-Ins
      • APIs
      • Best Practices
      • Blox
      • CDT
      • Cloud Managed Service
      • Data Models
      • Data Sources
      • Embedding Analytics
      • How-Tos & FAQs
      • Onboarding
      • PySisense
      • Security
      • Sisense Administration
      • Sisense Intelligence & AI
      • Troubleshooting
      • Widget & Dashboard Scripts
    • Support
    • Learning
      • Sisense Academy: Free Courses and Certifications
      • Official Developer Documentation
      • Official Product Documentation
      • Official Sisense Youtube Channel
      • Sisense Compose SDK Playground
      • Official Sisense Discord
    • Use Case Gallery
    •      
    Discussions
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
    Discussions
    • TagsChevronRightIcon
    FAQ: Embedding and Sisense.js
      • Embedding AnalyticsChevronRightIcon

      Invoke Custom Dashboard Function From SisenseJS

                       

      Question: how to invoke functions from within sisenseJS? I would like to understand this invocation process for a function that lives within a dashboard script AND a plugin. Answer: Functions in a widget/dashboard script or a plugin aren't (and cannot be) automatically exposed somewhere, because they run in an enclosed scope just like any Javascript function (or any scoped block for that matter, including loops for example): function myScopedBlock() { function myInternalFunc() { // do something } } console.log(myInternalFunc); // undefined As you can see in the example above, simply defining a function in a scoped block does not automatically allow you to invoke it elsewhere, and you need to explicitly expose it - how that's done depends on the environment you're working in. For example, in a Node.js script using CommonJS modules, you would use the module.exports syntax. In the case of dashboard or widget scripts, in their context you always have access to an object called either "widget" or "dashboard" respectively, which represents the current instance of the dashboard/widget the script is running in. You can attach custom properties to that object, which can be functions as well, for example in a widget script you could add: widget.myFunc = function () { console.log('this is a custom function in widget ' + widget.oid); }; Now in your Sisense.js code you can wait for the widget to load, and once it does, you will have access to the function you've attached to it: Sisense.connect('http://localhost:30845/').then(function(app) { app.dashboards.load('5e9d6748d81796002d373530').then(function(dash) { let widgetInstance = dash.widgets.get('5e9d676ed81796002d373533'); widgetInstance.container = document.getElementById('widget1'); widgetInstance.on('ready', function(sender, ev){ // "sender" is your widget object in the event's context sender.myFunc(); }); dash.refresh(); }); }); Same can be done for dashboards.

      intapiuser
      intapiuserPosted 3 years ago
      0
               
      • Embedding AnalyticsChevronRightIcon

      Accessing Dashboard And Widgets Without Logging In Through SSO

               

      Question: Suppose I have the website which will show some of the Sisense widgets. User is already logged in and wants to see the widgets. User doesn't want to login again through SSO login page url. Is it possible to achieve? Answer: The normal flow of SSO (whether in Sisense itself or Sisense.js-embedded applications) is: Sisense looks for a cookie representing authentication by the user Only If no cookie exists , Sisense redirects the request to the SSO handler SSO handler looks for it's own cookie (or whichever other method of checking for existing session) Only if user is not authenticated at all , request is redirected to a login page Within that flow, once a user has authenticated and while the session is active and valid, he should never be redirected to the login page - even if he is redirected via the SSO handler behind the scenes, which should have minimal to no impact on performance or latency. If this is happening on your environment, it might be due to an incorrect implementation of the SSO handler.

      intapiuser
      intapiuserPosted 3 years ago
      0
               
      • Embedding AnalyticsChevronRightIcon

      Missing Legends In Embedded Widgets

               

      Question: I have used Sisense.JS to embed multiple widgets into a web page. However, none of the Legends are displaying, rendering the widgets useless. Is it possible to pull through the legend? Answer : Widgets rendered using Sisense.JS follow the same behavior seen in Sisense dashboards. There are 2 factors in whether a widget displays the legend (assuming it has one): Legend must be turned on via the widget's style panel Widget size must be above minimal threshold (changes from widget to widget - if the widget is too small, legend will be hidden to allow for better overall visualization) Please make sure your widget meets these two criteria.

      intapiuser
      intapiuserPosted 3 years ago
      0
               
      • How-Tos & FAQsChevronRightIcon

      Post Widget JAQL And Refresh Embedded Widget To Show Results

               

      Question: How can I update an embedded widget using a JAQL query and post to /jaql using sisenseJS? Answer: JAQL is just the syntax for querying data - it is not inherently bound to any specific widget or dashboard, which in turn means that executing any JAQL query has no affect on any widgets or dashboards, just like executing a SQL query against MySQL would not affect any web components that visualize data based on that same MySQL. To make a widget show data from a different query, you need to update that widget's metadata. and then refresh it. But before diving into how that's done, it's important to clarify your last sentence: "just for the local user": If you mean the changes should be applied only to one given user and not other users who can view the same dashboard, but persisted for these users, hen you do want to have those changes saved. Each user has their own instance of a dashboard - and changes they make are not reflect to other user, with the exception of the dashboard's owner who can make changes and re-publish the dashboard to apply these changes to all users with whom the dashboard is shared. If you mean these changes should apply only immediately, for a given person looking at the widget, and not persist upon refresh of the page, then you would make changes to the widget's metadata  on the client side (no REST calls required) and make it reload, and below is an example of how that can be done And this is a simple and crude example of how you could change a widget's metadata in runtime and make it re-render with new data, on client only: prism.on('beforemenu', (ev, args) => { // we want to add an item to a specific menu - widget in dashboard if (args.settings.name === 'widgetindashboard') { // save the widget instance to use in the closure const widget = args.settings.scope.widget; // add a button to the menu args.settings.items.push({ command: { title: 'Remove brand', canExecute: () => { return true; }, execute: () => { // Get the columns panel const panel = widget.metadata.panel('columns'); // Find the index of the 'brand' column in the panel const idxToRemove = panel.items.findIndex(i => i.jaql.title == 'Brand') // remove the item panel.items.splice(idxToRemove, 1) // refresh the widget, without saving these changes widget.refresh(); } } }); } }); In this example the change is done via a menu item added to the "widgetindashboard" menu but of course as long as you have the widget object accessible you could implement similar logic anywhere else.

      intapiuser
      intapiuserPosted 3 years ago
      0