I download the code "resource-histogram" from:
https://bryntum.com/products/gantt/examples/frameworks/react/javascript/resource-histogram/build/
And I read loadInlineData function in: https://bryntum.com/products/gantt/docs/api/Gantt/model/ProjectModel#function-loadInlineData
I want to load data from loadInlineData, but the Chart shows message "No records to display" (console.log('Raw projectFileData:') still show data)
Could you help me?
This is my code:
// this is main file:
import {
BryntumGantt,
BryntumGanttProjectModel,
BryntumResourceHistogram,
BryntumSplitter
} from '@bryntum/gantt-react';
import { Fragment, useEffect, useRef } from 'react';
import { ganttProps, histogramProps, projectProps } from './GanttConfig';
import projectFileData from './data1.json';
import './styles/CustomStyle.scss';
export default function CapacityProjection() {
const projectRef = useRef<BryntumGanttProjectModel>(null);
const ganttRef = useRef<BryntumGantt>(null);
const histogramRef = useRef<BryntumResourceHistogram>(null);
useEffect(() => {
if (projectFileData && projectRef.current?.instance) {
// Raw data
console.log('Raw projectFileData:', JSON.stringify(projectFileData));
projectRef.current.instance.loadInlineData(projectFileData);
}
// setup partnership between gantt and histogram
if (histogramRef.current?.instance && ganttRef.current?.instance) {
histogramRef.current.instance.addPartner(ganttRef.current.instance);
}
}, []);
return (
<Fragment>
<BryntumGanttProjectModel ref={projectRef} {...projectProps} />
<BryntumGantt ref={ganttRef} {...ganttProps} project={projectRef} />
<BryntumSplitter />
<BryntumResourceHistogram ref={histogramRef} {...histogramProps} project={projectRef} />
</Fragment>
);
}
// this is config file:
export const projectProps = {
startDate: '2019-01-16',
endDate: '2019-02-13',
// transport: {
// load: {
// url: './data1.json'
// }
// },
autoLoad: true,
autoSetConstraints: true,
validateResponse: true
};
export const ganttProps = {
dependencyIdField: 'sequenceNumber',
resourceImageFolderPath: 'users/',
startDate: '2019-01-11',
endDate: '2019-03-24',
viewPreset: 'weekAndDayLetter',
columnLines: true,
labelsFeature: {
before: {
field: 'name',
editor: {
type: 'textfield'
}
}
},
columns: [
{ type: 'name', width: 280 },
{ type: 'resourceassignment', showAvatars: true, width: 170 }
]
};
export const histogramProps = {
resourceImagePath: 'users/',
startDate: '2019-01-11',
endDate: '2019-03-24',
viewPreset: 'weekAndDayLetter',
hideHeaders: true,
rowHeight: 50,
showBarTip: true,
scheduleTooltipFeature: false,
columns: [{ type: 'resourceInfo', field: 'name', showEventCount: false, width: 410 }]
};
Result has no data:
And if use "url: './data1.json'" then result has data:
export const projectProps = {
startDate: '2019-01-16',
endDate: '2019-02-13',
transport: {
load: {
url: './data1.json'
}
},
autoLoad: true,
autoSetConstraints: true,
validateResponse: true
};