generate_pubmed_chart
Create customizable bar, line, and scatter charts from PubMed data. Define axes, titles, and visual encodings like color and size. Generates a PNG image using Vega-Lite for clear visualization of research trends and patterns.
Instructions
Generates a customizable chart (PNG) from structured data. Supports 'bar', 'line', and 'scatter' plots. Requires data values and field mappings for axes. Optional parameters allow for titles, dimensions, and color/size/series encoding. Internally uses Vega-Lite and a canvas renderer to produce a Base64-encoded PNG image.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
chartType | Yes | Required. Specifies the type of chart to generate. Options: 'bar', 'line', 'scatter'. | |
colorField | No | Optional. The name of the field in `dataValues` to use for color encoding. This can differentiate bars, lines, or points by color based on the values in this field (e.g., 'studyType', 'country'). | |
colorFieldType | No | Optional. Specifies the data type of the `colorField`. Options: 'nominal', 'ordinal', 'quantitative', 'temporal'. Defaults to 'nominal' if `colorField` is provided and this is omitted. | |
dataValues | Yes | Required. An array of data objects used to plot the chart. Each object represents a data point or bar, structured as key-value pairs (e.g., [{ 'year': '2020', 'articles': 150 }, { 'year': '2021', 'articles': 180 }]). Must contain at least one data object. | |
height | No | Optional. The height of the chart canvas in pixels. Must be a positive integer. Default: 300. | |
outputFormat | No | Specifies the output format for the chart. Currently, only 'png' (Portable Network Graphics) is supported and is the default. | png |
seriesField | No | Optional. Primarily for line charts. The name of the field in `dataValues` used to create multiple distinct lines (series) on the same chart. Each unique value in this field will correspond to a separate line (e.g., 'drugName' to plot different drug efficacy trends). Often used with `colorField` implicitly or explicitly. | |
seriesFieldType | No | Optional. Specifies the data type of the `seriesField`. Options: 'nominal', 'ordinal', 'quantitative', 'temporal'. Defaults to 'nominal' if `seriesField` is provided and this is omitted. | |
sizeField | No | Optional. For scatter plots. The name of the field in `dataValues` to use for encoding the size of the points. Larger values in this field will result in larger points on the scatter plot (e.g., 'sampleSize', 'effectMagnitude'). | |
sizeFieldType | No | Optional. Specifies the data type of the `sizeField`. Options: 'quantitative', 'ordinal'. Defaults to 'quantitative' if `sizeField` is provided and this is omitted. | |
title | No | Optional. The main title displayed above the chart. If omitted, no title is shown. | |
width | No | Optional. The width of the chart canvas in pixels. Must be a positive integer. Default: 400. | |
xField | Yes | Required. The name of the field in `dataValues` to be used for the X-axis (horizontal). This field determines the categories or values along the bottom of the chart (e.g., 'year', 'geneName', 'publicationCount'). | |
xFieldType | No | Optional. Specifies the data type of the X-axis field. Options: 'nominal' (categories), 'ordinal' (ordered categories), 'quantitative' (numerical), 'temporal' (dates/times). If omitted, a suitable default is chosen based on `chartType` (e.g., 'nominal' for bar charts, 'temporal' for line charts, 'quantitative' for scatter plots). | |
yField | Yes | Required. The name of the field in `dataValues` to be used for the Y-axis (vertical). This field determines the values plotted upwards on the chart (e.g., 'articles', 'expressionLevel', 'citationCount'). | |
yFieldType | No | Optional. Specifies the data type of the Y-axis field. Options: 'nominal', 'ordinal', 'quantitative', 'temporal'. Defaults to 'quantitative' if omitted. |