Highcharts map chart not drawing bubble on calling setData - highcharts
This my map configuration
chart = Highcharts.mapChart('container', {
title: {
text: ''
},
//This enables the zooming functionality
mapNavigation: {
enabled: true
},
credits: {
enabled: false
},
tooltip: {
pointFormat:
'Server Name : {point.source_host}<br>' +
'{point.Hover}<br>' +
'{point.trueVUEStatus}'
},
xAxis: {
crosshair: {
zIndex: 5,
dashStyle: 'dot',
snap: false,
color: 'gray'
}
},
yAxis: {
crosshair: {
zIndex: 5,
dashStyle: 'dot',
snap: false,
color: 'gray'
}
},
plotOptions: {
series: {
//allowPointSelect: true,
point: {
events: {
click: function (event) {
//location.href = '?' + event.point.serverName + '#serverdetailsview';
//alert('clicked '+ event.point.source_host);
window.open('index.html?' + event.point.source_host + "#serverdetailsview&store-no=" + event.point.storeNum, '_blank');
//http://localhost:10080/dashboard/index.html?ME629ASRFI21#serverdetailsview
}
}
}
}
},
series: [{
name: 'Basemap',
mapData: map,
borderColor: '#606060',
nullColor: 'rgba(200, 200, 200, 0.2)',
showInLegend: false
}, {
name: 'Separators',
type: 'mapline',
data: H.geojson(map, 'mapline'),
color: '#101010',
enableMouseTracking: false,
showInLegend: false
}, {
showInLegend: false,
type: 'mapbubble',
dataLabels: {
enabled: true,
format: '{point.storeNum}',
style:{color:"white"}
},
name: 'Cities1',
data: normaljson,
minsize: '1%',
maxSize: '4%',
color: '#00a65a'
},{
showInLegend: false,
type: 'mapbubble',
dataLabels: {
enabled: true,
format: '{point.storeNum}',
style:{color:"white"}
},
name: 'Cities2',
data: warnjson,
minsize: '1%',
maxSize: '4%',
color: '#f39c12'
},
{
showInLegend: false,
type: 'mapbubble',
dataLabels: {
enabled: true,
format: '{point.storeNum}',
style:{color:"white"}
},
name: 'Cities3',
data: errorjson,
minsize: '1%',
maxSize: '4%',
color: '#dd4b39'
}]
});
Just after this I am calling setData()
However, the bubble is not drawn on map
var pt = {"source_host":"xcxxxx","lat":26.3685,"lon":-80.1344,"serverIP":"NA","store":"Bloomingdales","storeNum":"2","status":"green"};
chart.series[2].setData([pt]);
It seems that you didn't include z property (value of the bubble) in your point's JSON (https://api.highcharts.com/highmaps/series.mapbubble.data.z).
Bubble is rendering fine after I added it: http://jsfiddle.net/BlackLabel/ktha1nmz/
Related
How to detect when dataLabels are overlapping and adjust them programmatically
I have a stacked column/scatter chart with some dataLabels off to one side. The issue I am facing is that when my two markers begin to get close to one another, their dataLabels overlap I need to always show both labels, so is there a way to detect when labels are overlapping and move the bottom one down by adjusting its y value based on how much overlap there is? sample fiddle of the issue Highcharts.chart('container', { chart: { type: 'column', width: 500 }, title: { text: 'Stacked column chart' }, xAxis: { visible: false, }, yAxis: { min: 0, visible: false, title: { }, }, legend: { layout:"vertical", align: "right", verticalAlign: "bottom", itemMarginTop: 15, y: -10, x: -50 }, tooltip: { enabled: false, }, plotOptions: { scatter: { marker: { symbol: "triangle", }, dataLabels: { enabled: true, x: -80, y: 50, allowOverlap: true, useHTML: true, } }, column: { pointWidth: 70, stacking: 'normal', dataLabels: { enabled: false } } }, series: [{ name: '', data: [100], color: "#ededed" }, { name: '', data: [500] }, { name: '', data: [400] }, { type: "scatter", data: [1000], color: "#000", dataLabels: { formatter: function(){ return "<div class='label-text'>Your goal of <br/>$"+ this.y +"<br/>text</div>" }, } }, { type: "scatter", data: [900], color: "#000", dataLabels: { formatter: function(){ return "<div class='label-text'>You are here <br/>$"+ this.y +"<br/>text</div>" }, } }] });
You can correct data-labels positions by using the attr method on their SVG elements. For example: chart: { events: { render: function() { const series = this.series; const dl1 = series[3].points[0].dataLabel; const dl2 = series[4].points[0].dataLabel; if (dl1.y + dl1.height > dl2.y) { dl2.attr({ y: dl1.y + dl1.height }); } } } } Live demo: https://jsfiddle.net/BlackLabel/5Lmh4owb/ API Reference: https://api.highcharts.com/class-reference/Highcharts.SVGElement.html#attr https://api.highcharts.com/highcharts/chart.events.render
Stockchart - property { cropThreshold: } is not working
I have created a chart with StockChart and I am trying to enlarge the cropThreshold of the serie but without success. When I am using the HighCharts implementation then it's working as expected. example of StockChart / HighChart: - JSFiddle (To see the difference between the two implementation just change line 4 with line 5) code: $(function() { Highcharts.stockChart('container', { /* Highcharts.chart({ */ chart: { renderTo: 'container' }, title: { text: 'Project wise Budget Estimation' }, navigation: { buttonOptions: { enabled: false } }, navigator: { enabled: false }, rangeSelector: { enabled: false }, credits: { enabled: false }, xAxis: { tickInterval: 15 * 60 * 1000, type: 'datetime', min: 1530385200000, max: 1530394200000 }, yAxis: { min: 0, opposite: false, tickColor: '#95989A', tickWidth: 1, tickLength: 10, visible: true, tickInterval: 60, title: { text: 'Amount Distribution' } }, legend: { shadow: false }, tooltip: { }, plotOptions: { column: { stacking: 'normal', cropThreshold: 150 } }, series: [ { name: 'targetName', showInLegend: true, data: [ [1530385200000,500],[1530386100000,500],[1530387000000,500],[1530387900000,500],[1530388800000,500],[1530389700000,500],[1530390600000,400],[1530391500000,450],[1530392400000,550],[1530393300000,500],[1530394200000,650],[1530395100000,500],[1530396000000,500],[1530396900000,550],[1530397800000,500],[1530398700000,500],[1530399600000,700],[1530400500000,650],[1530401400000,800],[1530402300000,500],[1530403200000,500],[1530404100000,300],[1530405000000,250],[1530405900000,200],[1530406800000,350],[1530407700000,150],[1530408600000,770],[1530409500000,800],[1530410400000,500],[1530411300000,500],[1530412200000,500],[1530413100000,500],[1530414000000,500],[1530414900000,500],[1530415800000,500],[1530416700000,500],[1530417600000,500],[1530418500000,500],[1530419400000,500],[1530420300000,500],[1530421200000,500],[1530422100000,500],[1530423000000,500],[1530423900000,500],[1530424800000,500] ], zIndex: 2 }, { name: 'deviationName', showInLegend: true, data: [ [1530385200000,450,550],[1530386100000,450,550],[1530387000000,450,550],[1530387900000,450,550],[1530388800000,450,550],[1530389700000,450,550],[1530390600000,360,440],[1530391500000,405,495],[1530392400000,495,605],[1530393300000,450,550],[1530394200000,585,715],[1530395100000,450,550],[1530396000000,450,550],[1530396900000,495,605],[1530397800000,450,550],[1530398700000,450,550],[1530399600000,630,770],[1530400500000,585,715],[1530401400000,720,880],[1530402300000,450,550],[1530403200000,450,550],[1530404100000,270,330],[1530405000000,225,275],[1530405900000,180,220],[1530406800000,315,385],[1530407700000,135,165],[1530408600000,693,847],[1530409500000,720,880],[1530410400000,450,550],[1530411300000,450,550],[1530412200000,450,550],[1530413100000,450,550],[1530414000000,450,550],[1530414900000,450,550],[1530415800000,450,550],[1530416700000,450,550],[1530417600000,450,550],[1530418500000,450,550],[1530419400000,450,550],[1530420300000,450,550],[1530421200000,450,550],[1530422100000,450,550],[1530423000000,450,550],[1530423900000,450,550] ], type: 'arearange', linkedTo: ':previous', zIndex: 0 }, { name: 'periodsName', showInLegend: false, type: 'column', cropThreshold: 150, zIndex: 1, pointInterval: 24 * 3600 * 1000, data: [ {"x":1530385200000,"y":400,"colorIndex":55},{"x":1530386100000,"y":400,"colorIndex":55},{"x":1530387000000,"y":400,"colorIndex":55},{"x":1530387900000,"y":480,"colorIndex":56},{"x":1530388800000,"y":495,"colorIndex":56},{"x":1530389700000,"y":510,"colorIndex":56},{"x":1530390600000,"y":700,"colorIndex":57},{"x":1530391500000,"y":650,"colorIndex":57},{"x":1530392400000,"y":300,"colorIndex":55},{"x":1530393300000,"y":660,"colorIndex":57},{"x":1530394200000,"y":400,"colorIndex":55},{"x":1530395100000,"y":500,"colorIndex":56},{"x":1530396000000,"y":500,"colorIndex":56},{"x":1530396900000,"y":200,"colorIndex":55},{"x":1530397800000,"y":490,"colorIndex":56},{"x":1530398700000,"y":500,"colorIndex":56},{"x":1530399600000,"y":400,"colorIndex":55},{"x":1530400500000,"y":300,"colorIndex":55},{"x":1530401400000,"y":200,"colorIndex":55},{"x":1530402300000,"y":500,"colorIndex":56},{"x":1530403200000,"y":480,"colorIndex":56},{"x":1530404100000,"y":670,"colorIndex":57},{"x":1530405000000,"y":755,"colorIndex":57},{"x":1530405900000,"y":680,"colorIndex":57},{"x":1530406800000,"y":710,"colorIndex":57},{"x":1530407700000,"y":670,"colorIndex":57},{"x":1530408600000,"y":400,"colorIndex":55},{"x":1530409500000,"y":400,"colorIndex":55},{"x":1530410400000,"y":500,"colorIndex":56},{"x":1530411300000,"y":400,"colorIndex":55},{"x":1530412200000,"y":510,"colorIndex":56},{"x":1530413100000,"y":400,"colorIndex":55},{"x":1530414000000,"y":490,"colorIndex":56},{"x":1530414900000,"y":400,"colorIndex":55},{"x":1530415800000,"y":400,"colorIndex":55},{"x":1530416700000,"y":590,"colorIndex":57},{"x":1530417600000,"y":590,"colorIndex":57},{"x":1530418500000,"y":600,"colorIndex":57},{"x":1530419400000,"y":620,"colorIndex":57},{"x":1530420300000,"y":400,"colorIndex":55},{"x":1530421200000,"y":600,"colorIndex":57},{"x":1530422100000,"y":600,"colorIndex":57},{"x":1530423000000,"y":600,"colorIndex":57},{"x":1530423900000,"y":400,"colorIndex":55},{"x":1530423000000,"y":600,"colorIndex":57},{"x":1530423900000,"y":400,"colorIndex":55},{"x":1530423000000,"y":600,"colorIndex":57},{"x":1530423900000,"y":400,"colorIndex":55},{"x":1530423000000,"y":600,"colorIndex":57},{"x":1530423900000,"y":400,"colorIndex":55} ] }, { name: 'withinTarget', type: 'column', showInLegend: true, data: [] }, { name: 'belowTarget', type: 'column', showInLegend: true, data: [] }, { name: 'overTarget', type: 'column', showInLegend: true, data: [] }], scrollbar: { enabled:true, /* liveRedraw: false, */ barBackgroundColor: 'gray', barBorderRadius: 7, barBorderWidth: 0, buttonBackgroundColor: 'gray', buttonBorderWidth: 0, buttonArrowColor: 'yellow', buttonBorderRadius: 7, rifleColor: 'yellow', trackBackgroundColor: 'white', trackBorderWidth: 1, trackBorderColor: 'silver', trackBorderRadius: 7 } }); });
This behavior is caused by dataGrouping, you can disable it. It is also worth noting that you have unsorted data. plotOptions: { series: { stacking: 'normal', cropThreshold: 150, dataGrouping: { enabled: false } } } Live example: http://jsfiddle.net/BlackLabel/2ma3yhv1/ API Reference: https://api.highcharts.com/highstock/plotOptions.series.dataGrouping.enabled
Highcharts bar chart configuration to increase height and round edges
In an Angular 4 project I am using the angular2-highcharts library to create a stacked bar chart. The following object is the configuration I have so far. { title: { text: '' }, xAxis: { categories: [''], crosshair: true, visible: false }, yAxis: { min: 0, max: 100, title: { text: '' }, labels: { enabled: true }, visible: false }, chart: { type: 'bar', backgroundColor: 'rgba(255, 255, 255, 0.1)' }, legend: { enabled: false }, plotOptions: { column: { pointPadding: 0, borderWidth: 0, stacking: 'normal', dataLabels: { enabled: true, formatter: function() { return this.point.y + '%'; }, inside: true }, enableMouseTracking: false, }, series: { stacking: 'normal', dataLabels: { enabled: true, formatter: function () { if (this.point.y) { return this.point.y + '%'; } return ''; }, style: { fontSize: '10px' }, padding: 10 }, borderWidth: 0 } }, series: [{ name: 'Pending', data: ..., color: '#ff4233' }, { name: 'Executed', data: ..., color: '#34d788' }, { name: 'Cancelled', data: ..., color: '#8f8c87' }] } and this produces this visual result -> I need to transform this into -> As you see in the desired result the chart has more height and also its edges are round. That I don't know how to do.
Have you tried to use rounded-corners plugin? With it you can use following properties: borderRadiusTopLeft, borderRadiusTopRight, borderRadiusBottomRight and borderRadiusBottomLeft Plugin Reference: https://github.com/highcharts/rounded-corners Example: http://jsfiddle.net/3Lhzx8ao/
No data found message in highcharts
Below is the highcharts code I am using with dynamic values $fprgreen, $fprblue and $fprdrkorange. $('#seo-perform-fpr').highcharts({ exporting: { enabled: false }, credits: { enabled: false }, title: false, chart: { plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false, type: 'pie' }, tooltip: { pointFormat: '<b>{point.percentage:.1f}%</b>' }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: false }, showInLegend: false } }, series: [{ colorByPoint: true, data: [{ name: 'High', color: '#8bc43f', y: <?php echo $fprgreen;?> }, { name: 'Steady', y: <?php echo $fprblue;?>, // sliced: true, // selected: true, color: '#01A9F4', }, { name: 'Underperforming', y: <?php echo $fprdrkorange;?>, color: '#f57c00', }, ] }] }); If the values of $fprgreen, $fprblue and $fprdrkorange are 0, I need to show "No data found" message on the place of pie chart.
Highcharts change legend of only last stacked value
I have a highchart, as showed on the appended image. I am attempting to format the legend of only my last data stacked. In this case, index 1 always. Any help on how to achieve this? My main goal, being, on there always showing a value i have in a variable, which will be the max value possible. createChart: function (id, chartData, maxYValues, chartTitle, chartNames, dataToMax) { var me = this; debugger; me.highChart = new Highcharts.Chart({ chart: { type: 'column', renderTo: id }, title: { text: chartTitle, fontSize: '8px' }, xAxis: { labels: { overflow: 'justify' }, categories: chartNames }, yAxis: { gridLineWidth: 0, minorGridLineWidth: 0, labels: { enabled: false }, stackLabels: { enabled: true, format: maxYValues }, title: { enabled: false } }, colors: ['#afafaf', '#f89c1c', '#3aaa80'], credits: { enabled: false }, tooltip: { pointFormat: '<span>{point.name}</span>' }, plotOptions: { series: { colors: ['#3aab80', '#3aab80'], colorByPoint: true, borderWidth: 0, dataLabels: { enabled: true, headerFormat: '{point.y + point.name}', format: '{y} mb', verticalAlign: 'top', y: -20 } }, column: { stacking: "percent" }, area: { dataLabels: { enabled: false } } }, legend: { labelFormat: '<b>{point.y} MB</b><br/>', labelFormatter: function () { if (me.series.data.index === 1) { return maxYValues; } } }, series: [{ showInLegend: false, data: chartData, color: '#3aab80' }, { showInLegend: false, data: dataToMax, legend: { labelFormat: maxYValues + 'MB</b><br/>' } }], navigation: { menuItemStyle: { fontSize: '8px' } } }); }, Thank you UPDATE: Added code snipped, and updated the image to what my current code is showing