Issue #422 new

highlighter should be more flexible

Anonymous created an issue

The graph component works great! But the highlighter feature could be more flexible. I have a situation where I want to show dots on a chart and make a highlight on each dot showing an amount like this:

£ 120,- $ 80,-

I can't see this is possible with the current highlighter. I can specify '<br/>' as tooltipSeparator, but I can't make difference currency signs on each line.

It would be cool to have a format-property, where you could write something like this:

format: '£ %x,-<br/>$ %y'

Comments (2)

  1. casimirenslip

    Hi,

    I made some changes (very little changes) in highlighter plugin to put custom function to create my html content :

    line 312, I added

    if (typeof opts.formatString === 'function') {
        var fn = opts.formatString;
        str = fn(neighbor.data);
     }
    else
    

    juste before this line

     if (typeof opts.formatString ===  'string') {
                    str = $.jqplot.sprintf.apply($.jqplot.sprintf, [opts.formatString].concat(neighbor.data));
                }
    

    So, I can put in my javascript jqplot something like that :

    useAxesFormatters: false,
    yvalues: 5,
    formatString:function(data) {
          var d = new Date(data[0]);
          var dtResult = d.format("longDateTime3");
    
          var html = [];
          html.push("<table>");
          html.push("<tr><td><b>"+ i18n.RESULT_DT_TM +": </b></td><td>"+ dtResult +"</td></tr>");
          html.push("<tr><td><b>"+ data[6] +"</b></td><td>"+data[1]+" "+data[7]+"</td></tr>");
          html.push("</table>");
          return html.join("");
    }
    

    Hope it helps, and if this modification can be put in official plugin, it would be great !

  2. Log in to comment