Skip to content

Chartjs

The Chart.JS chart engine supports the following chart types:

  • Bar chart
  • Horizontal bar chart
  • Line chart
  • Pie chart
  • Doughnut chart
  • Scatter plot
  • Bubble chart
  • Radar chart
Source code in ckanext/charts/chart_builders/chartjs.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class ChartJsBuilder(BaseChartBuilder):
    @classmethod
    def get_supported_forms(cls) -> list[type[Any]]:
        return [
            ChartJSBarForm,
            ChartJSHorizontalBarForm,
            ChartJSLineForm,
            ChartJSPieForm,
            ChartJSDoughnutForm,
            ChartJSScatterForm,
            ChartJSBubbleForm,
            ChartJSRadarForm,
        ]

    def _create_zoom_and_title_options(self, options: dict[str, Any]) -> dict[str, Any]:
        """Add zoom and title plugin options to the provided options dictionary"""
        if "plugins" not in options:
            options["plugins"] = {}

        options["plugins"].update(
            {
                "zoom": {
                    "zoom": {
                        "wheel": {"enabled": True},
                        "pinch": {"enabled": True},
                        "drag": {"enabled": True},
                        "mode": "xy",
                    },
                    "pan": {
                        "enabled": True,
                        "modifierKey": "shift",
                        "mode": "xy",
                    },
                },
                "title": {
                    "display": True,
                    "position": "bottom",
                },
            },
        )
        return options

Bar chart

The bar chart is a chart with rectangular bars with lengths proportional to the values that they represent. The bars can be plotted vertically or horizontally. For a horizontal bar chart, use the Horizontal bar chart chart type.

Horizontal bar chart

The horizontal bar chart is a chart with rectangular bars with lengths proportional to the values that they represent. The bars are plotted horizontally.

Line chart

The line chart is a chart that displays information as a series of data points called 'markers' connected by straight line segments. It is useful for showing trends over time.

Pie chart

The pie chart is a circular statistical graphic that is divided into slices to illustrate numerical proportions. The arc length of each slice is proportional to the quantity it represents.

Doughnut chart

The doughnut chart is a variant of the pie chart, with a hole in the center. It is useful for showing the relationship of parts to a whole.

Scatter plot

The scatter plot is a chart that uses Cartesian coordinates to display values for two variables for a set of data. The data points are represented as individual dots.

Bubble chart

The bubble chart is a chart that displays data points as bubbles. The size of the bubble represents a third dimension of the data.

Radar chart

The radar chart is a chart that displays multivariate data in the form of a two-dimensional chart of three or more quantitative variables represented on axes starting from the same point. The data points are connected by a line to form a polygon.