Skip to main content

ChartParams

Struct ChartParams 

Source
pub struct ChartParams {
Show 19 fields pub sql: String, pub chart_type: String, pub x: Option<String>, pub y: Option<String>, pub series: Option<String>, pub title: Option<String>, pub format: Option<String>, pub width: Option<u32>, pub height: Option<u32>, pub bins: Option<u32>, pub x_as_category: Option<bool>, pub x_range: Option<[f64; 2]>, pub y_range: Option<[f64; 2]>, pub color_map: Option<HashMap<String, String>>, pub label_points: Option<bool>, pub output_path: Option<String>, pub inline: Option<bool>, pub overwrite: Option<bool>, pub database: Option<String>,
}
Expand description

Parameters for the chart tool.

Fields§

§sql: String

SQL query returning the data to plot (read-only SELECT/WITH/EXPLAIN/SHOW/VALUES)

§chart_type: String

Chart type: bar, line, scatter, or histogram

§x: Option<String>

X-axis column name (required for bar/line/scatter; histogram uses this as the value column)

§y: Option<String>

Y-axis column name (required for bar/line/scatter)

§series: Option<String>

Optional series/grouping column for colored/grouped multi-series charts

§title: Option<String>

Chart title

§format: Option<String>

Output format: “png” (default) or “svg”

§width: Option<u32>

Width in pixels (default 800)

§height: Option<u32>

Height in pixels (default 480)

§bins: Option<u32>

Number of bins for histograms (default 20)

§x_as_category: Option<bool>

Treat the x column as categorical rather than numeric. Auto-detected from the first row’s x value for line/scatter charts: DATE, TIMESTAMP, TEXT, and other non-numeric types flip to categorical automatically. Set explicitly to override auto-detection. Bar charts are always categorical regardless of this flag.

§x_range: Option<[f64; 2]>

Fix the x-axis range as [min, max]. Omit to auto-scale. Useful when comparing multiple charts at a consistent scale (e.g. [0, 1500] for population in millions) or when an outlier would distort auto-scaling. Ignored for bar charts (which use categorical x positions).

§y_range: Option<[f64; 2]>

Fix the y-axis range as [min, max]. Omit to auto-scale. Example: [0.0, 1.0] to pin a 0–1 index axis regardless of the data.

§color_map: Option<HashMap<String, String>>

Map series names to hex colors (“#rrggbb”). Series not listed here fall back to the default color palette. Example: {“India”: “#e41a1c”, “China”: “#ff7f0e”}. Only meaningful when a series column is set.

§label_points: Option<bool>

When true, draw the series name as a text label next to each dot (scatter) or point (line) and suppress the legend box. Best when each series has exactly one point (e.g. one country per dot). Defaults to false (legend shown).

§output_path: Option<String>

Where to write the rendered image. Parent directory is created automatically. If omitted, a file is auto-generated under the system temp dir (<temp>/hyperdb-charts/chart-<ts>-<pid>-<n>.<ext>). Combine with inline=true to receive the bytes inline AND write a file; otherwise the file is the sole output.

§inline: Option<bool>

When true, include the PNG/SVG bytes inline in the tool result. Without output_path this also skips the disk write entirely (pure inline). With output_path the file is written and the image is returned inline. Defaults to true so MCP clients can display the chart without a separate file-read round-trip.

§overwrite: Option<bool>

When false, refuse to overwrite an existing file at output_path and return PERMISSION_DENIED without touching it. Defaults to true (overwrite silently), matching the export tool.

§database: Option<String>

Target database alias for unqualified name resolution in the chart’s SQL. Omit to query the ephemeral primary. Pass "persistent" or a user-attached alias to chart from there.

Trait Implementations§

Source§

impl Debug for ChartParams

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ChartParams

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for ChartParams

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more