Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
add reflow examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sdadn committed Apr 15, 2024
1 parent 7217a45 commit f7d8324
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';

import Button from 'terra-button';

Expand All @@ -21,7 +21,7 @@ const graphConfig = {
upperLimit: 20,
},
},
allowCalibration: false,
allowCalibration: true,
};

// graph dataset
Expand Down Expand Up @@ -51,32 +51,44 @@ const dataset1 = {

// graph rendering
let graph;

const BasicReflowExample = () => {
const [allowCalibrationStatus, SetAllowCalibrationStatus] = useState(graphConfig.allowCalibration.toString());

React.useEffect(() => {
graph = Carbon.api.graph(graphConfig);
graph.loadContent(Carbon.api.line(dataset1));
}, []);

const handleClick = () => {
if (!graph) { return; }


const handleClickToggleCalibration = () => {
graph.config.allowCalibration = !graph.config.allowCalibration;
SetAllowCalibrationStatus(graph.config.allowCalibration.toString());

// graph.config.axis.y.lowerLimit = -50;
// graph.config.axis.y.upperLimit = 20;
graph.reflowMultipleDatasets();
};

graph.config.axis.y.lowerLimit = -50;
const handleClickUpdateLimits = () => {
graph.config.axis.y.domain.lowerLimit = -52;
graph.config.axis.y.domain.upperLimit = 52;

graph.reflowMultipleDatasets();
};

// graph.config.allowCalibration = !graph.config.allowCalibration;
const handleClickReset = () => {
graph.config.axis.y.domain.lowerLimit = 0;
graph.config.axis.y.domain.upperLimit = 20;

graph.reflowMultipleDatasets();
};

return (
<>
<Button text="Toggle Calibration" onClick={handleClick} />
<Button text="Toggle Calibration" onClick={handleClickToggleCalibration} />
<Button text="Update Axis Limits" onClick={handleClickUpdateLimits} />
<Button text="Reset" onClick={handleClickReset} />
<div>
AllowCalibration:
{allowCalibrationStatus}
</div>
<div id="basic-reflow-example" />
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const graphConfig = {
upperLimit: 20,
},
},
panning: {
enabled: true,
},
};

// graph dataset
Expand Down

0 comments on commit f7d8324

Please sign in to comment.