How to add a third set of data in a Highcharts bar graph











up vote
0
down vote

favorite












I'm making an angular web app, and I'm trying to render a bar graph with 3 different sets. I want to show 2 of the sets on the x-axis and y-axis, and the third one when you hover over each



According to the documentation, that seems to be the tooltip.



The documentation shows how to change each one manually, but I'm calling an API for data, so the tooltip has to be somewhat dynamic and not static.



Angular Component



import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'
import { BuyerService, BuyerDetail } from '../buyer.service';
import { HttpResponse } from '@angular/common/http';

declare const Highcharts: any;

@Component({
selector: 'app-buyer-details',
templateUrl: './buyer-details.component.html',
styleUrls: ['./buyer-details.component.css']
})
export class DrinkerDetailsComponent implements OnInit {

buyerName: string;
buyerDetails: BuyerDetail;

constructor(
public buyerService: BuyerService,
private route: ActivatedRoute
) {
route.paramMap.subscribe((paramMap) => {
this.buyerName = paramMap.get('buyer');
this.buyerService.getBuyerSpendingDistribution(this.buyerName).subscribe(
data => {
const cars = ;
const years = ;
const counts = ;

data.forEach(buyer => {
cars.push(buyer.car_name);
years.push(buyer.year)
counts.push(buyer.total_per_year);
});

this.renderChart2(cars, years, counts);
}
);
});

}

renderChart2(cars: string, years: string, counts: string){
Highcharts.chart('bargraph2', {
chart: {
type: 'column'
},
title: {
text: 'Distribution of Amount Spent By Drinker By Bar'
},
xAxis: {
categories: years,
title: {
text: 'Year'
}
},
yAxis: {
min: 0,
title: {
text: 'Dollars Spent'
}
},
labels: {
overflow: 'justify'
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
legend: {
enabled: false
},
credits: {
enabled: false
},
series: [{
data: counts,
}],
tooltip: {
formatter: function() {
// not sure what to put here.
}
}
})
}

}


How do I make it so the cars is the tooltip, where each car shows over it's correct bar on the bar graph?










share|improve this question






















  • Could you please prepare a simplified online example of your app with sample data presenting this issue (codesandbox for example)? Are you using highcharts official wrapper for Angular: github.com/highcharts/highcharts-angular?
    – Wojciech Chmiel
    Nov 19 at 10:59















up vote
0
down vote

favorite












I'm making an angular web app, and I'm trying to render a bar graph with 3 different sets. I want to show 2 of the sets on the x-axis and y-axis, and the third one when you hover over each



According to the documentation, that seems to be the tooltip.



The documentation shows how to change each one manually, but I'm calling an API for data, so the tooltip has to be somewhat dynamic and not static.



Angular Component



import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'
import { BuyerService, BuyerDetail } from '../buyer.service';
import { HttpResponse } from '@angular/common/http';

declare const Highcharts: any;

@Component({
selector: 'app-buyer-details',
templateUrl: './buyer-details.component.html',
styleUrls: ['./buyer-details.component.css']
})
export class DrinkerDetailsComponent implements OnInit {

buyerName: string;
buyerDetails: BuyerDetail;

constructor(
public buyerService: BuyerService,
private route: ActivatedRoute
) {
route.paramMap.subscribe((paramMap) => {
this.buyerName = paramMap.get('buyer');
this.buyerService.getBuyerSpendingDistribution(this.buyerName).subscribe(
data => {
const cars = ;
const years = ;
const counts = ;

data.forEach(buyer => {
cars.push(buyer.car_name);
years.push(buyer.year)
counts.push(buyer.total_per_year);
});

this.renderChart2(cars, years, counts);
}
);
});

}

renderChart2(cars: string, years: string, counts: string){
Highcharts.chart('bargraph2', {
chart: {
type: 'column'
},
title: {
text: 'Distribution of Amount Spent By Drinker By Bar'
},
xAxis: {
categories: years,
title: {
text: 'Year'
}
},
yAxis: {
min: 0,
title: {
text: 'Dollars Spent'
}
},
labels: {
overflow: 'justify'
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
legend: {
enabled: false
},
credits: {
enabled: false
},
series: [{
data: counts,
}],
tooltip: {
formatter: function() {
// not sure what to put here.
}
}
})
}

}


How do I make it so the cars is the tooltip, where each car shows over it's correct bar on the bar graph?










share|improve this question






















  • Could you please prepare a simplified online example of your app with sample data presenting this issue (codesandbox for example)? Are you using highcharts official wrapper for Angular: github.com/highcharts/highcharts-angular?
    – Wojciech Chmiel
    Nov 19 at 10:59













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm making an angular web app, and I'm trying to render a bar graph with 3 different sets. I want to show 2 of the sets on the x-axis and y-axis, and the third one when you hover over each



According to the documentation, that seems to be the tooltip.



The documentation shows how to change each one manually, but I'm calling an API for data, so the tooltip has to be somewhat dynamic and not static.



Angular Component



import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'
import { BuyerService, BuyerDetail } from '../buyer.service';
import { HttpResponse } from '@angular/common/http';

declare const Highcharts: any;

@Component({
selector: 'app-buyer-details',
templateUrl: './buyer-details.component.html',
styleUrls: ['./buyer-details.component.css']
})
export class DrinkerDetailsComponent implements OnInit {

buyerName: string;
buyerDetails: BuyerDetail;

constructor(
public buyerService: BuyerService,
private route: ActivatedRoute
) {
route.paramMap.subscribe((paramMap) => {
this.buyerName = paramMap.get('buyer');
this.buyerService.getBuyerSpendingDistribution(this.buyerName).subscribe(
data => {
const cars = ;
const years = ;
const counts = ;

data.forEach(buyer => {
cars.push(buyer.car_name);
years.push(buyer.year)
counts.push(buyer.total_per_year);
});

this.renderChart2(cars, years, counts);
}
);
});

}

renderChart2(cars: string, years: string, counts: string){
Highcharts.chart('bargraph2', {
chart: {
type: 'column'
},
title: {
text: 'Distribution of Amount Spent By Drinker By Bar'
},
xAxis: {
categories: years,
title: {
text: 'Year'
}
},
yAxis: {
min: 0,
title: {
text: 'Dollars Spent'
}
},
labels: {
overflow: 'justify'
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
legend: {
enabled: false
},
credits: {
enabled: false
},
series: [{
data: counts,
}],
tooltip: {
formatter: function() {
// not sure what to put here.
}
}
})
}

}


How do I make it so the cars is the tooltip, where each car shows over it's correct bar on the bar graph?










share|improve this question













I'm making an angular web app, and I'm trying to render a bar graph with 3 different sets. I want to show 2 of the sets on the x-axis and y-axis, and the third one when you hover over each



According to the documentation, that seems to be the tooltip.



The documentation shows how to change each one manually, but I'm calling an API for data, so the tooltip has to be somewhat dynamic and not static.



Angular Component



import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'
import { BuyerService, BuyerDetail } from '../buyer.service';
import { HttpResponse } from '@angular/common/http';

declare const Highcharts: any;

@Component({
selector: 'app-buyer-details',
templateUrl: './buyer-details.component.html',
styleUrls: ['./buyer-details.component.css']
})
export class DrinkerDetailsComponent implements OnInit {

buyerName: string;
buyerDetails: BuyerDetail;

constructor(
public buyerService: BuyerService,
private route: ActivatedRoute
) {
route.paramMap.subscribe((paramMap) => {
this.buyerName = paramMap.get('buyer');
this.buyerService.getBuyerSpendingDistribution(this.buyerName).subscribe(
data => {
const cars = ;
const years = ;
const counts = ;

data.forEach(buyer => {
cars.push(buyer.car_name);
years.push(buyer.year)
counts.push(buyer.total_per_year);
});

this.renderChart2(cars, years, counts);
}
);
});

}

renderChart2(cars: string, years: string, counts: string){
Highcharts.chart('bargraph2', {
chart: {
type: 'column'
},
title: {
text: 'Distribution of Amount Spent By Drinker By Bar'
},
xAxis: {
categories: years,
title: {
text: 'Year'
}
},
yAxis: {
min: 0,
title: {
text: 'Dollars Spent'
}
},
labels: {
overflow: 'justify'
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
legend: {
enabled: false
},
credits: {
enabled: false
},
series: [{
data: counts,
}],
tooltip: {
formatter: function() {
// not sure what to put here.
}
}
})
}

}


How do I make it so the cars is the tooltip, where each car shows over it's correct bar on the bar graph?







javascript jquery angular highcharts






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 18 at 16:52









James Mitchell

74031331




74031331












  • Could you please prepare a simplified online example of your app with sample data presenting this issue (codesandbox for example)? Are you using highcharts official wrapper for Angular: github.com/highcharts/highcharts-angular?
    – Wojciech Chmiel
    Nov 19 at 10:59


















  • Could you please prepare a simplified online example of your app with sample data presenting this issue (codesandbox for example)? Are you using highcharts official wrapper for Angular: github.com/highcharts/highcharts-angular?
    – Wojciech Chmiel
    Nov 19 at 10:59
















Could you please prepare a simplified online example of your app with sample data presenting this issue (codesandbox for example)? Are you using highcharts official wrapper for Angular: github.com/highcharts/highcharts-angular?
– Wojciech Chmiel
Nov 19 at 10:59




Could you please prepare a simplified online example of your app with sample data presenting this issue (codesandbox for example)? Are you using highcharts official wrapper for Angular: github.com/highcharts/highcharts-angular?
– Wojciech Chmiel
Nov 19 at 10:59

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53363278%2fhow-to-add-a-third-set-of-data-in-a-highcharts-bar-graph%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53363278%2fhow-to-add-a-third-set-of-data-in-a-highcharts-bar-graph%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]