Skip to main content

QCustomLineChart

QCustomLineChart

Line chart implementation using the modular architecture.

Qt Designer compatible with property exposure.

At a glance​

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

Quick start​

from Custom_Widgets.QCustomCharts.QCustomLineChart import QCustomLineChart

widget = QCustomLineChart()
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.

QCustomLineChart in dark theme

Properties​

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

PropertyTypeDefault
fillOpacityfloat0.3
xAxisTitlestringX Axis
yAxisTitlestringY Axis
autoScaleboolTrue
showCrosshairboolTrue
crosshairColorcolor#000000
crosshairWidthfloat1.0
showGridboolTrue
gridColorcolor#c8c8c8
showLegendboolTrue
showDataPointsboolTrue
fillAreaboolFalse
enableShadowboolFalse
shadowBlurint15
highlightSizeint8
markerSizefloat8.0
showFooterboolTrue
defaultLineStyleint0
defaultMarkerStyleint6
chartTitlestringLine 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)
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
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
hasCustomMarkerSize(series_name: str) -> boolCheck if series has custom marker size
hideCrosshair()Manually hide crosshair
hideTooltip()Manually hide tooltip
isValidLineStyle(style: str) -> boolCheck if line style is valid
isValidMarkerStyle(style: str) -> boolCheck if marker style is valid
legendPositionChanged(...)Legend position changed.
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
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
setLegendAlignment(alignment: PySide6.QtCore.Qt.AlignmentFlag)Directly set legend alignment
setLegendBackgroundVisible(visible: bool)Set legend background visibility
setLegendFontSize(size: int)Set legend font size
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)
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
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, accent.

See Design tokens.

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