generate_bar_chart
Create horizontal bar charts for numerical comparisons across categories. Enable grouping or stacking for detailed analysis. Customize style, theme, and axis titles to visualize data effectively.
Instructions
Generate a horizontal bar chart to show data for numerical comparisons among different categories, such as, comparing categorical data and for horizontal comparisons.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
axisXTitle | No | Set the x-axis title of chart. | |
axisYTitle | No | Set the y-axis title of chart. | |
data | Yes | Data for bar chart, such as, [{ category: '分类一', value: 10 }, { category: '分类二', value: 20 }], when grouping or stacking is needed for bar, the data should contain a `group` field, such as, when [{ category: '北京', value: 825, group: '油车' }, { category: '北京', value: 1000, group: '电车' }]. | |
group | No | Whether grouping is enabled. When enabled, bar charts require a 'group' field in the data. When `group` is true, `stack` should be false. | |
height | No | Set the height of chart, default is 400. | |
stack | No | Whether stacking is enabled. When enabled, bar charts require a 'group' field in the data. When `stack` is true, `group` should be false. | |
style | No | Custom style configuration for the chart. | |
theme | No | Set the theme for the chart, optional, default is 'default'. | default |
title | No | Set the title of chart. | |
width | No | Set the width of chart, default is 600. |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"axisXTitle": {
"default": "",
"description": "Set the x-axis title of chart.",
"type": "string"
},
"axisYTitle": {
"default": "",
"description": "Set the y-axis title of chart.",
"type": "string"
},
"data": {
"description": "Data for bar chart, such as, [{ category: '分类一', value: 10 }, { category: '分类二', value: 20 }], when grouping or stacking is needed for bar, the data should contain a `group` field, such as, when [{ category: '北京', value: 825, group: '油车' }, { category: '北京', value: 1000, group: '电车' }].",
"items": {
"properties": {
"category": {
"type": "string"
},
"group": {
"type": "string"
},
"value": {
"type": "number"
}
},
"required": [
"category",
"value"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"group": {
"default": false,
"description": "Whether grouping is enabled. When enabled, bar charts require a 'group' field in the data. When `group` is true, `stack` should be false.",
"type": "boolean"
},
"height": {
"default": 400,
"description": "Set the height of chart, default is 400.",
"type": "number"
},
"stack": {
"default": true,
"description": "Whether stacking is enabled. When enabled, bar charts require a 'group' field in the data. When `stack` is true, `group` should be false.",
"type": "boolean"
},
"style": {
"description": "Custom style configuration for the chart.",
"properties": {
"backgroundColor": {
"description": "Background color of the chart, such as, '#fff'.",
"type": "string"
},
"palette": {
"description": "Color palette for the chart, it is a collection of colors.",
"items": {
"type": "string"
},
"type": "array"
},
"texture": {
"default": "default",
"description": "Set the texture for the chart, optional, default is 'default'. 'rough' refers to hand-drawn style.",
"enum": [
"default",
"rough"
],
"type": "string"
}
},
"type": "object"
},
"theme": {
"default": "default",
"description": "Set the theme for the chart, optional, default is 'default'.",
"enum": [
"default",
"academy",
"dark"
],
"type": "string"
},
"title": {
"default": "",
"description": "Set the title of chart.",
"type": "string"
},
"width": {
"default": 600,
"description": "Set the width of chart, default is 600.",
"type": "number"
}
},
"required": [
"data"
],
"type": "object"
}