Skip to main content

QCustomAreaChart

QCustomAreaChart

Area chart implementation using the modular architecture.

Qt Designer compatible with property exposure.

At a glance

TierFree (GPLv3)
Importfrom Custom_Widgets.QCustomCharts.QCustomAreaChart import QCustomAreaChart
Qt DesignerYes — drag it from the palette

Quick start

from Custom_Widgets.QCustomCharts.QCustomAreaChart import QCustomAreaChart

widget = QCustomAreaChart()
widget.categoriesCsv = "Jan,Feb,Mar,Apr,May,Jun"
widget.seriesCsv = "Revenue=12,19,15,24,22,30;Costs=8,11,9,14,13,17"
_chartPresentation(w, theme, "Revenue vs costs", "Month", "$k")

That is the exact code behind the screenshot above.

Dark theme

Colours come from the design tokens, so the widget follows the app theme with no extra work.

QCustomAreaChart in dark theme

Properties

Every property below is settable in code and in Qt Designer.

PropertyTypeDefault
gradientFillboolTrue
gradientTypestringvertical
baselineValuefloat0.0
stackedAreaboolFalse
percentageAreaboolFalse
fillOpacityfloat0.3
xAxisTitlestringX Axis
yAxisTitlestringY Axis
autoScaleboolTrue
showCrosshairboolTrue
crosshairColorcolor#000000
crosshairWidthfloat1.0
showGridboolTrue
gridColorcolor#c8c8c8
showLegendboolTrue
showDataPointsboolTrue
fillAreaboolTrue
enableShadowboolFalse
shadowBlurint15
highlightSizeint8
markerSizefloat8.0
showFooterboolTrue
defaultLineStyleint0
defaultMarkerStyleint6
chartTitlestringArea Chart
animationEnabledboolTrue
animationDurationint1000
antialiasingboolTrue
showToolbarboolFalse
tooltipsEnabledboolTrue
tooltipDelayint500
tooltipDurationint5000
themeint0
legendPositionint1
legendFontSizeint8
legendBackgroundVisibleboolFalse
compactModeboolFalse
seriesCsvstring
categoriesCsvstring

Signals

Signal
chartExportComplete(QString,bool)
dataPointClicked(double,double,QString)
dataPointHovered(double,double,QString)
legendPositionChanged(QString)
seriesAdded(QString)
seriesRemoved(QString)

Methods

MethodDescription
`addSeries(name: str, data: List[Tuple[float, float]], color: PySide6.QtGui.QColorNone = None, visible: bool = True, line_style: str = 'solid', line_width: float = 2.0, marker_style: str = 'none', marker_size: float = None, **kwargs) -> bool`
appendToSeries(name: str, points: List[Tuple[float, float]]) -> boolAppend points to an existing series
applyCustomPalette(palette: PySide6.QtGui.QPalette)Apply a custom palette to the chart (for App Theme)
areaBorderEdges() -> boolWhether the full area outline is stroked (see setAreaBorderEdges).
baselineValue(*args, **kwargs)Get baseline value
chartExportComplete(...)Chart export complete.
clearData()Clear all chart data (compatibility method)
dataPointClicked(...)Data point clicked.
dataPointHovered(...)Data point hovered.
exportToClipboard()Export chart to clipboard
exportToFile(format: str = None, filename: str = None)Export chart to file
fillOpacity(*args, **kwargs)Get fill opacity
generateExampleData(example_type: str = 'sine_wave')Generate example data for testing.
getAvailableLegendPositions() -> List[str]Get list of available legend positions
getAvailableThemes() -> List[str]Get list of available theme names
getBaselineValue() -> floatGet the baseline value
getFillOpacity() -> floatGet fill opacity
getGradientType() -> strGet gradient type
getLegendAlignment() -> PySide6.QtCore.Qt.AlignmentFlagGet current legend alignment
getLegendFontSize() -> intGet legend font size
getMarkerSizeRange() -> Tuple[float, float]Get valid marker size range
getSeriesData(name: str) -> List[Tuple[float, float]]Get data for a specific series (overrides base method)
getSeriesLineStyle(name: str) -> strGet line style for a series
getSeriesMarkerSize(name: str) -> floatGet marker size for a specific series
getSeriesMarkerStyle(name: str) -> strGet marker style for a series
getSeriesNames() -> List[str]Get list of all series names (overrides base method)
getXAxisRange() -> Tuple[float, float]Get X axis range
getYAxisRange() -> Tuple[float, float]Get Y axis range
gradientFill(*args, **kwargs)Get gradient fill state
gradientType(*args, **kwargs)Get gradient type
hasCustomMarkerSize(series_name: str) -> boolCheck if series has custom marker size
hideCrosshair()Manually hide crosshair
hideTooltip()Manually hide tooltip
isGradientFillEnabled() -> boolCheck if gradient fill is enabled
isPercentageArea() -> boolCheck if percentage area is enabled
isStackedArea() -> boolCheck if stacked area is enabled
isValidLineStyle(style: str) -> boolCheck if line style is valid
isValidMarkerStyle(style: str) -> boolCheck if marker style is valid
legendPositionChanged(...)Legend position changed.
percentageArea(*args, **kwargs)Get percentage area state
printChart()Print chart
refreshTheme()Refresh the current theme (useful when app palette changes)
removeSeries(name: str) -> boolRemove a series from the chart
resetMarkerSizes()Reset all marker sizes to default
seriesAdded(...)Series added.
seriesRemoved(...)Series removed.
setAllMarkersSize(size: float)Set marker size for all series
setAreaBorderEdges(enabled: bool)Draw the area polygon's full outline (True, default) or only the top
setBaselineValue(value: float)Set the baseline value for area chart
setChartTitle(title: str)Set chart title (compatibility method)
setCrosshairColor(color: PySide6.QtGui.QColor)Set crosshair line color
setCrosshairStyle(style: PySide6.QtCore.Qt.PenStyle)Set crosshair line style
setCrosshairWidth(width: float)Set crosshair line width
setFillOpacity(opacity: float)Set fill opacity (0.0 to 1.0)
setGradientFill(enabled: bool)Enable or disable gradient fill
setGradientType(gradient_type: str)Set gradient type: 'vertical', 'horizontal', or 'radial'
setLegendAlignment(alignment: PySide6.QtCore.Qt.AlignmentFlag)Directly set legend alignment
setLegendBackgroundVisible(visible: bool)Set legend background visibility
setLegendFontSize(size: int)Set legend font size
setPercentageArea(percentage: bool)Enable or disable percentage area chart
setSeriesColor(name: str, color: PySide6.QtGui.QColor)Set color for a specific series (overrides base method)
setSeriesLineStyle(name: str, style: str) -> boolSet line style for a series
setSeriesLineWidth(name: str, width: float) -> boolSet line width for a series
setSeriesMarkerSize(name: str, size: float) -> boolSet marker size for a series
setSeriesMarkerStyle(name: str, style: str) -> boolSet marker style for a series
setSeriesVisibility(name: str, visible: bool)Set visibility for a specific series (overrides base method)
setStackedArea(stacked: bool)Enable or disable stacked area chart
setXAxisRange(min_val: float, max_val: float)Set X axis range
setXAxisTitle(title: str)Set X axis title
setYAxisRange(min_val: float, max_val: float)Set Y axis range
setYAxisTitle(title: str)Set Y axis title
showCrosshairAt(x: float, y: float)Manually show crosshair at specific coordinates
showTooltipAt(x: float, y: float, series_name: str, title: str = None, description: str = None)Manually show tooltip at specific coordinates
stackedArea(*args, **kwargs)Get stacked area state
updateChart()Update the chart display based on current data
updateSeriesData(name: str, data: List[Tuple[float, float]]) -> boolUpdate data for an existing series

Theming

Colours come from the design tokens, so they follow the active theme. Roles used: surface, on-surface, outline, accent.

See Design tokens.

QCustomBarChart · QCustomBeeswarm · QCustomBubbleChart · QCustomCandlestickChart · QCustomCompass · QCustomCompassDial · QCustomDivergingBarChart · QCustomDonut