473,398 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Mean stack angular 2.bind api data to high chart in typescript.

i want to binde api data so it can render highchart according to data in angular 2 and typescript.


Expand|Select|Wrap|Line Numbers
  1. export class DashboardComponent implements OnInit {
  2. //api having some data
  3. phones =  this.http.get('http://localhost:7788/countphones').map(res => res.json())
  4. laptops =  this.http.get('http://localhost:7788/countlaptops').map(res => res.json())
  5. televisions =  this.http.get('http://localhost:7788/counttelevisions').map(res => res.json())
  6.   constructor(private http:Http) { }
  7.  
  8.   ngOnInit() {
  9. Observable
  10.     .forkJoin(this.phones, this.laptops, this.televisions)
  11.     .subscribe(([phones, laptops, televisions])=>{
  12.         this.phones = phones;   //some data 
  13.         this.laptops = laptops; //some data
  14.         this.televisions = televisions; //some data
  15.  
  16.   }); 
  17.   }
  18.   chart = new Chart({
  19.       chart: {type: 'bar'},
  20.       title: {text: 'Product Charts'},
  21.       xAxis :{
  22.      categories: ['Televisions', 'phones', 'Laptops'],
  23.                 title: {  text: 'Product Names',},
  24.             },
  25.       yAxis : {
  26.                title: {text: 'Product (Quantity)',},
  27.             },
  28.       credits: {enabled: false},
  29.       series: [{
  30.         name: 'Line 1',
  31.         data: [['TELEVISIONS',//bind here api data], ['PHONES',//bind here api data ], ['LAPTOPS',//bind data here ]]
  32.       }]
  33.     });

more explanation in image
Attached Images
File Type: jpg Screenshot (2).jpg (46.9 KB, 139 views)
Feb 26 '18 #1
0 1449

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Vijaya | last post by:
Can we bind data to textbox in a headertemplate in a template column of a datagrid? If so please give some code snippets. Thank you
0
by: Kobe | last post by:
I am trying to bind data in a collection to a combo box in a windows application. I am able to retrieve records from the collection but when I bind it to the combo box, nothing is displayed ...
2
by: Santosh | last post by:
Dear all i want to bind data to datagrid header template i am wrtting follwing code it is displaying data with in item template not but it is display data in header template <asp:DataGrid...
3
by: vineetbatta | last post by:
I have Custom Data class which stores data about single customer and then i store that customer objects in arraylist as shown below. Customer custdata = null; // Custom Data class for 1 customer...
2
by: chandana Devabhaktuni | last post by:
Hello and Hi to everyone, This is chandana, i have a doubt which i am mentioning here. We can retrive or bind data to datagrid from database(sql server) and also we can...
5
by: Ahmed Osama | last post by:
I'm using NetBeans 5.5 First :I want to bind data from table from MS Access DB into JTable . Second: Is there any other component in java to do the previous action(e.g. DataGrid )
3
by: sudhashekhar30 | last post by:
i have dropdownlist with data. based on selected item(dropdownlist) i am retrieving data(single value) from database(sql server) using sqldataadapter and wanted to show this value in textbox. I want...
1
by: newtodotnet1 | last post by:
Hi all, I would like to know how to bind data to the gridview using XPath.. The data is in the XML format.. Please help me.... Its urgent.. I am using asp.net and c#.net
1
by: jaredciagar | last post by:
Hi guys...can you help me please.... I'm using ASP.net, MSSQL 2005 and VB Script I have don't know how to bind data in gridview control from database. I want also to allow paging in gridview...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.