plotly / dash-ag-grid

Dash AG Grid is a high-performance and highly customizable component that wraps AG Grid, designed for creating rich datagrids.
https://dash.plotly.com/dash-ag-grid
MIT License
177 stars 28 forks source link

JavaScript function not recognized as a function in Dash AG Grid sparklines #329

Open safroze-plotly opened 1 month ago

safroze-plotly commented 1 month ago

A client has reported an issue where the function key in the formatter property for the agSparklineCellRenderer is not being recognized as a JavaScript function in enterprise sparklines. Instead, it is interpreted as a string, which leads to incorrect behavior. Some properties in AG Grid take a JavaScript function as inputs according to the doc here

The issue occurs when using the following configuration in the AG Grid;

{
  "cellRenderer": "agSparklineCellRenderer",
  "cellRendererParams": {
    "sparklineOptions": {
      "type": "bar",
      "formatter": {"function": "params.value[0] < 0 ? {fill: #5470c6} : {fill: #a90000}"},
      "valueAxisDomain": [-15, 15],
      "paddingOuter": 0,
      "padding": {
        "top": 0,
        "bottom": 0
      },
      "label": {
        "enabled": true,
        "fontWeight": "bold",
        "placement": "outsideEnd"
      }
    }
  }
}

Reference Links:

https://community.plotly.com/t/aggrid-agsparklinecellrenderer-and-formatter-params/84780

https://dash.plotly.com/dash-ag-grid/javascript-and-the-grid#functions