Home Web Front-end JS Tutorial How to use 3D charts to display data in Highcharts

How to use 3D charts to display data in Highcharts

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

How to use 3D charts to display data in Highcharts

Highcharts is a very popular JavaScript charting library that provides many different types of charts, including 3D charts. This article will introduce in detail how to use 3D charts to display data in Highcharts, and provide specific code examples.

  1. Introducing the Highcharts library

First, we need to introduce the Highcharts library into the HTML file. This can be achieved in the following ways:

<script src="https://code.highcharts.com/highcharts.js"></script>
Copy after login
  1. Preparing data

We need to prepare some data to display in the 3D chart. This data is usually a JavaScript object consisting of an array. For example:

var data = {
   categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
   series: [{
       name: 'Tokyo',
       data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
   }, {
       name: 'New York',
       data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
   }, {
       name: 'Berlin',
       data: [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
   }, {
       name: 'London',
       data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
   }]
};
Copy after login

This object contains 4 different data series. Each series includes a name and an array. Each element in the array represents a data point.

  1. Create a 3D chart

Next, we can create a 3D chart. First, we need to decide what type of chart we want to create. Highcharts provides several different types of 3D charts, including 3D column charts, 3D scatter charts, 3D cylindrical charts, and 3D maps. In this article, we will create a 3D column chart with the following code:

Highcharts.chart('container', {
    chart: {
        type: 'column',
        options3d: {
            enabled: true,
            alpha: 15,
            beta: 15,
            depth: 50,
            viewDistance: 25
        }
    },
    title: {
        text: 'Monthly Average Temperature'
    },
    subtitle: {
        text: 'Source: WorldClimate.com'
    },
    xAxis: {
        categories: data.categories
    },
    yAxis: {
        title: {
            text: 'Temperature (°C)'
        }
    },
    plotOptions: {
        column: {
            depth: 25
        }
    },
    series: data.series
});
Copy after login

First, we define a div named "container" in the HTML document, which will contain the chart we created.

Then, we use the Highcharts.chart() method to create the chart. In the chart options, we set the type to "column", which means we will create a column chart. We also set the options3d option, enable 3D functionality, and set some 3D parameters such as alpha and beta angles, depth, and more.

We also define some title and axis options, as well as the column option in plotOptions, which is used to set the depth of the column chart.

Finally, we specify the data series and use the previously defined data object to set the name and data of each series.

  1. Running the Code

Now that we have our code ready, we can run it in the browser. When we load the HTML file and view the graph, we will see a 3D column chart that will show the average temperature for each month using the data we defined earlier.

Code examples can be viewed in the following code repository:

https://github.com/Jackie199199/Highcharts-3D-Demo

Summary

Highcharts is a very powerful JavaScript charting library that provides a wide variety of chart types and functions, including 3D charts. In this article, we explain how to create 3D charts in Highcharts and provide concrete code examples. If you want to add high-quality, interactive data visualization to your web page or application, Highcharts may be one of your best options.

The above is the detailed content of How to use 3D charts 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 use Vue to achieve 3D stereoscopic rotation effects How to use Vue to achieve 3D stereoscopic rotation effects Sep 19, 2023 am 08:42 AM

How to use Vue to achieve 3D three-dimensional rotation effects As a popular front-end framework, Vue.js plays an important role in developing dynamic web pages and applications. It provides an intuitive, efficient way to build interactive interfaces and is easy to integrate and extend. This article will introduce how to use Vue.js to implement a stunning 3D stereoscopic rotation effect, and provide specific code examples. Before you start, make sure you have Vue.js installed and have some understanding of the basic usage of Vue.js. If you still

How to draw a 3D geographic chart with Python How to draw a 3D geographic chart with Python Sep 28, 2023 am 10:19 AM

Overview of how to draw 3D geographic charts with Python: Drawing 3D geographic charts can help us understand geographic data and spatial distribution more intuitively. Python, as a powerful and easy-to-use programming language, provides many libraries and tools for drawing various types of geographical charts. In this article, we will learn how to draw 3D geographic charts using the Python programming language and some popular libraries such as Matplotlib and Basemap. Environment preparation: Before starting, we need to make sure

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

See all articles