Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
git clone https://github.com/qlik-demo-team/qdt-components-tutorial-001
cd qdt-components-tutorial-001
npm i
git checkout start
npm run dev
import { qdtEnigma } from 'qdt-components';
const config = {
host: 'sense-demo.qlik.com',
secure: true,
port: 443,
prefix: '',
appId: '372cbc85-f7fb-4db6-a620-9a5367845dce', // Consumer Sales
};
const appPromise = qdtEnigma(config);
appPromise.then((app) => { app.clearAll(); });
export default appPromise;
// MyChart.js
import { qdtCompose, QdtPicasso, useBarChartSettings } from 'qdt-components';
import appPromise from './config/app';
// hypercube defintion
const MyChart = () => {
const barChart = useRef(null);
useEffect(() => {
(async () => {
const settings = useBarChartSettings();
const app = await appPromise;
qdtCompose({
app,
element: barChart.current,
component: QdtPicasso,
options: {
settings,
},
properties: hypercube,
loading: () => null,
})
})()
}, [])
return (
<div>
<h2>My Charts</h2>
<div ref={barChart} style={{ height: 400, paddingTop: 50 }} />
</div>
)
}
export default MyChart;
import { qdtCompose, QdtPicasso, useBarChartSettings, usePieChartSettings } from 'qdt-components';
import appPromise from './config/app';
// hypercube
const MyChart = () => {
const barChart = useRef(null);
const pieChart = useRef(null); // NEW: pie chart ref object
useEffect(() => {
(async () => {
// old code
const pieSettings = usePieChartSettings();
qdtCompose({
app,
element: pieChart.current,
component: QdtPicasso,
options: {
settings: pieSettings,
},
properties: hypercube,
loading: () => null,
})
})()
}, [])
return (
<div>
<h2>My Charts</h2>
<div ref={barChart} style={{ height: 400, paddingTop: 50 }} />
<div ref={pieChart} style={{ height: 400, paddingTop: 50 }} />
</div>
)
}
import { qdtCompose, QdtPicasso, useBarChartSettings, usePieChartSettings, QdtButton } from 'qdt-components';
// OLD CODE
const MyChart = () => {
const barChart = useRef(null);
const pieChart = useRef(null);
const clearButton = useRef(null);
useEffect(() => {
(async () => {
// OLD CODE
qdtCompose({
app,
element: clearButton.current,
component: QdtButton,
options: {
type: 'clearSelections',
label: 'Clear Selections'
}
})
})()
}, [])
return (
<div>
<h2>My Charts</h2>
<div ref={clearButton} style={{ margin: '10px auto', width: 250 }} />
<div ref={barChart} style={{ height: 400, paddingTop: 50 }} />
<div ref={pieChart} style={{ height: 400, paddingTop: 50 }} />
</div>
)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.