On this page

Creating chart objects and setting chart types and styles

To create a chart in accordance with the specified chart type and style, use the following code:

create(chartType, chartStyle, startCell, columnSize, rowSize)

Where the parameters are:

  • chartType: case-sensitive type of the created chart with one of the following options:
    • "Line"
    • "Column"
    • "Pie"
    • "Bar"
    • "Area"
    • "Surface"
    • "Radar"
  • chartStyle: case-sensitive style of the created chart with one of the following options:

    • Line
      • "Line" (the default style)
      • "Staked Line"
      • "100% Stacked Line"
      • "Line with Markers"
      • "Stacked Line with Markers"
      • "100% Stacked Line with Markers"
      • "3-D Line"
    • Column
      • "Clustered Column" (the default style)
      • "Stacked Column"
      • "100% Stacked Column"
      • "3-D Clustered Column"
      • "3-D Stacked Column"
      • "3-D 100% Stacked Column"
      • "3-D Column"
    • Pie
      • "Pie" (the default style)
      • "3-D Pie"
      • "Doughnut"
    • Bar

      • "Clustered Bar" (the default style)

      • "Stacked Bar"

      • "100% Stacked Bar"

      • "3-D Clustered Bar"

      • "3-D Stacked Bar"

      • "3-D 100% Stacked Bar"

    • Area

      • "Area" (the default style)

      • "Stacked Area"

      • "100% Stacked Area"

      • "3-D Area"

      • "3-D Stacked Area"

      • "3-D 100% Stacked Area"

    • Surface

      • "3-D Surface" (the default style)

      • "Wireframe 3-D Surface"

      • "Contour"

      • "Wireframe Contour"

    • Radar

      • "Radar" (the default style)

      • "Radar with Markers"

      • "Filled Radar"

If you do not specify the chart style, the default style of the chosen chart type is used.

  • startCell: the first cell of the data table used for the chart.
  • columnSize and rowSize: numeric values that determine the size of the data table.

An example of the code for a 3x5 size data table starting at cell A4:

#set($linechart = $chart.create("Column", "3-D Column", "A4", 3, 5))

Setting chart titles

To set a chart title, use the following code:

setTitle(title String)

For example:

$linechart.setTitle("Line Chart")

If you do not enter the chart title, the default title “Sample” is used.

Printing a chart to a report

To print a chart to a report, use the following code:

buildChart()

For example:

$linechart.buildChart()

A full sample of the Chart tool code is shown below:

#import('chart', 'com.nomagic.reportwizard.tools.ChartTool')
#set($linechart = $chart.create("Column", "3-D Column", "A4", 3, 5))
$linechart.setTitle("Sample")
$linechart.buildChart()



A chart printed to a report after applying the full sample code using the Chart tool.