製品版のみの機能
データ チャート - XML のバインド
このサンプルは、XML データにバインド`したデータ チャートを表示します。
このサンプルは CTP 機能を使用しています。製品版では、API や動作が変更される場合があります。
人口のデータ ソース:
U.S. Census Bureau
U.S. Census Bureau
このサンプルは、より大きい画面サイズのためにデザインされました。
モバイル デバイスで画面を回転、フル サイズ表示、またはその他のデバイスにメールで送信します。
コード ビュー
クリップボードへコピー
<!DOCTYPE html>
<html>
<head>
<title>XML Binding</title>
<script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<!-- Ignite UI for jQuery Required Combined CSS Files -->
<link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
<link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/structure/infragistics.css" rel="stylesheet" />
<!--CSS file specific for chart styling -->
<link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/structure/modules/infragistics.ui.chart.css" rel="stylesheet" />
<!-- Ignite UI for jQuery Required Combined JavaScript Files -->
<script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.core.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.dv.js"></script>
</head>
<body>
<script>
$(function () {
//Sample XML Data
var xmlDoc = '<WorldPopulation>' +
'<Country Name="China" Pop1995="1216" Pop2005="1297" Pop2015="1361" Pop2025="1394" />' +
'<Country Name="India" Pop1995="920" Pop2005="1090" Pop2015="1251" Pop2025="1396" />' +
'<Country Name="United States" Pop1995="266" Pop2005="295" Pop2015="322" Pop2025="351" />' +
'<Country Name="Indonesia" Pop1995="197" Pop2005="229" Pop2015="256" Pop2025="277" />' +
'<Country Name="Brazil" Pop1995="161" Pop2005="186" Pop2015="204" Pop2025="218" />' +
'</WorldPopulation>';
//Binding to XML requires a schema to define data fields
var xmlSchema = new $.ig.DataSchema("xml",
{
//searchField serves as the base node(s) for the XPaths
searchField: "//Country",
fields: [
{ name: "Name", xpath: "./@Name"},
{ name: "Pop1995", xpath: "./@Pop1995" },
{ name: "Pop2005", xpath: "./@Pop2005" },
{ name: "Pop2015", xpath: "./@Pop2015" },
{ name: "Pop2025", xpath: "./@Pop2025" },
]
}
);
//This creates an Infragistics datasource from the XML
//and the Schema which can be consumed by the grid.
var ds = new $.ig.DataSource({
type: "xml",
dataSource: xmlDoc,
schema: xmlSchema
});
ds.dataBind();
$("#chart").igDataChart({
width: "100%",
height: "400px",
title: "国別人口",
subtitle: "2015 年推計人口トップ 5",
axes: [
{
name: "NameAxis",
type: "categoryX",
label: "Name",
dataSource: ds, //$.ig.DataSource defined above
title: "国"
},
{
name: "PopulationAxis",
type: "numericY",
minimumValue: 0,
maximumValue: 1400,
title: "人口 (百万人単位)"
}
],
series: [
{
name: "2015Population",
type: "column",
isHighlightingEnabled: true,
isTransitionInEnabled: true,
dataSource: ds, //$.ig.DataSource defined above
xAxis: "NameAxis",
yAxis: "PopulationAxis",
valueMemberPath: "Pop2015"
}
]
});
});
</script>
<div style="width: 90%; min-width: 210px;">
<div id="chart"></div>
</div>
<div class="USCensus-attribution">
人口のデータ ソース:<br />
<a href="http://www.census.gov/" target="_blank">U.S. Census Bureau</a>
</div>
</body>
</html>