Home Forums Chart Support Time in Axis Y and sync cross hair in multiple series

Time in Axis Y and sync cross hair in multiple series

Viewing 3 posts - 1 through 3 (of 3 total)
  • #36577

    Hello,
    I create a chart with 3 series, and on the axis Y there is time.
    To create this chart I follow this example.
    But if I want to use the folliwing option I can see the value only of one serie and not of all the three series when I put the mouse on the chart:

     toolTip:{
       shared: true,
     }

    The following function elaborate only one and not all the three series:

    contentFormatter: function (e) {
      return CanvasJS.formatDate(e.entries[0].dataPoint.y,"hh:mm:ss TT");	//Formatting dateTime in ToolTip
     }  

    Can someone help me?

    Thank you very much

    #36585

    @begins,

    In order to display y values of all the dataSeries in a toolTip, you can loop through each of the e.entries and display the respective y values in appropriate format. Please check out the below code snippet.

    contentFormatter: function (e) {
      var content = "";
      content += e.entries[0].dataPoint.x + "<br/>"
      for(var i=0; i<e.entries.length; i++) {
        content += "<span style= \"color:"+e.entries[i].dataSeries.color + "\">" + e.entries[i].dataSeries.name + "</span>: " + CanvasJS.formatDate(e.entries[i].dataPoint.y,"hh:mm:ss TT") + " <br/>";	//Formatting dateTime in ToolTip
      }
      return content;
    } 

    Also, take a look at this JSFiddle for complete code.

    Display all dataseries value in ToolTip for Multi Series Chart with datetime value in y axis

    —-
    Manoj Mohan
    Team CanvasJS

    #36588

    Thank you very much Manoj Mohan, it seems to work perfectly!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.