LineChart drops column if there is one missing value

Hello everyone,
I have data that looks like the data below. When I try to plot it with dataKey=‘date’ and series (FITC, CY5, DAPI, and TRITC). If there’s a null value in any line, it drops it from the graph. How can I adjust this to just skip that data point?

data = [{'DAPI': 42212.44284955681, 'FITC': 39579.08263156841, 'dataset_index': 0, 'date': datetime.date(2024, 11, 29), 'CY5': nan, 'TRITC': nan}, {'DAPI': 43525.87908987836, 'FITC': 41935.75454605864, 'dataset_index': 1, 'date': datetime.date(2024, 11, 29), 'CY5': 41124.016080595175, 'TRITC': 42618.78987275943}, {'DAPI': 45706.72574325567, 'FITC': 42922.41592194716, 'dataset_index': 2, 'date': datetime.date(2024, 11, 29), 'CY5': 45567.41051876721, 'TRITC': 42027.75111531162}, {'DAPI': 42409.59461449837, 'FITC': 44240.63513784188, 'dataset_index': 3, 'date': datetime.date(2024, 11, 29), 'CY5': 44792.27478468819, 'TRITC': 45347.34554698756}]

Hi @User5

Can you try changing nan to None ? Then you can also include the option to connectNulls

Hi @AnnMarieW ,
Thank you for your reply. But, no it didn’t work after I replaced nan with None and included connectNulls.

Can you make a complete example that reproduces the issue?

2 Likes

Here’s the complet code i use for linechart:

dmc.LineChart(id="line-chart",
h=300,
data = [{'DAPI': 42212.44284955681, 'FITC': 39579.08263156841, 'dataset_index': 0,
                 'date': "01-01-2024", 'CY5': '', 'TRITC': ''},
                {'DAPI': 43525.87908987836, 'FITC': 41935.75454605864, 'dataset_index': 1,
                 'date': "01-01-2024", 'CY5': 41124.016080595175, 'TRITC': 42618.78987275943},
                {'DAPI': 45706.72574325567, 'FITC': 42922.41592194716, 'dataset_index': 2,
                 'date': "01-01-2024", 'CY5': 45567.41051876721, 'TRITC': 42027.75111531162},
                {'DAPI': 42409.59461449837, 'FITC': 44240.63513784188, 'dataset_index': 3,
                 'date': "01-01-2024", 'CY5': 44792.27478468819, 'TRITC': 45347.34554698756}],
dataKey="date",
withLegend=True,
legendProps={
"horizontalAlign": "top",
"left": 50,
},
series=[
    { "name": "DAPI", "color": "#FF0000"},
    { "name": "FITC", "color": "#00FF00"},
    { "name": "CY5", "color": "#0000FF"},
    { "name": "TRITC", "color": "#FFFF00"},
    
],
curveType="natural",
style={"padding": 20},
xAxisLabel="Processed Date",
connectNulls=True,
)

It seems to work fine. When the values is '' (empty string) it renders as 0. If you change it to None the line segment doesn’t show – which looks correct to me.

Try it on PyCafe

right, thank you.