Pracowałem nad Highcharts właśnie wpadł w jednym problem, problem jest, gdy nie ma żadnej wartości istnieją dla niektórych danych na wykresie, wtedy wyświetla 0 na nim, który wygląda źle łaskawie kasie następujące jsfiddle Etykiety na wykresie zostaną wypełnione przez następującą funkcję, ale nie jestem w stanie sprawdzić, czy powinna wyświetlać tylko te paski, których wartości są powyżej zera na wykresie: [KLIKNIJ SPRAWDŹ sekcję APPLE na wykresie]Usuń Zero z HIGHCHART
$(function() {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column'
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'blue'
}
}
},
legend: {
align: 'right',
x: -100,
verticalAlign: 'top',
y: 20,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'gray',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
formatter: function() {
return '<b>'+ this.x +'</b><br/>'+
this.series.name +': '+ this.y +'<br/>'+
'Total: '+ this.point.stackTotal;
}
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
}
}
},
series: [{
name: 'John',
data: [0, 3, 4, 7, 2]
}, {
name: 'Jane',
data: [2, 2, 3, 2, 1]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}]
});
});
});
dobra sztuczka, ale dane są wypełniane w moim wykresie z DB, ale mogę umieścić kontrole, które –
Tak, będziesz musiał zbudować swoje dane w określonym formacie, zanim nadasz je do haseł. – c0deNinja
Ustawiłbym wartość na zero. Pamiętaj, że -1 jest wartością, a null nią nie jest. – wergeld