Skip to content

bug: LineChartEvent spot_index/bar_index stopped working in Flet 0.84.0 #6443

@Loz-Aus

Description

@Loz-Aus

Duplicate Check

Describe the bug

Hey there

I've upgraded to Flet 0.8 and noticed that the LineChartEvent spots doesn't work properly. It seems to return 'ExtType(code=0, data=b'')' and I cant find any info about how to use it. For some reason you can use e.spots[0].spot_index and bar_index which appear in intellisense but both just throw an error.

Any help would be greatly appreciated. Cheers

Code sample

Code
    def chart_event(self, e: LineChartEvent):
        
        print(e.spots) # -> [ExtType(code=0, data=b'')]
        
        # the spot_index and bar_index appear in intellisense but throw an error
        e.spots[0].spot_index
        # e.spots[0].bar_index
Image

To reproduce

Run the code below and hover over data points to print ExtType list. If you click the data point it will throw an error which should show the spot index e.g. 0,1,2,3 etc

from flet import * 
from flet_charts import * 

def main(page: Page):
    
    def chart_event(e: LineChartEvent):               
        match e.type:
            case ChartEventType.POINTER_HOVER:
                print(e.spots) # -> [ExtType(code=0, data=b'')]
           
            case ChartEventType.TAP_DOWN:
                # the spot_index and bar_index appear in intellisense but throw an error
                e.spots[0].spot_index
                #e.spots[0].bar_index

    chart = LineChart(
        bgcolor = "white",
        on_event=chart_event,
        interactive=True,
        expand=True,
        data_series=LineChartData(
            stroke_width=2,
            color=Colors.RED,
            below_line_gradient= None,
            curved=False,
            rounded_stroke_cap=True,
            points=[
                LineChartDataPoint(0, 100,point=True),
                LineChartDataPoint(1, 234,point=True),
                LineChartDataPoint(2, 123,point=True),
                LineChartDataPoint(3, 323,point=True),
                LineChartDataPoint(5, 423,point=True),
                LineChartDataPoint(6, 489,point=True),
                LineChartDataPoint(7, 523,point=True)
            ],
        ),
        min_x=0,
        max_x=7,
        min_y=0,
        max_y=523
    )

    page.add(chart)

run(main)
Image

Expected behavior

I would expect to see the index of each x axis when hovered for spot_index e.g. 0,1,2,3,4 etc as it did in Flet 0.28

Screenshots / Videos

Captures

[Upload media here]

Operating System

Windows

Operating system details

Windows 11

Flet version

Flet version 0.84.0

Regression

Yes, it used to work in a previous Flet version (please specify the version in additional details)

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

This works in Flet version 0.28.3.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

👀 In review

Relationships

None yet

Development

No branches or pull requests

Issue actions