我使用flot.js
创建了一个条形图。
每个栏应使用$.ajax
使用不同颜色的MVC。
$.ajax({
type: "GET",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
url: '/eTechInternal/GetSalesData/',
data: {
Year: Year,
Month: Month,
ResellerId: ResellerId
},
error: function() {
alert("An error occurred.");
},
success: function(data) {
console.log(data);
var dataset = [{
label: "",
data: data,
color: "#5482FF"
}];
var ticks = [
[0, "EndPoints"],
[1, "Exchange"],
[2, "Amazon Small"],
[3, "Amazon Medium"],
[4, "Amazon Large"],
[5, "Amazon XLarge"],
[6, "Amazon 2XLarge"],
[7, "Amazon 4XLarge"]
];
var options = {
series: {
bars: {
show: true
}
},
bars: {
align: "center",
barWidth: 0.5
},
xaxis: {
axisLabel: "",
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Verdana, Arial',
axisLabelPadding: 10,
ticks: ticks
},
legend: {
noColumns: 0,
labelBoxBorderColor: "#000000",
position: "nw"
},
grid: {
hoverable: true,
borderWidth: 2,
backgroundColor: {
colors: ["#ffffff", "#EDF5FF"]
}
}
};
$.plot($("#flot-bar-chart"), dataset, options);
$("#flot-bar-chart").UseTooltip();
我怎样才能做到这一点?