Home Web Front-end JS Tutorial How to use sunburst chart to display data in Highcharts

How to use sunburst chart to display data in Highcharts

Dec 18, 2023 am 08:18 AM
highcharts Data Display sunburst

How to use sunburst chart to display data in Highcharts

How to use a sunburst chart to display data in Highcharts

The sunburst chart is a visual chart with a hierarchical structure that can be used to display the hierarchical relationship and proportion of data. relation. In Highcharts, we can create a sunburst chart by setting relevant parameters and using appropriate data formats. This article will introduce how to use the Highcharts library to create a sunburst chart and provide some sample code for reference.

1. Data format

In Highcharts, the data format of the sunburst chart is a tree-shaped data based on a hierarchical structure. Each node contains the following attributes:

  • name: node name
  • value: the value of the node, used to determine the size of the node (can be a number or a string)
  • children: array of child nodes, representing the child nodes of the current node

The following is a simple data example:

{
    name: "总部",
    value: 1000,
    children: [
        {
            name: "部门A",
            value: 500,
            children: [
                {
                    name: "小组A1",
                    value: 200
                },
                {
                    name: "小组A2",
                    value: 300
                }
            ]
        },
        {
            name: "部门B",
            value: 500,
            children: [
                {
                    name: "小组B1",
                    value: 200
                },
                {
                    name: "小组B2",
                    value: 300
                }
            ]
        }
    ]
}
Copy after login

2. Code example

The following is a basic sunburst chart code example:

Highcharts.chart('container', {
    chart: {
        type: 'sunburst'
    },
    title: {
        text: '旭日图示例'
    },
    series: [{
        data: [
            {
                name: "总部",
                value: 1000,
                color: '#FAD107',
                children: [
                    {
                        name: "部门A",
                        value: 500,
                        color: '#34C1FE',
                        children: [
                            {
                                name: "小组A1",
                                value: 200,
                                color: '#FF0084'
                            },
                            {
                                name: "小组A2",
                                value: 300,
                                color: '#FF47A3'
                            }
                        ]
                    },
                    {
                        name: "部门B",
                        value: 500,
                        color: '#68C600',
                        children: [
                            {
                                name: "小组B1",
                                value: 200,
                                color: '#FF8000'
                            },
                            {
                                name: "小组B2",
                                value: 300,
                                color: '#FFA935'
                            }
                        ]
                    }
                ]
            }
        ]
    }]
});
Copy after login

In the above code, we use the chart object to set the chart type to sunburst chart. The data attribute in series is an array used to store the data of the sunburst chart. Each node is defined using the name, value, and color attributes. By setting the children attribute, you can nest hierarchical relationships.

3. Chart properties and style adjustment

Highcharts provides a wealth of properties and methods for adjusting the style and behavior of the sunburst chart. The following are some common properties:

  • chart.polar: Boolean value, used to specify whether it is a polar chart. Default is false.
  • chart.startAngle: Number, used to specify the starting angle of the sunburst chart. Default is 0.
  • series.dataLabels.format: String used to specify the display format of data labels. Supports placeholders, such as {point.node.name} represents the node name.
  • series.levels: used to define styles at different levels. You can set the color, expansion radius, etc. of different levels.

For more details on attribute and style adjustment, please refer to the official documentation of Highcharts.

4. Summary

This article introduces how to use sunburst charts to display data in Highcharts, and provides code examples. The sunburst chart is a visual chart suitable for displaying hierarchical relationships and proportional relationships, and can be used for data analysis and presentation. By setting the appropriate data format and adjusting related properties, we can create various styles of sunburst charts to meet different needs. I hope this article will be helpful to you when creating a sunburst chart using Highcharts.

The above is the detailed content of How to use sunburst chart to display data in Highcharts. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use Sankey chart to display data in Highcharts How to use Sankey chart to display data in Highcharts Dec 17, 2023 pm 04:41 PM

How to use Sankey diagram to display data in Highcharts Sankey diagram (SankeyDiagram) is a chart type used to visualize complex processes such as flow, energy, and funds. It can clearly display the relationship and flow between various nodes, and can help us better understand and analyze data. In this article, we will introduce how to use Highcharts to create and customize a Sankey chart, with specific code examples. First, we need to load the Highcharts library and Sank

How to use dynamic data in Highcharts to display real-time data How to use dynamic data in Highcharts to display real-time data Dec 17, 2023 pm 06:57 PM

How to use dynamic data in Highcharts to display real-time data. With the advent of the big data era, the display of real-time data has become more and more important. Highcharts, as a popular charting library, provides rich functions and customizability, allowing us to flexibly display real-time data. This article will introduce how to use dynamic data in Highcharts to display real-time data, and give specific code examples. First, we need to prepare a data source that can provide real-time data. In this article, I

How to create a Gantt chart using Highcharts How to create a Gantt chart using Highcharts Dec 17, 2023 pm 07:23 PM

How to use Highcharts to create a Gantt chart requires specific code examples. Introduction: The Gantt chart is a chart form commonly used to display project progress and time management. It can visually display the start time, end time and progress of the task. Highcharts is a powerful JavaScript chart library that provides rich chart types and flexible configuration options. This article will introduce how to use Highcharts to create a Gantt chart and give specific code examples. 1. Highchart

How to use stacked charts to display data in Highcharts How to use stacked charts to display data in Highcharts Dec 18, 2023 pm 05:56 PM

How to use stacked charts to display data in Highcharts Stacked charts are a common way of visualizing data, which can display the sum of multiple data series at the same time and display the contribution of each data series in the form of a bar chart. Highcharts is a powerful JavaScript library that provides a rich variety of charts and flexible configuration options to meet various data visualization needs. In this article, we will introduce how to use Highcharts to create a stacked chart and provide

How to create a map heat map using Highcharts How to create a map heat map using Highcharts Dec 17, 2023 pm 04:06 PM

How to use Highcharts to create a map heat map requires specific code examples. A heat map is a visual data display method that can represent the data distribution in each area through different color shades. In the field of data visualization, Highcharts is a very popular JavaScript library that provides rich chart types and interactive functions. This article will introduce how to use Highcharts to create a map heat map and provide specific code examples. First, we need to prepare some data

How to use histogram to display data in ECharts How to use histogram to display data in ECharts Dec 18, 2023 pm 02:21 PM

How to use histograms to display data in ECharts ECharts is a JavaScript-based data visualization library that is very popular and widely used in the field of data visualization. Among them, the histogram is the most common and commonly used chart type, which can be used to display the size, comparison and trend analysis of various numerical data. This article will introduce how to use ECharts to draw histograms and provide code examples. First, we need to introduce the ECharts library into the HTML file, which can be introduced in the following way

How to use Vue to implement statistical charts for large-screen data display How to use Vue to implement statistical charts for large-screen data display Aug 17, 2023 am 09:54 AM

How to use Vue to implement statistical charts for large-screen data display. In the modern information society, data statistics and visualization have become important means of decision-making and analysis. In order to display data more intuitively, we often use statistical charts. Under the Vue framework, you can easily achieve large-screen data display needs by using some excellent chart libraries. This article will introduce how to use Vue combined with two mainstream statistical chart libraries, echarts and chart.js, to display data. First, we need to install echarts and c for the Vue project

How to use scatter plots to display data in Highcharts How to use scatter plots to display data in Highcharts Dec 17, 2023 pm 10:30 PM

How to use scatter plots to display data in Highcharts Preface Highcharts is an open source JavaScript chart library that provides a variety of chart types and powerful customization functions. Among them, scatter plot is a commonly used data visualization method that can show the relationship between two variables and the distribution of variables. This article will introduce how to use scatter plots to display data in Highcharts and provide specific code examples. Step 1: Introduce the Highcharts library

See all articles