# InsightsChartEditor

## appmixer.ui.InsightsChartEditor

![](/files/-Lvp1JkjSLsmisR2Q4lq)

![](/files/-Lvp1kr-GuGqwoxzL-mF)

The appmixer.ui.InsightsChartEditor is a UI widget that allows the user to configure a new chart visualization of any data of their flows. Different types of charts are supported including bar, line, area, scatter, pie and more. Moreover, the user can select from a wide range of aggregations to create an aggregated visualization of their data such as Date Histogram, Sum, Min, Max, Average, Unique Count, Range and Filter.

| Method                                    | Description                                                                                                                                                                                                                                                                                                        |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `appmixer.ui.InsightsChartEditor(config)` | Constructor function that accepts `config` object. The `config` object must contain at least the `el` property that points to a container DOM element where the InsightsChartEditor will be rendered.                                                                                                              |
| `open()`                                  | Render the InsightsChartEditor inside its container.                                                                                                                                                                                                                                                               |
| `close()`                                 | Close the InsightsChartEditor.                                                                                                                                                                                                                                                                                     |
| `on(event, handler)`                      | React on events of the InsightsChartEditor. See below for the list of events the InsightsChartEditor supports.                                                                                                                                                                                                     |
| `off([event], [handler])`                 | Remove event listeners. If no arguments are provided, remove all event listeners. If only the `event` is provided, remove all listeners for that event. If both `event` and `handler` are given, remove the listener for that specific handler only.                                                               |
| `set(property, value)`                    | Set a property. Currently only "chartId" is supported. Use it to set the chart the chart editor should open for (`set("chartId", "123abc456")`). You can also call this to change the currently opened chart dynamically.                                                                                          |
| `get(property)`                           | Get a property value.                                                                                                                                                                                                                                                                                              |
| `state(name, value)`                      | Change the state of the UI. Currently, only `"loader"` and `"error"` states are supported. For example, in order to show a loader in the InsightsChartEditor UI, just call `state("loader", true)`. If you want to display an error in the InsightsChartEditor UI, call `state("error", "Something went wrong.")`. |
| `reload()`                                | Refresh the content of the chart editor.                                                                                                                                                                                                                                                                           |

### InsightsChartEditor Events

| Event   | Callback     | Triggered when...                    |
| ------- | ------------ | ------------------------------------ |
| `close` | `function()` | the user clicks on the close button. |

### Example

```javascript
var insightsChartEditor = appmixer.ui.InsightsChartEditor({
    el: '#your-insights-chart-editor-div'
});
appmixer.api.getCharts().then(function(charts) {
    var myChart = charts[0];   // Assuming we have at least one chart.
    insightsChartEditor.set('chartId', myChart.chartId);
    insightsChartEditor.open();
});
```

##


---

# 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://docs.appmixer.com/6.0/v4/appmixer-sdk/api-reference/insightscharteditor.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.
