Assign/Replace product
The diag.assignProduct method can be used to assign or replace a product to some plan regions, and get the related estimation.
The following example demonstrates how to assign/replace the product to specified plan regions.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>M2Diagram assign/replace the product demo</title>
<script src="https://diagram.measuresquare.com/scripts/m2diag.js"></script>
</head>
<body>
<div style="text-align:center;margin-top:20px;">
<div id="canvas" style="width:750px;height:450px;border:1px solid #333;"></div>
</div>
<script>
let options = { apiKey: 'YOUR_PUBLISHABLE_API_KEY', panZoom: false };
let diag = new m2Diag.Engine('canvas', options);
diag.state.onDataLoaded = function () {
// do something
}
diag.loadCloudData('YOUR_PROJECT_ID');
// assign a product in some action
function someClick() {
diag.assignProduct(prod, regionIds);
}
</script>
</body>
</html>
See more API detail about diag.assignProduct
You can go to here to see the demo and play more.