MCPcopy Index your code
hub / github.com/plotly/plotly.py / TraceNode

Class TraceNode

codegen/utils.py:1024–1075  ·  view source on GitHub ↗

Class representing datatypes in the trace hierarchy

Source from the content-addressed store, hash-verified

1022
1023
1024class TraceNode(PlotlyNode):
1025 """
1026 Class representing datatypes in the trace hierarchy
1027 """
1028
1029 # Constructor
1030 def __init__(self, plotly_schema, node_path=(), parent=None):
1031 super().__init__(plotly_schema, node_path, parent)
1032
1033 @property
1034 def name_base_datatype(self):
1035 if len(self.node_path) <= 1:
1036 return "BaseTraceType"
1037 else:
1038 return "BaseTraceHierarchyType"
1039
1040 @property
1041 def root_name(self):
1042 return ""
1043
1044 # Raw data
1045 @property
1046 def node_data(self) -> dict:
1047 if not self.node_path:
1048 node_data = self.plotly_schema["traces"]
1049 else:
1050 trace_name = self.node_path[0]
1051 node_data = self.plotly_schema["traces"][trace_name]["attributes"]
1052 for prop_name in self.node_path[1:]:
1053 node_data = node_data[prop_name]
1054
1055 return node_data
1056
1057 # Description
1058 @property
1059 def description(self) -> str:
1060 if len(self.node_path) == 0:
1061 desc = ""
1062 elif len(self.node_path) == 1:
1063 # Get trace descriptions
1064 trace_name = self.node_path[0]
1065 desc = self.plotly_schema["traces"][trace_name]["meta"].get(
1066 "description", ""
1067 )
1068 else:
1069 # Get datatype description
1070 desc = self.node_data.get("description", "")
1071
1072 if isinstance(desc, list):
1073 desc = "".join(desc)
1074
1075 return format_description(desc)
1076
1077
1078class LayoutNode(PlotlyNode):

Callers 1

perform_codegenFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected