大多数二维图表通过 chart.add() 方法接受数据,该方法有多种用法:
chart.add(x, y),其中 x 和 y 是数值列表:
import lightningchart as lc
lc.set_license('my-license-key')
x = [1, 2, 3, 4]
y = [1, 3, 2, 4]
chart = lc.LineChart()
chart.add(x, y)
chart.open()chart.add(data),其中 data 是 Python 列表,包含键为 "x "和 "y "的 Python dict:
import lightningchart as lc
lc.set_license('my-license-key')
data = [
{"x": 1, "y": 1},
{"x": 2, "y": 3},
{"x": 3, "y": 2},
{"x": 4, "y": 4},
]
chart = lc.LineChart()
chart.add(data)
chart.open()大多数三维图表都有具有类似 z 属性的等效方法:
import lightningchart as lc
lc.set_license('my-license-key')
chart1 = lc.ScatterChart3D()
chart1.add(
x=[1, 2, 3, 4],
y=[1, 3, 2, 4],
z=[4, 2, 3, 1]
)
chart2 = lc.LineChart3D()
chart2.add([
{"x": 1, "y": 1, "z": 4},
{"x": 2, "y": 3, "z": 2},
{"x": 3, "y": 2, "z": 3},
{"x": 4, "y": 4, "z": 1},
])
chart1.open()
chart2.open()如需了解例外情况,请参阅各图表的文档页面。
渝公网安备50010702505508