-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sparklines ? #118
Comments
@dcowden My example (test.csv) is done on following data full example code :
|
@Hurikaine thank you very much! After digging around, I had learned that the solution might involve a valuegetter, because it appears that the data is a string by the time it gets to the javascript layer. The above solution works, but I was hoping to avoid having to parse a number-list encoded as a string. A simple but unsafe eval() would probably also work. I think this is the line of code that creates the problem is: https://github.com/PablocFonseca/streamlit-aggrid/blob/main/st_aggrid/__init__.py#L55 Here, even if the dataframe has a column with a list of numbers, it is rendered as a string. It would be ideal if it was smarter, and tested for a list, rendering a list. instead of converting to a string, which then has to be undone on the client side |
following up, this sample solution uses [dangerous] eval, but illustrates another working solution:
This is not a bug, but an enhancement. The ideal behavior would be for __parse_row_data to detect lists, and convert them to a native list, instead of converting to a string and requiring lists to be re-parsed on the client side. |
Actually the example in the question works for me with
... without JS injection, evals, In other words, the following: import pandas as pd
import streamlit as st
from st_aggrid import AgGrid, GridOptionsBuilder
simple_data = pd.DataFrame(
{
"name": ["a", "b"],
"history": [
[1, 2, 0, 0, 1, 0, 2],
[1, 0, 0, 0, 2, 2, 2, 2],
],
}
)
gb = GridOptionsBuilder.from_dataframe(simple_data)
gb.configure_side_bar()
gb.configure_column(
"history",
cellRenderer="agSparklineCellRenderer",
cellRendererParams={
"sparklineOptions": {
"type": "line",
"line": {"stroke": "#91cc75", "strokeWidth": 2},
}
},
)
gridOptions = gb.build()
g = AgGrid(
simple_data,
gridOptions=gridOptions,
) ... produces |
Hi, thank you for the excellent python module!
I'm trying to use AGGrid's relatively new ( October 2021) Sparklines feature:
https://ag-grid.com/javascript-data-grid/sparklines-overview/
I am using these libs, which at the time of this writing are the latest:
I think this simple example should yeild a grid with sparklines in the history column:
But it renders an empty column, like this:
I have a feeling that this has to do with the format of the data. pandas reports the column as an object:
And Aggrid sparkline expects a numeric javascript array
I know that an attempt is being made to apply the agSparkLineCellRenderer because if we comment out the configure_column call, we get the expected result:
![image](https://user-images.githubusercontent.com/1297923/181804735-6f0b2852-47a7-4c29-bf73-bc88ea09707a.png)
Using browser console, there are no javascript errors reported (other than the AGgrid license warning).
I also tried applying type='number' and type='numeric' in the column properties, with the same blank column behavior.
I suspect i'm missing a pretty simple data conversion issue here, or alternately it could be that the aggride version being used is older.
Help would be appreciated!
The text was updated successfully, but these errors were encountered: