# CalculationFinished Event

### What is the CalculationFinished event?

The `CalculationFinished` event is a custom browser event that gets automatically dispatched when a calculation process completes. This event allows you to programmatically detect when calculations are done and access the results.

### When is this event triggered?

The event is fired immediately after any calculation finishes processing.

### How do I listen for this event?

You can listen for the `CalculationFinished` event using a standard event listener:

```javascript
window.addEventListener('CalculationFinished', (event) => {
  const result = event.detail;
  console.log('Calculation completed:', result);
  
  // Your custom logic here
  handleCalculationResult(result);
});
```

### What data does the event contain?

The calculation results are available in the `event.detail` property.

```json
[
    {
        "unit": {
            "svg": "<svg image>",
            "svgM": null,
            "zero": {
                "left": 457.015,
                "bottom": 563.5
            },
            "imageSize": {
                "width": 891,
                "height": 891
            },
            "name": "5m x 5m",
            "id": "<unit-id>",
            "unitDetails": {
                "id": "<unit-id>",
                "name": "5m x 5m",
                "unit": {
                    "ID": "unit-id",
                    "unitName": "5m x 5m",
                    "unitWidth": "5",
                    "unitHeight": "2.4",
                    "unitDepth": "5"
                },
                "dimensions": {
                    "width": 500,
                    "depth": 500,
                    "height": 240
                }
            }
        },
        "items": [
            {
                "id": "bbq",
                "x": -88.248457,
                "y": -80.79013988439307,
                "orientation": "turned",
                "scale": false,
                "width": 49.5,
                "volume": 0.50642262,
                "quantity": 1,
                "image": null
            }
        ],
        "totalItemsWeight": 908.4,
        "totalVolume": 15.765080274,
        "animationDone": true
    }
]
```

### Best Practices

* **Always add the event listener before initiating calculations** to ensure you don't miss the event.
* **Remove event listeners** when they're no longer needed to prevent memory leaks.

### Browser Compatibility

This feature uses the standard `CustomEvent` API, which is supported in all modern browsers. For older browser support, you may need a polyfill.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.calcumate.co/frequently-asked-questions/calculationfinished-event.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
