EchartOptionByPath_clh
Chart a JSON blob without retyping it
- options
Same job as EchartOption clh - it builds an ECharts options string that EchartGraph clh renders - but with a different input style. Instead of typing your axis labels and data as plain arrays, you hand it a whole JSON object and tell it where inside that object the values live, using path expressions. It's the node you reach for when your numbers already exist as structured JSON and you don't want to copy-paste them into arrays by hand.
If some upstream node in your workflow already produces a JSON string - a JavaScript clh node's output, an API result, a stats blob - this is how you point a chart at it without reshaping the data first.
How it works
You give it the JSON in the data field. Then, for each thing the chart needs (the x-axis, series one, series two), you give it a path expression - the defaults look like $.data[0].0.name, which is JSONPath-style syntax for "reach into this object and pull that value out." The node resolves each path against your JSON, collects the values, and assembles the ECharts options object from them. Change the underlying JSON and the same paths pull the new values - that's the whole advantage over the hand-typed sibling.
The trade-off: you have to know your JSON's shape to write the paths, and getting a path wrong is the main way this node bites. It's more powerful and more fiddly than EchartOption. If your data is just a short list of numbers, the plain-array node is less hassle.
The inputs and outputs that matter
data- the source JSON object, as a string. Everything else reads out of this.xAxis- a path expression pointing at the category labels insidedata.data1- a path expression pointing at the first series' values.data1_name- the legend label for that series.data1_type-line,bar, orpie.titleandmarkLine1- the chart heading and an optional reference line (leave it0for none).
There's an optional second series too - data2, data2_name, data2_type, markLine2 - resolved the same way by path. Two series max.
Output is one options string, ready to wire into EchartGraph clh.
Installing it
ComfyUI Manager: search Clh Tool for ComfyUI, install, restart. Or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/clhui/ComfyUi-clh-Tool
and restart ComfyUI. If the node doesn't appear after a manual clone, the startup console will name any missing dependency for you to pip install - Manager does that step automatically, a bare clone doesn't.
Common issues
Wrong paths are the whole ballgame here. A path that doesn't match your JSON's actual structure returns nothing (or the wrong thing), and the chart comes out empty or garbled. Before you trust it, look at your data JSON carefully and confirm each path resolves to what you expect - start with just the x-axis and one series, get that rendering, then add the second series. Don't wire up all four paths blind and wonder why it's blank.
Malformed source JSON is the other one: if data isn't valid JSON, nothing downstream can work. Validate the blob first.
And as with the whole Echart trio, this node only produces a config - it draws nothing on its own. The options output has to reach EchartGraph clh for a chart to appear. If you find yourself fighting path syntax for a handful of numbers you could just type, EchartOption clh is the simpler node and probably the one you actually want.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| data | STRING | {} | — |
| title | STRING | 保险 | — |
| xAxis | STRING | $.data[0].0.name | — |
| data1_name | STRING | 销量 | — |
| data1_type | COMBO | line | 3 options: line, bar, pie |
| data1 | STRING | $.data[0].0.name | — |
| markLine1 | STRING | 0 | — |
| data2_nameopt | STRING | 比例 | — |
| data2_typeopt | COMBO | line | 3 options: line, bar, pie |
| data2opt | STRING | $.data[0].0.name | — |
| markLine2opt | STRING | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| options | STRING | — |