color_by scalars not working

Hi All,

I am loading the following vtkjs file on Paraview Glance. Everythng works fine except the dataset named “Grid”. I have added two scalars to this data and they can be seen in Glance.

The question is why I don’t see the scalar loaded when I see in the index.json file that for this dataset “colorByArrayName” property is set to one of the scalars?

I would also share that this works fine when instead of Points, I use Polygons as a grid.

I have attached the vtkjs file and the zip file that I used to make this vtkjs below;

test.vtkjs (18.3 KB) (18.0 KB)

I found a perfect example to show the issue. The following code is taken from the example here

import vtk

def get_program_parameters():
    import argparse
    description = 'Generate a triangle with colored points and write it to a .vtp file.'
    epilogue = '''
    parser = argparse.ArgumentParser(description=description, epilog=epilogue)
    parser.add_argument('filename', help='A required vtp filename.', nargs='?',
                        type=str, default='TestTriangleColoredPoints.vtp')
    args = parser.parse_args()
    return args.filename

def main():
    colors = vtk.vtkNamedColors()

    filename = get_program_parameters()

    # setup points and vertices
    Points = vtk.vtkPoints()
    Vertices = vtk.vtkCellArray()

    id = Points.InsertNextPoint(1.0, 0.0, 0.0)
    id = Points.InsertNextPoint(0.0, 0.0, 0.0)
    id = Points.InsertNextPoint(0.0, 1.0, 0.0)

    # setup colors
    Colors = vtk.vtkUnsignedCharArray()

    polydata = vtk.vtkPolyData()

    writer = vtk.vtkXMLPolyDataWriter()

if __name__ == '__main__':

I only added the following line


My expectation is that when I load the resulting .vtp file in Paraview Glance it should color the points with the scalar that I set as an active scalar. But it doesn’t. Why?

I believe this is similar. Is this implemented yet @Forrest_Li ?

1 Like

The vtkjs format should have worked and it used to work. The same should be true with custom color range defined in PV, those should be kept as well rather than recomputed the full scalar range. @Forrest_Li

I’ll check this out. Thanks for the pings.

1 Like

PR is out for active scalars: feat(ColorBy): Use default scalars for colorBy by floryst · Pull Request #397 · Kitware/paraview-glance · GitHub

1 Like

Thanks a lot @Forrest_Li! When do we get to try this?

I’ve just merged it after some more testing. The changes should be live shortly on the nightly build; do let me know if the active scalars are still not being picked up.

I tried just now and it’s not being picked up. Maybe I should wait longer. Here’s the file I used.

gridbased.vtkjs (15.1 KB)

I’ve made updates to Glance and the public instance of it. I loaded your file and it seems to work; do try it out and let me know if something is still not working.

Note: you may need to clear out the application cache via devtools or a hard reload.

You’re the man. It works. Thanks a lot!