The issue is the current version of jquery.flot.tooltip.js is at V0.6.1 and the last one is V0.9.0.
V0.9.0 is passing 4 parameter :
// if it is a function callback get the content string
if (typeof(content) === 'function') {
content = content(item.series.label, x, y, item);
}
And V0.6.1, only two:
In modules\backend\assets\foundation\migrate\vendor\flot\jquery.flot.tooltip.js:
// if it is a function callback get the content string
if( typeof(content) === 'function' ) {
content = content(item.series.data[item.dataIndex][0], item.series.data[item.dataIndex][1]);
}
My code (js part - itās working well, except I donāt have the parameters) :
<script>
$(document).render(function () {
// Find the chart element
var chartElement = $('[data-control="chart-line"]');
// Check if the chart element exists
if (chartElement.length > 0) {
// Get the chartLine instance
var chartLineInstance = chartElement.data('october.chartLine');
// Check if the chartLine instance exists
if (chartLineInstance) {
// Get the existing chart options
var chartOptions = chartLineInstance.chartOptions;
// Update the tooltipOpts content property with a function
chartOptions.tooltipOpts.content = function (label, xval, yval, flotItem) {
return 'HD Activity : ' + flotItem.series.hd_activities_count + ' | Regular Activities : ' + flotItem.series.regular_activities_count + ' | Total : ' + yval;
};
// Update the chart with the modified options
chartLineInstance.rebuildChart();
} else {
console.error('ChartLine instance not found.');
}
} else {
console.error('Chart element not found.');
}
});
</script>
How can I update the default version of modules\backend\assets\foundation\migrate\vendor\flot\jquery.flot.tooltip.js ? or is this define in OctoberCMS and itās not ātouchableā ?
> prod
> npm run production
> production
> mix --production
'mix' is not recognized as an internal or external command,
operable program or batch file.
Alright, it successfully compiled and now, Iām seeing the 4 values being logged !!
Thank you. I will test more tomorrow and give an example of a solution here and see if there is no apparent bug - I donāt have a lot of widget that are using the āflotā libraries.
// if it is a function callback get the content string
if( typeof(content) === 'function' ) {
content = content(item.series.data[item.dataIndex][0], item.series.data[item.dataIndex][1]);
}
V0.9.0 :
// if it is a function callback get the content string
if (typeof(content) === 'function') {
content = content(item.series.label, x, y, item);
}
I suspect this is why it hasnāt been upgraded already. AFAIK, this library has been abandoned so there isnāt much incentive to go down this path. HTML has come a long way so it might be better to use a more modern charting tool.