0
に表示するには、Get私は、このように、様々なJSONファイルのチェックボックスがあります。デフォルトのチャートは、私は我々のデータの一部でグラフを構築するために、この特定のFLOTの例を使用していFLOTチャート
<span>
<input class="fetchSeries" type="checkbox"> Service One
<a href="@Server.MapPath("~/Scripts/flot/servicedataone.json")"></a>
</span>
私はグラフがJSONファイルの1ページのロード時に事前移入したいと思います。私は、ページが読み込まれたときにデフォルトでチェックボックスの1つをチェックすることを含め、さまざまなことを試しましたが、運はありません。
ご協力いただきましてありがとうございます。以下のコード:このことについて
<script type="text/javascript">
$(document).ready(function() {
var options = {
lines: { show: true },
points: { show: true },
yaxis: {
},
xaxis: {
mode: "time"
},
grid: { hoverable: true }
};
var data = [];
var placeholder = $("#placeholder");
$.plot(placeholder, data, options);
// fetch one series, adding to what we got
var alreadyFetched = {};
$("input.fetchSeries").click(function() {
var button = $(this);
// find the URL in the link right next to us
var dataurl = button.siblings('a').attr('href');
// then fetch the data with jQuery
function onDataReceived (series) {
// extract the first coordinate pair so you can see that
// data is now an ordinary Javascript object
var firstcoordinate = '(' + series.data[0][0] + ', ' + series.data[0][1] + ')';
//button.siblings('span').text('Fetched ' + series.label + ', first point: ' + firstcoordinate);
// let's add it to our current data
if (!alreadyFetched[series.label]) {
alreadyFetched[series.label] = true;
data.push(series);
}
// and plot all we got
$.plot(placeholder, data, options);
}
$.ajax({
url: dataurl,
method: 'GET',
dataType: 'json',
success: onDataReceived
});
});
});
</script>
いやが、動作しませんでした:( – mynameisneo
を、私はこれをテストし、正常に動作します:http://jsfiddle.net/ryleyb/bdSrc/唯一の違いは、jsfiddleでということです私はデータを生成し、jsfiddleからそれをバウンスしました。なぜなら、私はデータを取得するサーバを持っていないからです。 – Ryley
これは動作しました..ありがとう! – mynameisneo