I created a scatterChart from nvd3 and then tried to customize the tooltip the way it is described here:
nvd3 piechart.js - How to edit the tooltip?
using chart.tooltip.contentGenerator() approach:
import React from 'react'
import * as d3 from 'd3';
import nvd3 from 'nvd3';
var nv = nvd3;
import BarChart from './BarChart';
class ScatterChart extends React.Component {
constructor(props){
super(props);
this.createScatterChart = this.createScatterChart.bind(this);
}
...
...
chart.tooltip.contentGenerator(function (d) {
var html = "<div>";
d.series.forEach(function(elem){
Object.keys(data_obj).forEach(function(key_1) {
var outer_obj = data_obj[key_1];
if (outer_obj["key"] === elem.key) {
var expr = outer_obj["values"][0]["expr"];
html += "<p>" + elem.key + "</p>"
html += "<p>x = " + d.value + ", y = " + elem.value + "</p>"
html += "<p><BarChart datum = " + makeDatumForBarChart(expr) + "/></p>"
}
});
})
html += "</div>";
return html;
})
<BarChart datum = { datum }/> - tag there is discreteBarChart also from nvd3. BarChart react component is not called here (I am setting breakpoints up in that BarChart.jsx file) for some reason, so the barchart is not rendered (the tooltip is working fine, except no barchart is drawn). How to make it render?
BarChart code looks like that (already fixed): React: Pass function to a child not working
Any suggestions would be greatly appreciated.
