我似乎无法在我的基本Flot图表上运行标签,我已将其剥离到基础但我仍然无法使其工作;
<div id="graph" style="width:600px;height:300px;"></div>
<script type="text/javascript">
$(function () {
var d1 = [[0, 13], [1, 13], [2, 13], [3, 0], [4, 17], [5, 17], [6, 13]];
$.plot($("#graph"), [
{
data: d1,
bars: {
show: true
},
xaxis: {
axisLabel: 'Hops'
},
yaxis: {
axisLabel: 'Traceroute'
}
}
]);
});
</script>
以下是我得到的图表。如您所见,Chrome调试窗口中没有错误。我确实包含了以下简单的轴标签格式设置,但它仍然不起作用:
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
axisLabelPadding: 5
答案 0 :(得分:1)
我不知道我是如何修复它的,但是通过使它更复杂,我有。也许是一个错误?
现在它适用于此代码:
<div id="graph" style="width:600px;height:300px;"></div>
<script type="text/javascript">
$(function () {
var d1 = [[0, 13]];
var d2 = [[1, 13]];
var d3 = [[2, 13]];
var d4 = [[3, 30]];
var d5 = [[4, 17]];
var d6 = [[5, 17]];
var d7 = [[6, 13]];
var data1 = [
{
data: d1,
bars: {
show: true,
fillColor: "#CAFFD8"
},
color: "#CAFFD8"
},
{
data: d2,
bars: {
show: true,
fillColor: "#CAFFD8"
},
color: "#CAFFD8"
},
{
data: d3,
bars: {
show: true,
fillColor: "#CAFFD8"
},
color: "#CAFFD8"
},
{
data: d4,
bars: {
show: true,
fillColor: "#FF7575"
},
color: "#FF7575"
},
{
data: d5,
bars: {
show: true,
fillColor: "#FFFF75"
},
color: "#FFFF75"
},
{
data: d6,
bars: {
show: true,
fillColor: "#FFFF75"
},
color: "#FFFF75"
},
{
data: d7,
bars: {
show: true,
fillColor: "#CAFFD8"
},
color: "#CAFFD8"
},
];
$.plot($("#graph"), data1, {
xaxis: {
axisLabel: 'Hops',
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
axisLabelPadding: 5
},
yaxis: {
min: 0,
max: 30,
axisLabel: 'Traceroute',
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
axisLabelPadding: 5
}
});
});
</script>
答案 1 :(得分:0)
您需要在html代码中加入jquery.flot.axislabels插件。