Override D3 Dimple tooltips with chart data

I realize this might be my misunderstanding of Series with Dimple, but I can't figure out how to use getTooltipText () to override the tooltip with values ​​from the original data (like a chart), not just the axis (i.e. x, y, d).

Let's say I have data like this:

var data = [{"project_id":"1114","project_status":"Active","request_date":"2014-05-31","project_type":"CRISPR","cost":"0","due_date":"2014-08-14","service_durations_days":"75","days_overdue":"1","active_services":""},...]

      

And the chart / axes / series are initialized like this:

 var chart = new dimple.chart(svg, data);
 chart.addTimeAxis("x", "request_date","%Y-%m-%d","%Y-%m-%d");
 chart.addCategoryAxis("y", "project_type");
 var z = chart.addMeasureAxis("z", "cost");
 var s = chart.addSeries("project_status", dimple.plot.bubble);

      

Can I call from outside:

s.getTooltipText = function(e){
  console.log(e);
  return ["test"];
}

      

which returns project_id, service_durations_days, days_overdue or active_services objects to display?

+3


source to share


1 answer


You can include them in the batch definition and become available. The reason they are not immediately available is because Dimple aggregates the data to the level it needs to draw the chart, so if it doesn't require a field, it ignores it. You can include additional fields in the first parameter of the addSeries method:

chart.addSeries([
    "project_id",
    "service_durations_days",
    "days_overdue",
    "active_services",
    "project_status"
], dimple.plot.bubble);

      



Here is a fiddle modified from Greg Ross to show this alternative approach: http://jsfiddle.net/6n5r6vyb/3/

+3


source







All Articles