{"id":16687390,"url":"https://github.com/rodrigokamada/angular-highcharts","last_synced_at":"2025-05-15T04:34:57.149Z","repository":{"id":44470190,"uuid":"404165482","full_name":"rodrigokamada/angular-highcharts","owner":"rodrigokamada","description":"Application example built with Angular 15 and adding charts using the highcharts library.","archived":false,"fork":false,"pushed_at":"2023-04-03T12:31:43.000Z","size":8368,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-11T07:11:17.748Z","etag":null,"topics":["angular","beginners","charts","dev-community","gh-actions","gh-pages","hacktoberfest","highcharts","stackblitz","tutorial"],"latest_commit_sha":null,"homepage":"https://rodrigokamada.github.io/angular-highcharts/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rodrigokamada.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"rodrigokamada"}},"created_at":"2021-09-08T00:53:15.000Z","updated_at":"2023-11-12T20:16:31.000Z","dependencies_parsed_at":"2024-11-19T09:48:34.361Z","dependency_job_id":"979cec35-7e1b-46ce-82d9-8cb22f121e8f","html_url":"https://github.com/rodrigokamada/angular-highcharts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigokamada%2Fangular-highcharts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigokamada%2Fangular-highcharts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigokamada%2Fangular-highcharts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigokamada%2Fangular-highcharts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rodrigokamada","download_url":"https://codeload.github.com/rodrigokamada/angular-highcharts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254274737,"owners_count":22043575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","beginners","charts","dev-community","gh-actions","gh-pages","hacktoberfest","highcharts","stackblitz","tutorial"],"created_at":"2024-10-12T15:09:00.439Z","updated_at":"2025-05-15T04:34:56.784Z","avatar_url":"https://github.com/rodrigokamada.png","language":"TypeScript","readme":"# Angular Highcharts\n\n\nApplication example built with [Angular](https://angular.io/) 15 and adding the charts using the [highcharts](https://www.npmjs.com/package/highcharts) library.\n\nThis tutorial was posted on my [blog](https://rodrigo.kamada.com.br/blog/adicionando-graficos-usando-a-biblioteca-highcharts-em-uma-aplicacao-angular) in portuguese and on the [DEV Community](https://dev.to/rodrigokamada/adding-charts-using-the-highcharts-library-to-an-angular-application-2bbl) in english.\n\n\n\n[![Website](https://shields.braskam.com/v1/shields?name=website\u0026format=rectangle\u0026size=small\u0026radius=5)](https://rodrigo.kamada.com.br)\n[![LinkedIn](https://shields.braskam.com/v1/shields?name=linkedin\u0026format=rectangle\u0026size=small\u0026radius=5)](https://www.linkedin.com/in/rodrigokamada)\n[![Twitter](https://shields.braskam.com/v1/shields?name=twitter\u0026format=rectangle\u0026size=small\u0026radius=5\u0026socialAccount=rodrigokamada)](https://twitter.com/rodrigokamada)\n[![Instagram](https://shields.braskam.com/v1/shields?name=instagram\u0026format=rectangle\u0026size=small\u0026radius=5)](https://www.instagram.com/rodrigokamada)\n\n\n\n## Prerequisites\n\n\nBefore you start, you need to install and configure the tools:\n\n* [git](https://git-scm.com/)\n* [Node.js and npm](https://nodejs.org/)\n* [Angular CLI](https://angular.io/cli)\n* IDE (e.g. [Visual Studio Code](https://code.visualstudio.com/))\n\n\n\n## Getting started\n\n\n### Create the Angular application\n\n\n**1.** Let's create the application with the Angular base structure using the `@angular/cli` with the route file and the SCSS style format.\n\n```shell\nng new angular-highcharts\n? Would you like to add Angular routing? Yes\n? Which stylesheet format would you like to use? SCSS   [ https://sass-lang.com/documentation/syntax#scss                ]\nCREATE angular-highcharts/README.md (1063 bytes)\nCREATE angular-highcharts/.editorconfig (274 bytes)\nCREATE angular-highcharts/.gitignore (604 bytes)\nCREATE angular-highcharts/angular.json (3279 bytes)\nCREATE angular-highcharts/package.json (1080 bytes)\nCREATE angular-highcharts/tsconfig.json (783 bytes)\nCREATE angular-highcharts/.browserslistrc (703 bytes)\nCREATE angular-highcharts/karma.conf.js (1435 bytes)\nCREATE angular-highcharts/tsconfig.app.json (287 bytes)\nCREATE angular-highcharts/tsconfig.spec.json (333 bytes)\nCREATE angular-highcharts/src/favicon.ico (948 bytes)\nCREATE angular-highcharts/src/index.html (303 bytes)\nCREATE angular-highcharts/src/main.ts (372 bytes)\nCREATE angular-highcharts/src/polyfills.ts (2820 bytes)\nCREATE angular-highcharts/src/styles.scss (80 bytes)\nCREATE angular-highcharts/src/test.ts (788 bytes)\nCREATE angular-highcharts/src/assets/.gitkeep (0 bytes)\nCREATE angular-highcharts/src/environments/environment.prod.ts (51 bytes)\nCREATE angular-highcharts/src/environments/environment.ts (658 bytes)\nCREATE angular-highcharts/src/app/app-routing.module.ts (245 bytes)\nCREATE angular-highcharts/src/app/app.module.ts (393 bytes)\nCREATE angular-highcharts/src/app/app.component.scss (0 bytes)\nCREATE angular-highcharts/src/app/app.component.html (24617 bytes)\nCREATE angular-highcharts/src/app/app.component.spec.ts (1109 bytes)\nCREATE angular-highcharts/src/app/app.component.ts (223 bytes)\n✔ Packages installed successfully.\n```\n\n**2.** Install and configure the Bootstrap CSS framework. Do steps 2 and 3 of the post *[Adding the Bootstrap CSS framework to an Angular application](https://github.com/rodrigokamada/angular-bootstrap)*.\n\n**3.** Install the `highcharts` library.\n\n```shell\nnpm install highcharts\n```\n\n**4.** Remove the contents of the `AppComponent` class from the `src/app/app.component.ts` file. Import the `Highcharts`, `HighchartsMore` and `HighchartsSolidGauge` services and create the `createChartGauge`, `createChartPie`, `createChartColumn` and `createChartLine` methods as below.\n\n```typescript\nimport { AfterViewInit, Component } from '@angular/core';\nimport * as Highcharts from 'highcharts';\nimport HighchartsMore from 'highcharts/highcharts-more';\nimport HighchartsSolidGauge from 'highcharts/modules/solid-gauge';\n\nHighchartsMore(Highcharts);\nHighchartsSolidGauge(Highcharts);\n\n@Component({\n  selector: 'app-root',\n  templateUrl: './app.component.html',\n  styleUrls: ['./app.component.scss'],\n})\nexport class AppComponent implements AfterViewInit {\n\n  public ngAfterViewInit(): void {\n    this.createChartGauge();\n    this.createChartPie();\n    this.createChartColumn();\n    this.createChartLine();\n  }\n\n  private getRandomNumber(min: number, max: number): number {\n    return Math.floor(Math.random() * (max - min + 1) + min)\n  }\n\n  private createChartGauge(): void {\n    const chart = Highcharts.chart('chart-gauge', {\n      chart: {\n        type: 'solidgauge',\n      },\n      title: {\n        text: 'Gauge Chart',\n      },\n      credits: {\n        enabled: false,\n      },\n      pane: {\n        startAngle: -90,\n        endAngle: 90,\n        center: ['50%', '85%'],\n        size: '160%',\n        background: {\n            innerRadius: '60%',\n            outerRadius: '100%',\n            shape: 'arc',\n        },\n      },\n      yAxis: {\n        min: 0,\n        max: 100,\n        stops: [\n          [0.1, '#55BF3B'], // green\n          [0.5, '#DDDF0D'], // yellow\n          [0.9, '#DF5353'], // red\n        ],\n        minorTickInterval: null,\n        tickAmount: 2,\n        labels: {\n          y: 16,\n        },\n      },\n      plotOptions: {\n        solidgauge: {\n          dataLabels: {\n            y: -25,\n            borderWidth: 0,\n            useHTML: true,\n          },\n        },\n      },\n      tooltip: {\n        enabled: false,\n      },\n      series: [{\n        name: null,\n        data: [this.getRandomNumber(0, 100)],\n        dataLabels: {\n          format: '\u003cdiv style=\"text-align: center\"\u003e\u003cspan style=\"font-size: 1.25rem\"\u003e{y}\u003c/span\u003e\u003c/div\u003e',\n        },\n      }],\n    } as any);\n\n    setInterval(() =\u003e {\n      chart.series[0].points[0].update(this.getRandomNumber(0, 100));\n    }, 1000);\n  }\n\n  private createChartPie(): void {\n    let date = new Date();\n    const data: any[] = [];\n\n    for (let i = 0; i \u003c 5; i++) {\n      date.setDate(new Date().getDate() + i);\n      data.push({\n        name: `${date.getDate()}/${date.getMonth() + 1}`,\n        y: this.getRandomNumber(0, 1000),\n      });\n    }\n\n    const chart = Highcharts.chart('chart-pie', {\n      chart: {\n        type: 'pie',\n      },\n      title: {\n        text: 'Pie Chart',\n      },\n      credits: {\n        enabled: false,\n      },\n      tooltip: {\n        headerFormat: `\u003cspan class=\"mb-2\"\u003eDate: {point.key}\u003c/span\u003e\u003cbr\u003e`,\n        pointFormat: '\u003cspan\u003eAmount: {point.y}\u003c/span\u003e',\n        useHTML: true,\n      },\n      series: [{\n        name: null,\n        innerSize: '50%',\n        data,\n      }],\n    } as any);\n\n    setInterval(() =\u003e {\n      date.setDate(date.getDate() + 1);\n      chart.series[0].addPoint({\n        name: `${date.getDate()}/${date.getMonth() + 1}`,\n        y: this.getRandomNumber(0, 1000),\n      }, true, true);\n    }, 1500);\n  }\n\n  private createChartColumn(): void {\n    let date = new Date();\n    const data: any[] = [];\n\n    for (let i = 0; i \u003c 10; i++) {\n      date.setDate(new Date().getDate() + i);\n      data.push({\n        name: `${date.getDate()}/${date.getMonth() + 1}`,\n        y: this.getRandomNumber(0, 1000),\n      });\n    }\n\n    const chart = Highcharts.chart('chart-column' as any, {\n      chart: {\n        type: 'column',\n      },\n      title: {\n        text: 'Column Chart',\n      },\n      credits: {\n        enabled: false,\n      },\n      legend: {\n        enabled: false,\n      },\n      yAxis: {\n        min: 0,\n        title: undefined,\n      },\n      xAxis: {\n        type: 'category',\n      },\n      tooltip: {\n        headerFormat: `\u003cdiv\u003eDate: {point.key}\u003c/div\u003e`,\n        pointFormat: `\u003cdiv\u003e{series.name}: {point.y}\u003c/div\u003e`,\n        shared: true,\n        useHTML: true,\n      },\n      plotOptions: {\n        bar: {\n          dataLabels: {\n            enabled: true,\n          },\n        },\n      },\n      series: [{\n        name: 'Amount',\n        data,\n      }],\n    } as any);\n\n    setInterval(() =\u003e {\n      date.setDate(date.getDate() + 1);\n      chart.series[0].addPoint({\n        name: `${date.getDate()}/${date.getMonth() + 1}`,\n        y: this.getRandomNumber(0, 1000),\n      }, true, true);\n    }, 1500);\n  }\n\n  private createChartLine(): void {\n    let date = new Date();\n    const data: any[] = [];\n\n    for (let i = 0; i \u003c 10; i++) {\n      date.setDate(new Date().getDate() + i);\n      data.push([`${date.getDate()}/${date.getMonth() + 1}`, this.getRandomNumber(0, 1000)]);\n    }\n\n    const chart = Highcharts.chart('chart-line', {\n      chart: {\n        type: 'line',\n      },\n      title: {\n        text: 'Line Chart',\n      },\n      credits: {\n        enabled: false,\n      },\n      legend: {\n        enabled: false,\n      },\n      yAxis: {\n        title: {\n          text: null,\n        }\n      },\n      xAxis: {\n        type: 'category',\n      },\n      tooltip: {\n        headerFormat: `\u003cdiv\u003eDate: {point.key}\u003c/div\u003e`,\n        pointFormat: `\u003cdiv\u003e{series.name}: {point.y}\u003c/div\u003e`,\n        shared: true,\n        useHTML: true,\n      },\n      series: [{\n        name: 'Amount',\n        data,\n      }],\n    } as any);\n\n    setInterval(() =\u003e {\n      date.setDate(date.getDate() + 1);\n      chart.series[0].addPoint([`${date.getDate()}/${date.getMonth() + 1}`, this.getRandomNumber(0, 1000)], true, true);\n    }, 1500);\n  }\n\n}\n```\n\n**5.** Remove the contents of the `src/app/app.component.html` file. Add the `div` tags for each chart as below.\n\n```html\n\u003cdiv class=\"container-fluid py-3\"\u003e\n  \u003ch1\u003eAngular Highcharts\u003c/h1\u003e\n\n  \u003cdiv class=\"row mt-5\"\u003e\n    \u003cdiv class=\"col-6\"\u003e\n      \u003cdiv id=\"chart-gauge\"\u003e\u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"col-6\"\u003e\n      \u003cdiv id=\"chart-pie\"\u003e\u003c/div\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n  \u003cdiv class=\"row mt-5\"\u003e\n    \u003cdiv class=\"col-6\"\u003e\n      \u003cdiv id=\"chart-column\"\u003e\u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"col-6\"\u003e\n      \u003cdiv id=\"chart-line\"\u003e\u003c/div\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\n**6.** Add the style in the `src/app/app.component.scss` file as below.\n\n```css\n#chart-gauge, #chart-pie, #chart-column, #chart-line {\n  display: block;\n  min-width: 150px;\n  max-width: 400px;\n  height: 200px;\n  margin: 0 auto;\n}\n```\n\n**7.** Run the application with the command below.\n\n```shell\nnpm start\n\n\u003e angular-highcharts@1.0.0 start\n\u003e ng serve\n\n✔ Browser application bundle generation complete.\n\nInitial Chunk Files | Names         |      Size\nvendor.js           | vendor        |   2.79 MB\nstyles.css          | styles        | 266.63 kB\npolyfills.js        | polyfills     | 128.52 kB\nscripts.js          | scripts       |  77.06 kB\nmain.js             | main          |  18.40 kB\nruntime.js          | runtime       |   6.64 kB\n\n                    | Initial Total |   3.28 MB\n\nBuild at: 2021-09-09T01:25:33.291Z - Hash: 2495029c373d88bd55c1 - Time: 27953ms\n\n** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **\n\n\n✔ Compiled successfully.\n```\n\n**8.** Ready! Access the URL `http://localhost:4200/` and check if the application is working. See the application working on [GitHub Pages](https://rodrigokamada.github.io/angular-highcharts/) and [Stackblitz](https://stackblitz.com/edit/angular15-highcharts).\n\n![Angular Highcharts](https://res.cloudinary.com/rodrigokamada/image/upload/v1638101045/Blog/angular-highcharts/angular-highcharts.gif)\n\n\n\n## Cloning the application\n\n**1.** Clone the repository.\n\n```shell\ngit clone git@github.com:rodrigokamada/angular-highcharts.git\n```\n\n**2.** Install the dependencies.\n\n```shell\nnpm ci\n```\n\n**3.** Run the application.\n\n```shell\nnpm start\n```","funding_links":["https://github.com/sponsors/rodrigokamada"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigokamada%2Fangular-highcharts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodrigokamada%2Fangular-highcharts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigokamada%2Fangular-highcharts/lists"}