Usage Guide

Usage Guide

ChartKit uses a "control + data structure + theme" model. Business code prepares categories, values, points, or slices, then passes them to the chart control.

Shared Base API

All current ChartKit controls inherit UIGQChartBase.

Method Description Parameters Return
setThemePreset(UIGQChartThemePreset preset) Applies a built-in theme preset. preset: kChartThemeDefault, kChartThemeMacarons, kChartThemeShine, or kChartThemeDark. void
getThemePreset() Reads the current theme preset. None. UIGQChartThemePreset
setTheme(const UIGQChartTheme& theme) Applies a custom theme structure. theme: theme data including background, axes, grid lines, and palette. void
getTheme() Reads the current theme structure. None. const UIGQChartTheme&
setLegendPosition(UIGQChartLegendPosition position) Places the legend at top, right, bottom, or left. position: legend position enum. void
getLegendPosition() Reads the current legend position. None. UIGQChartLegendPosition
setBackgroundColor(const QColor& color) Sets the chart widget background. color: background color. void
getBackgroundColor() Reads the chart widget background. None. QColor
setAnimationEnabled(bool enabled) Enables or disables animation. enabled: whether animation is enabled. void
getAnimationEnabled() Reads the animation switch. None. bool
setAnimationDuration(int durationMs) Sets animation duration. durationMs: duration in milliseconds. void
getAnimationDuration() Reads animation duration. None. int
restartAnimation() Replays animation after data changes. None. void
getAnimationProgress() Reads current animation progress. None. qreal
setTooltipOverlay(const QPoint& anchorPos, const QString& text) Sets tooltip overlay content. anchorPos: tooltip anchor; text: tooltip text. void
clearTooltipOverlay() Clears tooltip overlay. None. void
hasTooltipOverlay() Checks whether tooltip overlay exists. None. bool
drawTooltipOverlay(QPainter& painter) Draws tooltip overlay, usually from chart internals. painter: painter used for drawing. void

Data Entry Points

Chart Main Data Structure Recommended Entry
Line UIGQLineChartSeries setCategories(...) + setSeries(...)
Bar UIGQBarChartSeries setCategories(...) + setSeries(...)
Pie UIGQOpenGLPieChartSlice setSlices(...)
Scatter UIGQScatterChartSeries setSeries(...)

Recommended Flow

auto* chart = new UIGQBarChart(parent);

chart->setTitle("Policy Status");
chart->setCategories({"Active", "Expiring", "Invalid"});

QVector<UIGQBarChartSeries> series;
UIGQBarChartSeries item;
item.name = "Policies";
item.values = {420, 15, 30};
item.fillColor = QColor(35, 128, 224);
series.append(item);

chart->setSeries(series);
chart->setThemePreset(kChartThemeShine);
chart->setTooltipVisible(true);
chart->setHoverEnabled(true);

Notes

  • Keep category count and value count aligned whenever possible.
  • Use QVector<UIGQLineChartSeries> or QVector<UIGQBarChartSeries> for multiple series.
  • Use clearSeries() or clearSlices() to remove current data.
  • Use setSeriesVisible(index, visible) to toggle series visibility without deleting data.
  • Application code should configure data structures, theme settings, and interaction options through ChartKit public methods. Internal rendering objects are managed by the chart controls.