Chart Macro

The Chart macro displays charts from given data sources.

Usage

{{chart source="<inline|xdom>" type="<type>" params="<params>" title="<title>" width="<width>" height="<height>"
colors="<colors>" /}}

Parameters Definition

NameOptionalAllowed valuesDescriptionDefault value
sourceYes
  • xdom
  • inline
The type of data source providing input for chartinginline if the macro has content, xdom otherwise
typeNo
  • line
  • area
  • bar
  • pie
  • bar3D
  • line3D
  • xy_area
  • xy-line-and-shape
  • xy_line3D
  • xy_step
  • stackedbar
  • stackedbar3D 
The type of the generated chartNone
paramsYesA stringA list of parameter name to value mappings, depending on the data sourceNone
titleYesA stringThe title used when rendering the chartNone
widthYesA stringThe width of the chart image in pixels400
heightYesA stringThe height of the chart image in pixels300
colorsYesA stringThe list of colors to use The values are specified in hexadecimal.None

Generic Parameters

NameDescriptionDefault value
backgroundColorThe background color of the non-chart area specified using a hexadecimal notation (e.g. FFAACC) where the first 2 letters are for Red, the following 2 are for Green and last 2 are for Blue.
plotBackgroundColorThe background color of the plot area specified using an hexadecimal notation (see backgroundColor).White
plotBorderColorColor of the plot border specified using an hexadecimal notation (see backgroundColor)Black
borderColorColor of the outer graph border specified using an hexadecimal notation (see backgroundColor).Black
legendBackgroundColorBackground color of the legend box, specified using an hexadecimal notation (see backgroundColor).White
plotBorderVisibleWhether the border for the plot area is visible or not. Valid values are true and false.true
legendVisibleWhether the legend is displayed or not. Valid values are true and false.true

Pie Chart Parameters

NameOptionalAllowed valuesDescriptionDefault value
pie_label_formatYesUse {0} where the pie section key should be inserted, {1} for the absolute section value and {2} for the percent amount of the pie sectionThe format of the label for pie segments{0}

Example:{0} = {1} ({2}) will display the same result as apple = 120 (5%)

The params parameter

The "params" parameter can contain the following mappings:

  • document: the name of the wiki page
  • table: the id of the table source
  • time_period
    • millisecond
    • second
    • minute
    • hour
    • day
    • week
    • month
    • quarter
    • year
  • locale
  • date_format
  • axis related mappings:
    • domain_axis_type: the name of the domain axis parameter (e.g. date)
    • range_axis_type: the name of the range axis parameter
    • domain_axis_date_format: the name of the domain axis date format parameter that should only be used if the axis type is date
    • range_axis_date_format: the name of the range axis date format parameter that should only be used if the axis type is date
    • domain_axis_lower: the lower limit on the domain axis
    • domain_axis_upper: the upper limit on the domain axis
    • range_axis_lower: the lower limit on the range axis
    • range_axis_upper: the upper limit on the range axis
  • range: the data range selected just like for an Excel sheet
  • series
    • columns which defines the x and y axes
    • rows
  • dataset
    • category
    • timeseries
    • pie
    • xy
    • timetable_xy
  • hideShapes: hide the interpolation lines that connect the data points
  • colors

Examples

Generate a Bar chart from an xdom data source

{{chart type="bar" params="document:Sandbox.Test;table:barChartTable;range:B2-D5;series:columns;" title="Bar Chart Columns"
width="320" height="240"/}}

BarChartColumns.png

{{chart type="bar" params="document:Sandbox.Test;table:barChartTable;range:B2-D5;series:rows;" title="Bar Chart Rows"
width="320" height="240"/}}

BarChartRows.png

The page "Sandbox.Test" contains the following code:

(%id="barChartTable"%)
|=|=X|=Y|=Z
|Q1|1.2|3.4|1.3
|Q2|4.5|3.4|2.3
|Q3|1.2|4.5|9.0
|Q4|3.4|1.2|1.2

Generate a 3D Bar chart from an inline data source

{{chart type="bar3D" source="inline" params="range:B2-D5;series:columns;" title="3D Bar Chart" width="320" height="240"}}
|=|=X|=Y|=Z
|Q1|1.2|3.4|1.3
|Q2|4.5|3.4|2.3
|Q3|1.2|4.5|9.0
|Q4|3.4|1.2|1.2
{{/chart}}

3DBarChart.png

Generate a Pie chart from an inline data source

{{chart type="pie" source="inline" params="range:B2-D5;series:columns;" title="Pie Chart" width="320" height="240"}}
|=|=X|=Y|=Z
|Q1|1.2|3.4|1.3
|Q2|4.5|3.4|2.3
|Q3|1.2|4.5|9.0
|Q4|3.4|1.2|1.2
{{/chart}}

PieChart.png

Generate a Pie chart with custom colors

{{chart type="pie" source="inline" params="range:B2-D5;series:columns;colors:C3E3F7,1D9FF5,015891,012A45"
title="Pie Chart with Custom Colors" width="320" height="240"}}
|=|=X|=Y|=Z
|Q1|1.2|3.4|1.3
|Q2|4.5|3.4|2.3
|Q3|1.2|4.5|9.0
|Q4|3.4|1.2|1.2
{{/chart}}

PieChartCustomColors.png

Generate a "xy_line_and_shape" chart

{{chart type="xy_line_and_shape" params="range:B2-C19;dataset:timetable_xy;domain_axis_type:date;domain_axis_date_format:MMM-yyyy;
date_format:yyyy-MM;time_period:month;range_axis_lower:100; range_axis_upper:190"
title="xy_line_and_shape Chart"}}
|=|=Series1|=Series2
|2010-2|181.8|129.6
|2010-3|167.3|123.2
|2010-4|153.8|117.2
|2010-5|167.6|124.1
|2010-6|158.8|122.6
|2010-7|148.3|119.2
|2010-8|153.9|116.5
|2010-9|142.7|112.7
|2010-10|123.2|101.5
|2010-11|131.8|106.1
|2010-12|139.6|110.3
|2011-1|142.9|111.7
|2011-2|138.7|111.0
|2011-3|137.3|109.6
|2011-4|143.9|113.2
|2011-5|139.8|111.6
|2011-6|137.0|108.8
|2011-7|132.8|101.6
{{/chart}}

TimeseriesChart1.png

Generate a "xy_line3D" chart

{{chart type="xy_line3D" params="range:B2-C19;dataset:timetable_xy;domain_axis_type:date;domain_axis_date_format:MMM-yyyy;
date_format:yyyy-MM;time_period:month;range_axis_lower:100;range_axis_upper:190"
title="xy_line3D Chart"}}
|=|=Series1|=Series2
|2010-2|181.8|129.6
|2010-3|167.3|123.2
|2010-4|153.8|117.2
|2010-5|167.6|124.1
|2010-6|158.8|122.6
|2010-7|148.3|119.2
|2010-8|153.9|116.5
|2010-9|142.7|112.7
|2010-10|123.2|101.5
|2010-11|131.8|106.1
|2010-12|139.6|110.3
|2011-1|142.9|111.7
|2011-2|138.7|111.0
|2011-3|137.3|109.6
|2011-4|143.9|113.2
|2011-5|139.8|111.6
|2011-6|137.0|108.8
|2011-7|132.8|101.6
{{/chart}}

TimeseriesChart3D1.png

Generate a "xy_step" chart

{{chart type="xy_step" params="range:B2-C19;dataset:timetable_xy;domain_axis_type:date;domain_axis_date_format:MMM-yyyy;
date_format:yyyy-MM;time_period:month;range_axis_lower:100;range_axis_upper:190"
title="xy_step Chart"}}
|=|=Series1|=Series2
|2010-2|181.8|129.6
|2010-3|167.3|123.2
|2010-4|153.8|117.2
|2010-5|167.6|124.1
|2010-6|158.8|122.6
|2010-7|148.3|119.2
|2010-8|153.9|116.5
|2010-9|142.7|112.7
|2010-10|123.2|101.5
|2010-11|131.8|106.1
|2010-12|139.6|110.3
|2011-1|142.9|111.7
|2011-2|138.7|111.0
|2011-3|137.3|109.6
|2011-4|143.9|113.2
|2011-5|139.8|111.6
|2011-6|137.0|108.8
|2011-7|132.8|101.6
{{/chart}}

TimeseriesChart2.png

Generate a "line" chart without shapes for data points

{{chart type="line" source="inline" params="range:B2-D18;series:columns;colors:FF0000,FFA500,000000;hideShapes:true"
title="Disk Usage" width="400" height="200"}}
|=Date|=Warning|=Critical|=% Used
|1|90|80|85
|2|91|65|55
|3|90|80|93
|4|78|67|54
|5|90|98|87
|6|56|66|45
|7|56|45|87
|8|45|56|76
|9|56|98|45
|10|56|98|76
|11|78|67|54
|12|90|98|87
|13|56|66|45
|14|45|56|76
|15|56|98|45
|16|56|98|76
|17|90|80|85
|18|91|65|55
|19|90|80|93
|20|78|67|54
{{/chart}}

LineChartNoShapes.png

 Generate a "stackedbar" chart 

(%id=table1"%)
|=|=X|=Y|=Z
|Q1|1.2|3.4|1.3
|Q2|4.5|3.4|2.3
|Q3|1.2|4.5|9.0
|Q4|3.4|1.2|1.2

{{chart type="stackedbar" params="document:Sandbox.Test;table:table1;range:B2-D5;series:columns;" title="Stacked Bar Chart"
width="320" height="240"/}}

StackedBarChart.png

 Generate a "stackedbar3D" chart 

(%id=table1"%)
|=|=X|=Y|=Z
|Q1|1.2|3.4|1.3
|Q2|4.5|3.4|2.3
|Q3|1.2|4.5|9.0
|Q4|3.4|1.2|1.2

{{chart type="stackedbar3D" params="document:Sandbox.Test;table:table1;range:B2-D5;series:columns;" title="Stacked Bar 3D Chart"
width="320" height="240"/}}

StackedBar3DChart.png

Related Pages

Search this space

 

Most popular tags

Failed to execute the [groovy] macro
  1. access rights
  2. activity stream
  3. annotation
  4. attachment
  5. comment
  6. Document Tree Macro
  7. export
  8. Extension Manager
  9. Flamingo skin
  10. global user
  11. Groovy event listener
  12. group
  13. nested page
  14. search
  15. skin
  16. syntax
  17. user
  18. user profile
  19. velocity macros
  20. wiki
  21. wysiwyg
  22. XWiki Applications
  23. xwikiattachment_archive table
  24. xwikiattachment table
  25. xwikiattrecyclebin table
  26. xwikiproperties table

[Display all tags from this space]