or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

3d-charts.mdbasic-charts.mdcomposite-charts.mdgeographic-charts.mdindex.mdoptions.mdrendering.mdutilities.md

basic-charts.mddocs/

0

# Basic Charts

1

2

Core 2D chart types that form the foundation of pyecharts' visualization capabilities. These charts cover the most common data visualization needs including categorical data, time series, distributions, relationships, and hierarchical data.

3

4

## Capabilities

5

6

### Bar Charts

7

8

Creates bar charts with rectangular bars representing categorical data. Supports horizontal and vertical orientations, stacking, and extensive styling options.

9

10

```python { .api }

11

class Bar:

12

def __init__(self, init_opts=None, render_opts=None):

13

"""

14

Initialize a bar chart.

15

16

Args:

17

init_opts (InitOpts, optional): Chart initialization options

18

render_opts (RenderOpts, optional): Rendering options

19

"""

20

21

def add_xaxis(self, xaxis_data):

22

"""

23

Add x-axis data (categories).

24

25

Args:

26

xaxis_data (list): List of category names

27

28

Returns:

29

Bar: Self for method chaining

30

"""

31

32

def add_yaxis(self, series_name, y_axis, **kwargs):

33

"""

34

Add y-axis data series.

35

36

Args:

37

series_name (str): Name of the data series

38

y_axis (list): List of numeric values or BarItem objects

39

xaxis_index (int, optional): Index of x-axis to use

40

yaxis_index (int, optional): Index of y-axis to use

41

stack (str, optional): Stack group name for stacked bars

42

bar_width (str|int, optional): Bar width

43

bar_max_width (str|int, optional): Maximum bar width

44

bar_min_width (str|int, optional): Minimum bar width

45

category_gap (str, optional): Gap between categories

46

gap (str, optional): Gap between bars in same category

47

48

Returns:

49

Bar: Self for method chaining

50

"""

51

52

def reversal_axis(self):

53

"""

54

Swap x and y axes to create horizontal bar chart.

55

56

Returns:

57

Bar: Self for method chaining

58

"""

59

```

60

61

**Usage Example:**

62

```python

63

from pyecharts.charts import Bar

64

from pyecharts import options as opts

65

66

bar = (

67

Bar(init_opts=opts.InitOpts(width="800px", height="600px"))

68

.add_xaxis(["A", "B", "C", "D", "E"])

69

.add_yaxis("Series 1", [10, 20, 30, 40, 50])

70

.add_yaxis("Series 2", [15, 25, 35, 45, 55])

71

.set_global_opts(

72

title_opts=opts.TitleOpts(title="Bar Chart Example"),

73

legend_opts=opts.LegendOpts(is_show=True)

74

)

75

)

76

```

77

78

### Line Charts

79

80

Creates line charts connecting data points with lines. Ideal for time series data, trends, and continuous data visualization.

81

82

```python { .api }

83

class Line:

84

def __init__(self, init_opts=None, render_opts=None):

85

"""

86

Initialize a line chart.

87

88

Args:

89

init_opts (InitOpts, optional): Chart initialization options

90

render_opts (RenderOpts, optional): Rendering options

91

"""

92

93

def add_xaxis(self, xaxis_data):

94

"""

95

Add x-axis data.

96

97

Args:

98

xaxis_data (list): List of x-axis values

99

100

Returns:

101

Line: Self for method chaining

102

"""

103

104

def add_yaxis(self, series_name, y_axis, **kwargs):

105

"""

106

Add y-axis data series.

107

108

Args:

109

series_name (str): Name of the data series

110

y_axis (list): List of numeric values or LineItem objects

111

is_smooth (bool, optional): Smooth line curves

112

is_connect_nones (bool, optional): Connect null values

113

is_step (bool|str, optional): Step line style

114

is_symbol_show (bool, optional): Show data point symbols

115

stack (str, optional): Stack group name

116

area_style_opts (AreaStyleOpts, optional): Area fill styling

117

118

Returns:

119

Line: Self for method chaining

120

"""

121

```

122

123

### Pie Charts

124

125

Creates pie and donut charts for showing proportional data and part-to-whole relationships.

126

127

```python { .api }

128

class Pie:

129

def __init__(self, init_opts=None, render_opts=None):

130

"""

131

Initialize a pie chart.

132

133

Args:

134

init_opts (InitOpts, optional): Chart initialization options

135

render_opts (RenderOpts, optional): Rendering options

136

"""

137

138

def add(self, series_name, data_pair, **kwargs):

139

"""

140

Add pie chart data.

141

142

Args:

143

series_name (str): Name of the data series

144

data_pair (list): List of [name, value] pairs or PieItem objects

145

radius (list, optional): Inner and outer radius ["20%", "80%"]

146

center (list, optional): Center position ["50%", "50%"]

147

rosetype (str, optional): Rose chart type ("radius" or "area")

148

is_clockwise (bool, optional): Clockwise order

149

start_angle (int, optional): Start angle in degrees

150

151

Returns:

152

Pie: Self for method chaining

153

"""

154

```

155

156

### Scatter Charts

157

158

Creates scatter plots for showing relationships between two numeric variables.

159

160

```python { .api }

161

class Scatter:

162

def __init__(self, init_opts=None, render_opts=None):

163

"""

164

Initialize a scatter chart.

165

166

Args:

167

init_opts (InitOpts, optional): Chart initialization options

168

render_opts (RenderOpts, optional): Rendering options

169

"""

170

171

def add_xaxis(self, xaxis_data):

172

"""

173

Add x-axis data.

174

175

Args:

176

xaxis_data (list): List of x-axis values

177

178

Returns:

179

Scatter: Self for method chaining

180

"""

181

182

def add_yaxis(self, series_name, y_axis, **kwargs):

183

"""

184

Add y-axis data series.

185

186

Args:

187

series_name (str): Name of the data series

188

y_axis (list): List of y values or [x, y] pairs or ScatterItem objects

189

symbol (str, optional): Symbol type

190

symbol_size (int|list, optional): Symbol size

191

192

Returns:

193

Scatter: Self for method chaining

194

"""

195

```

196

197

### Effect Scatter Charts

198

199

Enhanced scatter plots with animation effects and particle trails.

200

201

```python { .api }

202

class EffectScatter:

203

def __init__(self, init_opts=None, render_opts=None):

204

"""

205

Initialize an effect scatter chart.

206

207

Args:

208

init_opts (InitOpts, optional): Chart initialization options

209

render_opts (RenderOpts, optional): Rendering options

210

"""

211

212

def add_xaxis(self, xaxis_data):

213

"""

214

Add x-axis data.

215

216

Args:

217

xaxis_data (list): List of x-axis values

218

219

Returns:

220

EffectScatter: Self for method chaining

221

"""

222

223

def add_yaxis(self, series_name, y_axis, **kwargs):

224

"""

225

Add y-axis data series with effects.

226

227

Args:

228

series_name (str): Name of the data series

229

y_axis (list): List of y values or EffectScatterItem objects

230

effect_opts (EffectOpts, optional): Animation effect options

231

232

Returns:

233

EffectScatter: Self for method chaining

234

"""

235

```

236

237

### Heatmaps

238

239

Creates heatmaps for visualizing data through colors, useful for correlation matrices and 2D data density.

240

241

```python { .api }

242

class HeatMap:

243

def __init__(self, init_opts=None, render_opts=None):

244

"""

245

Initialize a heatmap.

246

247

Args:

248

init_opts (InitOpts, optional): Chart initialization options

249

render_opts (RenderOpts, optional): Rendering options

250

"""

251

252

def add_xaxis(self, xaxis_data):

253

"""

254

Add x-axis categories.

255

256

Args:

257

xaxis_data (list): List of x-axis category names

258

259

Returns:

260

HeatMap: Self for method chaining

261

"""

262

263

def add_yaxis(self, series_name, yaxis_data, value, **kwargs):

264

"""

265

Add heatmap data.

266

267

Args:

268

series_name (str): Name of the data series

269

yaxis_data (list): List of y-axis category names

270

value (list): List of [x_index, y_index, value] triplets

271

272

Returns:

273

HeatMap: Self for method chaining

274

"""

275

```

276

277

### Additional Chart Types

278

279

```python { .api }

280

class Boxplot:

281

"""Box and whisker plots for statistical data visualization."""

282

def __init__(self, init_opts=None, render_opts=None): ...

283

def add_xaxis(self, xaxis_data): ...

284

def add_yaxis(self, series_name, y_axis, **kwargs): ...

285

286

class Funnel:

287

"""Funnel charts for process flow visualization."""

288

def __init__(self, init_opts=None, render_opts=None): ...

289

def add(self, series_name, data_pair, **kwargs): ...

290

291

class Gauge:

292

"""Gauge charts for dashboard-style metrics."""

293

def __init__(self, init_opts=None, render_opts=None): ...

294

def add(self, series_name, data_pair, **kwargs): ...

295

296

class Graph:

297

"""Network diagrams and relationship visualizations."""

298

def __init__(self, init_opts=None, render_opts=None): ...

299

def add(self, series_name, nodes, links, **kwargs): ...

300

301

class Kline:

302

"""Candlestick charts for financial data."""

303

def __init__(self, init_opts=None, render_opts=None): ...

304

def add_xaxis(self, xaxis_data): ...

305

def add_yaxis(self, series_name, y_axis, **kwargs): ...

306

307

class Liquid:

308

"""Liquid fill gauge charts."""

309

def __init__(self, init_opts=None, render_opts=None): ...

310

def add(self, series_name, data, **kwargs): ...

311

312

class Parallel:

313

"""Parallel coordinate plots for multivariate data."""

314

def __init__(self, init_opts=None, render_opts=None): ...

315

def add_schema(self, schema): ...

316

def add(self, series_name, data, **kwargs): ...

317

318

class PictorialBar:

319

"""Pictorial bar charts with custom symbols."""

320

def __init__(self, init_opts=None, render_opts=None): ...

321

def add_xaxis(self, xaxis_data): ...

322

def add_yaxis(self, series_name, y_axis, **kwargs): ...

323

324

class Polar:

325

"""Polar coordinate system charts."""

326

def __init__(self, init_opts=None, render_opts=None): ...

327

def add_schema(self, schema, **kwargs): ...

328

def add(self, series_name, data, **kwargs): ...

329

330

class Radar:

331

"""Radar/spider charts for multivariate data."""

332

def __init__(self, init_opts=None, render_opts=None): ...

333

def add_schema(self, schema, **kwargs): ...

334

def add(self, series_name, data, **kwargs): ...

335

336

class Sankey:

337

"""Sankey diagrams for flow visualization."""

338

def __init__(self, init_opts=None, render_opts=None): ...

339

def add(self, series_name, nodes, links, **kwargs): ...

340

341

class Sunburst:

342

"""Sunburst charts for hierarchical data."""

343

def __init__(self, init_opts=None, render_opts=None): ...

344

def add(self, series_name, data_pair, **kwargs): ...

345

346

class ThemeRiver:

347

"""Theme river charts for temporal categorical data."""

348

def __init__(self, init_opts=None, render_opts=None): ...

349

def add(self, series_name, data, **kwargs): ...

350

351

class Tree:

352

"""Tree diagrams for hierarchical structures."""

353

def __init__(self, init_opts=None, render_opts=None): ...

354

def add(self, series_name, data, **kwargs): ...

355

356

class TreeMap:

357

"""Treemap charts for hierarchical data with area encoding."""

358

def __init__(self, init_opts=None, render_opts=None): ...

359

def add(self, series_name, data, **kwargs): ...

360

361

class WordCloud:

362

"""Word cloud visualizations."""

363

def __init__(self, init_opts=None, render_opts=None): ...

364

def add(self, series_name, data_pair, **kwargs): ...

365

366

class Custom:

367

"""Custom chart definitions for advanced use cases."""

368

def __init__(self, init_opts=None, render_opts=None): ...

369

def add(self, series_name, data, **kwargs): ...

370

371

class Calendar:

372

"""Calendar heatmaps for temporal data."""

373

def __init__(self, init_opts=None, render_opts=None): ...

374

def add(self, series_name, data, **kwargs): ...

375

```

376

377

## Common Chart Methods

378

379

All chart classes inherit common methods from the base Chart class:

380

381

```python { .api }

382

class ChartMethods:

383

def set_global_opts(self, **kwargs):

384

"""

385

Set global chart options.

386

387

Args:

388

title_opts (TitleOpts, optional): Title configuration

389

legend_opts (LegendOpts, optional): Legend configuration

390

tooltip_opts (TooltipOpts, optional): Tooltip configuration

391

toolbox_opts (ToolboxOpts, optional): Toolbox configuration

392

xaxis_opts (AxisOpts, optional): X-axis configuration

393

yaxis_opts (AxisOpts, optional): Y-axis configuration

394

visualmap_opts (VisualMapOpts, optional): Visual mapping

395

datazoom_opts (DataZoomOpts, optional): Data zoom controls

396

397

Returns:

398

Chart: Self for method chaining

399

"""

400

401

def set_series_opts(self, **kwargs):

402

"""

403

Set series-specific options.

404

405

Args:

406

label_opts (LabelOpts, optional): Data label options

407

itemstyle_opts (ItemStyleOpts, optional): Item styling

408

linestyle_opts (LineStyleOpts, optional): Line styling

409

areastyle_opts (AreaStyleOpts, optional): Area styling

410

markpoint_opts (MarkPointOpts, optional): Mark points

411

markline_opts (MarkLineOpts, optional): Mark lines

412

413

Returns:

414

Chart: Self for method chaining

415

"""

416

417

def render(self, path="render.html"):

418

"""

419

Render chart to HTML file.

420

421

Args:

422

path (str): Output file path

423

424

Returns:

425

str: Generated HTML content

426

"""

427

428

def render_notebook(self):

429

"""

430

Render chart for Jupyter notebook display.

431

432

Returns:

433

HTML: Jupyter HTML display object

434

"""

435

```

436

437

## Data Item Types

438

439

```python { .api }

440

class BarItem:

441

def __init__(self, name=None, value=None, **kwargs): ...

442

443

class LineItem:

444

def __init__(self, name=None, value=None, **kwargs): ...

445

446

class PieItem:

447

def __init__(self, name=None, value=None, **kwargs): ...

448

449

class ScatterItem:

450

def __init__(self, name=None, value=None, **kwargs): ...

451

452

class EffectScatterItem:

453

def __init__(self, name=None, value=None, **kwargs): ...

454

455

class FunnelItem:

456

def __init__(self, name=None, value=None, **kwargs): ...

457

458

class RadarItem:

459

def __init__(self, name=None, value=None, **kwargs): ...

460

461

class TreeItem:

462

def __init__(self, name=None, value=None, children=None, **kwargs): ...

463

464

class SunburstItem:

465

def __init__(self, name=None, value=None, children=None, **kwargs): ...

466

467

class ThemeRiverItem:

468

def __init__(self, date=None, value=None, name=None): ...

469

470

class CandleStickItem:

471

def __init__(self, name=None, value=None): ...

472

473

class BoxplotItem:

474

def __init__(self, name=None, value=None): ...

475

```