You have to add the Charts package in your CMAKE file:
find_package(Qt6 REQUIRED COMPONENTS Charts) target_link_libraries(mytarget PRIVATE Qt6::Charts)