Nodes/Clh Tool for ComfyUI/EchartOptionByPath_clh
ComfyUI Node

EchartOptionByPath_clh

Chart a JSON blob without retyping it

By clhui·Created 2 years ago·Updated 10 months ago· 9
EchartOptionByPath_clh
    • options
    data{}
    title保险
    xAxis$.data[0].0.name
    data1_name销量
    data1_typeline
    data1$.data[0].0.name
    markLine10
    data2_name比例
    data2_typeline
    data2$.data[0].0.name
    markLine20

    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 inside data.
    • data1 - a path expression pointing at the first series' values.
    • data1_name - the legend label for that series.
    • data1_type - line, bar, or pie.
    • title and markLine1 - the chart heading and an optional reference line (leave it 0 for 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.

    CategorysimpleTool_clh

    Inputs (11)

    NameTypeDefaultDescription
    dataSTRING{}
    titleSTRING保险
    xAxisSTRING$.data[0].0.name
    data1_nameSTRING销量
    data1_typeCOMBOline3 options: line, bar, pie
    data1STRING$.data[0].0.name
    markLine1STRING0
    data2_nameoptSTRING比例
    data2_typeoptCOMBOline3 options: line, bar, pie
    data2optSTRING$.data[0].0.name
    markLine2optSTRING0

    Outputs (1)

    NameTypeDescription
    optionsSTRING