cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
Introduction
Make your tool-tips talk by copy pasting this script within the script window of your widget. It works for Column and Line charts.
NOTE: This script leverages google' s speech synthesis API. It is currently only supported on Chrome and Safari. It is not supported on IE. It is a maturing technology and will crash on the odd occasion. You need to restart chrome to get it back up. This is 50% fun and 50% utility..:)
var synth = window.speechSynthesis;
var utterThis = new SpeechSynthesisUtterance('');
var voices = synth.getVoices();
var voice;


widget.on("beforedatapointtooltip", function (w, args) {
 // Cancel narrative from previous tool tip if still speaking
 try {
 if(synth.speaking) {
   synth.cancel();
  }
 }
 catch(e){}

 var dim = this.x;
 var m = this.y; 
 var i = args.context.pointScope.x;
 var s = args.context.pointScope.series;
 var xlabel = w.queryResult.xAxis.categories[i];
 var seriesName = s.name;
 var v = s.data[i].y;

 // var utterThis = new SpeechSynthesisUtterance('Hello');
 utterThis.text = seriesName + ' for ' + xlabel + ' is ' + valToTxt(v);
 synth.speak(utterThis);
});


function valToTxt(n) { 
 var t = '' + n.toFixed(2);
 if(n >= 1000000.0) {
 t = '' + (n/1000000.0).toFixed(2) + ' million';
 }
 else if(n >= 1000.0) {
 t = '' + (n/1000.0).toFixed(2) + ' thousand';
 }

 return t;
}
Version history
Last update:
‎03-02-2023 09:16 AM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?

Email [email protected]

Share this page: