ans2dev.general.charts module – Generate charts images.
Note
This module is part of the ans2dev.general collection (version 0.2.0).
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install ans2dev.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: ans2dev.general.charts
.
New in ans2dev.general 0.1.0
Synopsis
This module generates various types of charts like
line
,bar
,pie
anddonut
and saves them as images.It provides customization options for titles, axis labels, colors, sizes, fonts, and legends.
Uses `Plotly` and `Kaleido` for image generation.
Requirements
The below requirements are needed on the host that executes this module.
requests
plotly
kaleido
Parameters
Parameter |
Comments |
---|---|
Filename for the saved chart image. |
|
Font color for chart text. Default: |
|
Font size for labels and text. Default: |
|
Image format for saving the chart. Choices:
|
|
Height of the generated chart image (in pixels). Default: |
|
Width of the generated chart image (in pixels). Default: |
|
Path where the chart image will be saved. |
|
Line shape for Choices:
|
|
Size of the hole in a Default: |
|
Colors for Default: |
|
Data values for Default: |
|
Labels for Default: |
|
Title of the chart. |
|
Title for the legend. |
|
Type of chart to generate. Choices:
|
|
X-axis data values for Default: |
|
Label for the X-axis for |
|
List of Y-axis data series for Default: |
|
Colors for the Y-axis data series for Default: |
|
Labels for the Y-axis data series for Default: |
Examples
- name: Generate a line chart for CPU Usage Over Time
ans2dev.general.charts:
type: "line"
titlechart: "CPU Usage Over Time"
xaxis: ['00:00', '02:00', '04:00', '06:00', '08:00']
xaxisname: "Time"
yaxis: [[20, 30, 40, 50, 60]]
yaxisname: ["CPU Usage %"]
yaxiscolor: ["red"]
shape_line: "spline"
imgwidth: 1920
imgheight: 1080
path: "/charts"
filename: "cpu_usage"
format: "png"
titlelegend: "Usage"
delegate_to: localhost
- name: Generate a pie chart for Resource Distribution
ans2dev.general.charts:
type: "pie"
titlechart: "Resource Distribution"
slicedata: [10, 20, 30, 40]
slicelabel: ["A", "B", "C", "D"]
slicecolor: ["#ff0000", "#00ff00", "#0000ff", "#ffff00"]
imgwidth: 800
imgheight: 600
path: "/charts"
filename: "resource_distribution"
format: "png"
delegate_to: localhost
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Indicates whether the chart image was successfully generated. Returned: always Sample: |