Reputation: 2023
I have one class which has state options imported from other file.
import heatChartOptions from './chartOptions/heatChartOptions';
class HeatContainer extends Component {
state = {
options : heatChartOptions.options
}
// Render app with demo chart
loadHierarchy = (obj) => {
console.log(obj,'heat');
}
}
Where heatChart options has object which call a method on click. But that method is available on our class. How to call that particular method from object.
import HeatChart from '../heatChartContainer';
export default {
axisColors: axisColors,
options: {
credits: {
enabled: false
},
chart: {
height: 428
},
colorAxis: {
minColor: axisColors.minColor,
maxColor: axisColors.maxColor,
labels: {
style: style
}
},
tooltip: {
useHTML: true,
padding: 2,
headerFormat: '<div class="padding-0-10 padding-b-10"><table>',
pointFormat: '<tr><td colspan="2"><h5><strong>{point.name}</strong></h5></td></tr>' +
'<tr><td style="padding-right: 5px;">{point.type} Count: </td><td>{point.colorValue}</td></tr>' +
'<tr><td style="padding-right: 5px;">Device Count: </td><td>{point.value}</td></tr>',
footerFormat: '</table></div>'
},
plotOptions: {
series: {
cursor: 'pointer',
enabled: true,
allowOverlap: true,
style: {
fontFamily: "'univers', Arial, sans-serif",
fontSize: 12,
color: "#FFF",
stoke: "#FFF"
}
},
point: {
events: {
click: function() {
HeatChart.loadHierarchy({chartType:'momentaryDisturbance', name:this.name, previousLevel: this.previousLevel}) //this is the one I need to call
}
}
}
}
}
}
I just called using HeatChart, Can I instantiate the heatchart class so that I can its method. Or is there any other way I can achieve this. Or I need functional component only to achieve this with the help of props.
Upvotes: 1
Views: 51
Reputation: 2023
It works for me if I create a instance using my class import like below
new HeatChart().loadHierarchy({chartType:'momentaryDisturbance', name:this.name, previousLevel: this.previousLevel})
Upvotes: 1