I am trying to do something like this:
I am using react and highcharts. I have a flat dataset that has just 3 columns from, to and value to draw a sankey chart. I am having trouble firing the prepareDataFunction and the callbacks for the getData function.
constreportComplete= () => {
pivotRef.current?.flexmonster.off('reportComplete', reportComplete);
createChart();
};
constcreateChart= () => {
pivotRef.current?.flexmonster.highcharts?.getData(
// Creating and configuring the chart
{
prepareDataFunction:function (input, _options) {
constdata=convertData(input.data);
console.log('data', data);
constchartOptions= {
series: [
{
data,
type:'sankey',
name:'Sankey demo series',
},
],
};
return chartOptions;
},
},
function (chartConfig) {
setChartOptions(chartConfig);
},
function (chartConfig) {
setChartOptions(chartConfig);
}
);
};
// flex moster configuration
<FlexmonsterReact.Pivot
toolbar={true}
ref={pivotRef}
licenseKey="key"
reportcomplete={reportComplete}
report={{
dataSource: {
type:'api',
url:'https://localhost:44351/api/reporting',
index:'sankey-dataset',
},
options: {
grid: {
type:'flat',
showGrandTotals:false,
showTotals:false,
},
},
slice: {
rows: [
{
uniqueName:'From',
},
{
uniqueName:'To',
},
{
uniqueName:'Value',
},
],
},
}}
/>
{chartOptions && <HighchartsReacthighcharts={Highcharts}options={chartOptions}/>}
Hello,
Thank you for contacting us.
We recommend setting the options.slice
property of the highcharts.getData
method and preprocessing the data for the Sankey chart. You are welcome to check the following JSFiddle for reference: https://jsfiddle.net/flexmonster/qgza3rc7/.
Please let us know if any questions arise.
Kind regards,
Nadia
Hello,
Hope you are doing well.
We were wondering if you had a chance to check the suggested approach. Could you please confirm if it works for you?
Looking forward to hearing from you.
Kind regards,
Nadia
I had a follow up question on this topic, will this work if the data source is a flexmonster api endpoint?
Like this:
dataSource: {
type:'api',
url:'https://localhost:44351/api/Reporting',
index:'index-1',
},
Or will it only work if the endpoint returns all the data at once?
Hello,
Thank you for the response.
Kindly note that integration with the Highcharts and other charting libraries is supported for all kinds of data sources, including type: "api"
. You are welcome to check our Technical Specifications page for reference: https://www.flexmonster.com/technical-specifications/#third-party-charts
We hope it helps. You are welcome to write to us in case further questions arise.
Kind regards,
Nadia