Legend Grid annotation from Paraview 12 with VTK filters

What you are looking for is the vtkLegendScaleActor class. You can find example (https://examples.vtk.org/site/Cxx/Visualization/LegendScaleActor/) and tests.