diff --git a/cave_api/cave_api/examples/kitchen_sink.py b/cave_api/cave_api/examples/kitchen_sink.py index 43eb45a..773e223 100644 --- a/cave_api/cave_api/examples/kitchen_sink.py +++ b/cave_api/cave_api/examples/kitchen_sink.py @@ -895,8 +895,8 @@ def execute_command(session_data, socket, command="init", **kwargs): "longitude": 14, }, }, - "legendView": "full", - "showLegendGroupNames": False, + "legendView": "minimal", + "showLegendGroupNames": True, "legendGroups": { "lga": { "name": "Legend Group A", @@ -912,46 +912,15 @@ def execute_command(session_data, socket, command="init", **kwargs): # "groupScaleWithZoom": True, # "groupScale": 10, "icon": "fa6/FaIgloo", - # NOTE: Example of overriding prop attributes in the legend - "props": { - "numericPropExampleA": { - "startGradientColor": "rgba(33, 200, 100, 1)", - "endGradientColor": "rgba(196, 220, 112, 1)", - "startSize": "40px", - "endSize": "60px", - # REVIEW: Preferred key name -> `default` or `fallback`? - # This would replace `nullColor` and `nullSize` and add the option of including a `name` - "default": {"name": "Undefined", "color": "rgba(128, 128, 128, 1)", "size": "20px"}, - # REVIEW: Option to use separate names for color and size - # "default": { - # "color": {"name": "No Color", "color": "rgba(128, 128, 128, 1)"}, - # "size": {"name": "No Size", "size": "20px"}, - # } - }, - "booleanPropExample": { - "options":{ - "false": {"name": "Idle", "color": "rgba(255, 0, 0, 1)", "size": "15px"}, - "true": {"name": "Active", "color": "rgba(0, 255, 0, 1)", "size": "30px"}, - }, - # REVIEW: Preferred key name -> `default` or `fallback`? - # This would replace `nullColor` and `nullSize` and add the option of including a `name` - "default": {"name": "Unknown", "color": "rgba(128, 128, 128, 1)", "size": "20px"}, - # REVIEW: Option to use separate names for color and size - # "default": { - # "color": {"name": "No Color", "color": "rgba(128, 128, 128, 1)"}, - # "size": {"name": "No Size", "size": "20px"}, - # } - } - }, # REVIEW: - # Current implemented behavior on `cave_static`: `colorBy` and `sizeBy` dropdowns are populated with props - # that have at least one gradient/color or size range/option value after left-merging + # Current implemented behavior on `cave_static`: the `colorBy` and `sizeBy` dropdowns are populated + # with props that have at least one gradient/color or size range/option value after left-merging # `legendGroups.lga.data.nodeTypeA.props` with `mapFeatures.data.nodeTypeA.props`. - - # REVIEW: The following is not implemented yet: - # I think we could define a list of prop keys to specify which props should appear in the dropdowns by - # using `colorByOptions` and `sizeByOptions`. Note that `colorByOptions` and `sizeByOptions` would be - # different from the old structure and will only point to the keys. + # + # Alternatively (not implemented yet): + # We could define a list of prop keys to specify which props should appear in the dropdowns by + # using `colorByOptions` and `sizeByOptions`. Note that `colorByOptions` and `sizeByOptions` would + # be different from the old structure and will only point to the keys. "colorByOptions": [], "sizeByOptions": [], }, @@ -1137,14 +1106,46 @@ def execute_command(session_data, socket, command="init", **kwargs): "type": "selector", "variant": "dropdown", "options": { - "a": {"name": "A", "color": "rgba(128, 255, 255, 1)", "size": "3px"}, - "b": {"name": "B", "color": "rgba(0, 153, 51, 1)", "size": "8px"}, - "c": {"name": "C", "color": "rgba(0, 0, 128, 1)", "size": "13px"}, - "d": {"name": "D", "color": "rgba(204, 0, 0, 1)", "size": "18px"}, - "e": {"name": "E", "color": "rgba(153, 77, 0, 1)", "size": "23px"}, - "f": {"name": "F", "color": "rgba(255, 25, 255, 1)", "size": "28px"}, - "g": {"name": "G", "color": "rgba(0, 255, 0, 1)", "size": "33px"}, - "h": {"name": "H", "color": "rgba(255, 255, 0, 1)", "size": "38px"}, + "a": { + "name": "A", + "color": "rgba(128, 255, 255, 1)", + "size": "3px", + }, + "b": { + "name": "B", + "color": "rgba(0, 153, 51, 1)", + "size": "8px", + }, + "c": { + "name": "C", + "color": "rgba(0, 0, 128, 1)", + "size": "13px", + }, + "d": { + "name": "D", + "color": "rgba(204, 0, 0, 1)", + "size": "18px", + }, + "e": { + "name": "E", + "color": "rgba(153, 77, 0, 1)", + "size": "23px", + }, + "f": { + "name": "F", + "color": "rgba(255, 25, 255, 1)", + "size": "28px", + }, + "g": { + "name": "G", + "color": "rgba(0, 255, 0, 1)", + "size": "33px", + }, + "h": { + "name": "H", + "color": "rgba(255, 255, 0, 1)", + "size": "38px", + }, }, }, }, @@ -1214,14 +1215,46 @@ def execute_command(session_data, socket, command="init", **kwargs): "type": "selector", "variant": "dropdown", "options": { - "a": {"name": "A", "color": "rgba(128, 255, 255, 1)", "size": "3px"}, - "b": {"name": "B", "color": "rgba(0, 153, 51, 1)", "size": "8px"}, - "c": {"name": "C", "color": "rgba(0, 0, 128, 1)", "size": "13px"}, - "d": {"name": "D", "color": "rgba(204, 0, 0, 1)", "size": "18px"}, - "e": {"name": "E", "color": "rgba(153, 77, 0, 1)", "size": "23px"}, - "f": {"name": "F", "color": "rgba(255, 25, 255, 1)", "size": "28px"}, - "g": {"name": "G", "color": "rgba(0, 255, 0, 1)", "size": "33px"}, - "h": {"name": "H", "color": "rgba(255, 255, 0, 1)", "size": "38px"}, + "a": { + "name": "A", + "color": "rgba(128, 255, 255, 1)", + "size": "3px", + }, + "b": { + "name": "B", + "color": "rgba(0, 153, 51, 1)", + "size": "8px", + }, + "c": { + "name": "C", + "color": "rgba(0, 0, 128, 1)", + "size": "13px", + }, + "d": { + "name": "D", + "color": "rgba(204, 0, 0, 1)", + "size": "18px", + }, + "e": { + "name": "E", + "color": "rgba(153, 77, 0, 1)", + "size": "23px", + }, + "f": { + "name": "F", + "color": "rgba(255, 25, 255, 1)", + "size": "28px", + }, + "g": { + "name": "G", + "color": "rgba(0, 255, 0, 1)", + "size": "33px", + }, + "h": { + "name": "H", + "color": "rgba(255, 255, 0, 1)", + "size": "38px", + }, }, }, }, @@ -1281,6 +1314,11 @@ def execute_command(session_data, socket, command="init", **kwargs): "endGradientColor": "rgba(96, 2, 2, 1)", "startSize": "30px", "endSize": "45px", + "fallback": { + "name": "Undefined", + "color": "rgba(128, 128, 128, 1)", + "size": "20px", + }, "help": "Help for numeric prop example A", }, "numericPropExampleB": { @@ -1300,10 +1338,22 @@ def execute_command(session_data, socket, command="init", **kwargs): "booleanPropExample": { "name": "Boolean Prop Example", "type": "toggle", - # REVIEW: Reusing the `options` structure from selector props for consistency, as the data types are similar in nature - "options":{ - "false": {"name": "False", "color": "rgba(255, 0, 0, 1)", "size": "15px"}, - "true": {"name": "True", "color": "rgba(0, 255, 0, 1)", "size": "30px"}, + "options": { + "false": { + "name": "Idle", + "color": "rgba(255, 0, 0, 1)", + "size": "15px", + }, + "true": { + "name": "Active", + "color": "rgba(0, 255, 0, 1)", + "size": "30px", + }, + }, + "fallback": { + "name": "Unknown", + "color": "rgba(128, 128, 128, 1)", + "size": "100px", }, "help": "Help for boolean prop", }, @@ -1312,14 +1362,46 @@ def execute_command(session_data, socket, command="init", **kwargs): "type": "selector", "variant": "dropdown", "options": { - "a": {"name": "A", "color": "rgba(128, 255, 255, 1)", "size": "3px"}, - "b": {"name": "B", "color": "rgba(0, 153, 51, 1)", "size": "8px"}, - "c": {"name": "C", "color": "rgba(0, 0, 128, 1)", "size": "13px"}, - "d": {"name": "D", "color": "rgba(204, 0, 0, 1)", "size": "18px"}, - "e": {"name": "E", "color": "rgba(153, 77, 0, 1)", "size": "23px"}, - "f": {"name": "F", "color": "rgba(255, 25, 255, 1)", "size": "28px"}, - "g": {"name": "G", "color": "rgba(0, 255, 0, 1)", "size": "33px"}, - "h": {"name": "H", "color": "rgba(255, 255, 0, 1)", "size": "38px"}, + "a": { + "name": "A", + "color": "rgba(128, 255, 255, 1)", + "size": "3px", + }, + "b": { + "name": "B", + "color": "rgba(0, 153, 51, 1)", + "size": "8px", + }, + "c": { + "name": "C", + "color": "rgba(0, 0, 128, 1)", + "size": "13px", + }, + "d": { + "name": "D", + "color": "rgba(204, 0, 0, 1)", + "size": "18px", + }, + "e": { + "name": "E", + "color": "rgba(153, 77, 0, 1)", + "size": "23px", + }, + "f": { + "name": "F", + "color": "rgba(255, 25, 255, 1)", + "size": "28px", + }, + "g": { + "name": "G", + "color": "rgba(0, 255, 0, 1)", + "size": "33px", + }, + "h": { + "name": "H", + "color": "rgba(255, 255, 0, 1)", + "size": "38px", + }, }, }, }, @@ -1362,8 +1444,6 @@ def execute_command(session_data, socket, command="init", **kwargs): "unit": "A units", "startGradientColor": "rgba(233, 0, 0, 1)", "endGradientColor": "rgba(96, 2, 2, 1)", - # REVIEW: This approach removes the ability to set different min and max values for color and size. - # In the previous "map2" example, "min" was set to 0 and "max" to 250 specifically for the size range. "startSize": "15px", "endSize": "30px", "help": "Help for numeric prop example A", @@ -1378,8 +1458,6 @@ def execute_command(session_data, socket, command="init", **kwargs): "legendMaxLabel": "Hi", "startGradientColor": "rgba(233, 0, 0, 1)", "endGradientColor": "rgba(96, 2, 2, 1)", - # REVIEW: This approach removes the ability to set different min and max values for color and size. - # In the previous "map2" example, "min" was set to 0 and "max" to 40 specifically for the size range. "startSize": "5px", "endSize": "15px", "help": "Help for numeric prop example B", @@ -1387,7 +1465,7 @@ def execute_command(session_data, socket, command="init", **kwargs): "booleanPropExample": { "name": "Boolean Prop Example", "type": "toggle", - "options":{ + "options": { "false": {"color": "rgba(233, 0, 0, 1)"}, "true": {"color": "rgba(0, 233, 0, 1)"}, }, @@ -1427,11 +1505,11 @@ def execute_command(session_data, socket, command="init", **kwargs): "booleanPropExample": { "name": "Boolean Prop Example", "type": "toggle", - "options":{ + "options": { "false": {"color": "rgba(233, 0, 0, 1)"}, "true": {"color": "rgba(0, 233, 0, 1)"}, }, - "help": "Help for boolean prop", + "help": "Help for boolean prop", }, }, "data": { @@ -1495,7 +1573,7 @@ def execute_command(session_data, socket, command="init", **kwargs): "booleanPropExample": { "name": "Boolean Prop Example", "type": "toggle", - "options":{ + "options": { "false": {"color": "rgba(233, 0, 0, 1)"}, "true": {"color": "rgba(0, 233, 0, 1)"}, },