gramex-area-line-chart
v1.0.1
Published
The drawAreaLineChart function is a JavaScript utility for creating area-line charts using the D3.js library. This function accepts a configuration object with parameters such as selector, data, xColumn, yColumn, period, width, and height. It generates an
Downloads
4
Readme
drawAreaLineChart Function
The drawAreaLineChart function is a JavaScript utility for creating area-line charts using the D3.js library. This function accepts a configuration object with parameters such as selector, data, xColumn, yColumn, period, width, and height. It generates an interactive area-line chart with tooltips.
Usage
drawAreaLineChart({
selector: '#chartContainer',
data: [
{'date': '202201', 'value': 10, 'tooltip_text': 'Details 1', 'text_label': 'Label 1'},
// ... more data objects
],
xColumn: 'date',
yColumn: 'value',
period: 'monthly', // 'monthly' or 'quarterly'
width: 800, // optional width
height: 400, // optional height
});
Parameters
- selector (string): The CSS selector for the container element where the chart will be rendered.
- data (array): An array of objects representing the chart data. Each object should have properties like 'date', 'value', 'tooltip_text', and 'text_label'.
- xColumn (string): The name of the column in the data representing the X-axis values.
- yColumn (string): The name of the column in the data representing the Y-axis values.
- period (string): Specifies the time period for X-axis tick labels. It can be either 'monthly' or 'quarterly'.
- width (number, optional): The width of the chart. If not provided, it will use the width of the selector element.
- height (number, optional): The height of the chart.
Features
- Handles empty data or data with zero total values gracefully.
- Dynamically adjusts chart dimensions based on the provided width and height or the container's width.
- Displays a custom tooltip with relevant information when hovering over data points.
- Includes text labels for additional insights associated with data points.