JSON API - addChart

addChart

PREMIUM TRIAL / ADVANCED

Inserts a chart into the Excel spreadsheet.

Note

You are reading the JSON API documentation. For the PHP API method please go to addChart.

JSON data
Key Description
chart

Chart type:

  • area
  • area3D
  • bar
  • bar3D, bar3DCone, bar3DCylinder, bar3DPyramid
  • bubble
  • col
  • col3D, col3DCone, col3DCylinder, col3DPyramid
  • doughnut
  • line
  • line3D
  • ofPie
  • pie
  • pie3D
  • radar
  • scatter
  • surface
position Cell position in the active sheet: "A1", "C3", "AB7"...
data This array contains legends, labels and values of the chart. Individual cell positions and cell range positions can be used.
border Border width in points.
color Color scheme.
colOffset
  • from => column size offset from.
  • to => column size offset to.
colSize Number of columns used by the chart.
font The font to be used. Arial, Calibri...
rowOffset
  • from => row size offset from.
  • to => row size offset to.
rowSize Number of rows used by the chart.
title The chart title (if any).

Chart display properties

Key Description
axPos Position of the axis (r, l, t, b). Each value of the array for each position (if a value is null avoids adding it).
formatCode Number format.
formatDataLabels Possible keys and values are:
  • rotation
  • position => center, insideEnd, insideBase, outsideEnd
haxLabel Label for the horizontal axis.
haxLabelDisplay How to display the label of the horizontal axis. Possible values are: vertical, horizontal, rotated.
hgrid Horizontal grid. Possible values are:
  • 0 (no grid)
  • 1 (only major grid lines - default)
  • 2 (only minor grid lines)
  • 3 (both major and minor grid lines)
majorUnit Major unit value for bar, col and line charts.
minorUnit Minor unit value for bar, col and line charts.
orientation Orientation of the axis, from min to max (minMax) or max to min (maxMin). Each value of the array for each axis (if a value if null avoids adding it).
scalingMax Scaling max value for bar, col and line charts.
scalingMin Scaling max value for for bar, col and line charts.
stylesTitle Possible keys and values are:
  • bold
  • color: ffffff, ff0000...
  • font: Arial, Times New Roman...
  • fontSize: 1420, 2000... Size as drawing content (10 to 400000). 1420 as default
  • italic
  • layout:
    • x: 0 < x < 1
    • y: 0 < y < 1
tickLblPos Tick label position (nextTo, high, low, none). If string, uses default values. If array, sets a value for each position.
vaxLabel Label for the vertical axis.
vaxLabelDisplay How to display the label of the horizontal axis. Possible values are: vertical, horizontal, rotated.
vgrid Vertical grid. Possible values are:
  • 0 (no grid)
  • 1 (only major grid lines - default)
  • 2 (only minor grid lines)
  • 3 (both major and minor grid lines)

The available parameters to display legends and data include

Key Description
legendOverlay If true the legend may overlay the chart.
legendPos The possible values are:
  • b (bottom)
  • l (left)
  • r (right)
  • t (top)
  • none
showCategory If true shows the categories inside the chart.
showLegendKey If true shows the legend values.
showPercent If true shows the percentage values.
showSeries If true shows the series values.
showTable If true shows the chart data in an associated table.
showValue If true shows the chart data values.
trendline Adds trendlines. Compatible with line, bar, col and area 2D charts. Possible keys and values are:
  • color => 0000FF...
  • display_equation => display equation on chart
  • display_rSquared => display R-squared value on chart
  • intercept => set intercept
  • line_style => solid, dot, dash, lgDash, dashDot, lgDashDot, lgDashDotDot, sysDash, sysDot, sysDashDot, sysDashDotDot
  • type => exp, linear, log, poly, power, movingAvg
  • type_order => for poly and movingAvg types

Further configuration options for specific chart types

Key Description
Bar and column charts
gapWidth Gap width.
groupBar Different ways to group data. Possible values are: clustered, stacked, percentStacked and standard.
overlap Overlap.
Pie and doughnut charts
explosion Distance between the different values.
holeSize Size of the inner hole (only doughnut charts).
Line charts
smooth If true it smooths the line. "0" forces disabling it
symbol The possible symbol values are:
  • Line charts: none, dot, plus, square, star, triangle, x, diamond, circle and dash.
symbolSize The size of the symbol used. From 1 to 73.

Additional available options for 3D charts

Key Description
perspective Perspective angle. Angles beyond 25 degrees provoke a big distortion in the 3D chart representation.
rotX Rotation angle with respect to the vertical axis. Standard values are between 10 and 20 degrees.
rotY Rotation angle with respect to the horizontal axis. Standard values are between 10 and 20 degrees.

Theme options

Key Description
chartArea backgroundColor
gridLines
  • capType
  • color
  • dashType
  • width
horizontalAxis
  • textBold
  • textDirection => horizontal, rotate90, rotate270
  • textItalic
  • textSize
  • textUnderline => DrawingML values such as none, sng, dash
legendArea
  • backgroundColor
  • textBold
  • textItalic
  • textSize
  • textUnderline => DrawingML values such as none, sng, dash
plotArea backgroundColor
serDataLabels
  • fontStyles:
    • bold
    • color: ffffff, ff0000...
    • font: Arial, Times New Roman...
    • fontSize: size as drawing content (100 to 400000) (100 = 1pt). 1420 as default
    • italic
  • formatCode
  • position => center, insideEnd, insideBase, outsideEnd
  • showCategory => 0, 1
  • showLegendKey => 0, 1
  • showPercent => 0, 1
  • showSeries => 0, 1
  • showValue => 0, 1
serRgbColors series colors
valueDataLabels
  • fontStyles:
    • bold
    • color: ffffff, ff0000...
    • font: Arial, Times New Roman...
    • fontSize: size as drawing content (100 to 400000) (100 = 1pt). 1420 as default
    • italic
  • position => bottom, center, insideEnd, insideBase, left, outsideEnd, right, top, bestFit
  • showCategory => 0, 1
  • showLegendKey => 0, 1
  • showPercent => 0, 1
  • showSeries => 0, 1
  • showValue => 0, 1
  • text => this text hides other automatic values
valueRgbColors values colors
verticalAxis
  • textBold
  • textDirection => horizontal, rotate90, rotate270
  • textItalic
  • textSize
  • textUnderline => DrawingML values such as none, sng, dash
Code samples

Example #1

Release notes
  • phpxlsx 6.0:
    • new action.