製品版のみの機能
シェープ チャート - チャート タイプ - 多角形
このサンプルでは、チャート コントロールの多角形シリーズを紹介します。
このサンプルは CTP 機能を使用しています。製品版では、API や動作が変更される場合があります。
このサンプルは、より大きい画面サイズのためにデザインされました。
モバイル デバイスで画面を回転、フル サイズ表示、またはその他のデバイスにメールで送信します。
コード ビュー
クリップボードへコピー
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Polygon Series</title>
<!-- 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" />
<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 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>
<div id="chart"></div>
<!-- template for custom tooltip -->
<script id="customTooltip" type="text/x-jquery-tmpl">
<table id="tooltipTable" style="background: white;">
<tr> <th colspan="2">${item.Label}</th> </tr>
<tr> <td>Width: ${item.Width} m</td> </tr>
<tr> <td>Height: ${item.Height} m</td> </tr>
<tr> <td>Area: ${item.Area} m</td> </tr>
</table>
</script>
<script type="text/javascript">
(function () {
$("#chart").igShapeChart({
width: "98%",
height: "550px",
title: "家の間取り図",
dataSource: createRoomData(),
chartType: "polygon",
brushes: ["#1C6ABB"],
outlines: ["#084482"],
isHorizontalZoomEnabled: true,
isVerticalZoomEnabled: true,
toolTipType: "default",
tooltipTemplate: "customTooltip",
// customizing marker template on seriesAdded event
seriesAdded: function (evt, args) {
args.series.title = "Rooms";
args.series.markerTemplate = {
render: function (renderInfo) {
renderInfo.context.font = "16px serif";
renderInfo.context.fillStyle = "white";
renderInfo.context.textAlign = "center";
renderInfo.context.fillText(renderInfo.data.item().Label, renderInfo.xPosition, renderInfo.yPosition);
}
}
}
});
$("#chart").igShapeChart({
yAxisFormatLabel: function (value) {
return value + " m";
},
xAxisFormatLabel: function (value) {
return value + " m";
},
xAxisMinimumValue: -2,
xAxisMaximumValue: 12,
yAxisMinimumValue: -2,
yAxisMaximumValue: 12,
//xAxisMajorStrokeThickness: 0,
//yAxisMajorStrokeThickness: 0,
});
function createRoomData() {
var shapes = [
{
"Label": "Hallway", "Points": [[
{ x: 6, y: 0 },
{ x: 6, y: 7 },
{ x: 4, y: 7 },
{ x: 4, y: 0 }, ]]
},
{
"Label": "Entrance", "Points": [[
{ x: 0, y: 5 },
{ x: 4, y: 5 },
{ x: 4, y: 7 },
{ x: 0, y: 7 }, ]]
},
{ "Label": "Guest Bedroom", "Points": [[{ x: 2, y: 10 }, { x: 7, y: 10 }, { x: 7, y: 7 }, { x: 2, y: 7 }], ] },
{ "Label": "Bathroom", "Points": [[{ x: 0, y: 10 }, { x: 2, y: 10 }, { x: 2, y: 7 }, { x: 0, y: 7 }], ] },
{ "Label": "Kitchen", "Points": [[{ x: 6, y: 7 }, { x: 10, y: 7 }, { x: 10, y: 4 }, { x: 6, y: 4 }], ] },
{ "Label": "Living Room", "Points": [[{ x: 6, y: 4 }, { x: 10, y: 4 }, { x: 10, y: 0 }, { x: 6, y: 0 }], ] },
{ "Label": "Master Bedroom", "Points": [[{ x: 0, y: 0 }, { x: 4, y: 0 }, { x: 4, y: 5 }, { x: 0, y: 5 }], ] },
];
// optional code to calculate dimensions of all shapes
for (i = 0; i < shapes.length; i++) {
var xMin = 1000;
var yMin = 1000;
var xMax = 0;
var yMax = 0;
for (p = 0; p < shapes[i].Points[0].length; p++) {
var point = shapes[i].Points[0][p];
xMin = Math.min(xMin, point.x);
yMin = Math.min(yMin, point.y);
xMax = Math.max(xMax, point.x);
yMax = Math.max(yMax, point.y);
}
shapes[i].PointsCount = shapes[i].Points[0].length;
shapes[i].Width = Math.abs(xMax - xMin);
shapes[i].Height = Math.abs(yMax - yMin);
shapes[i].Area = shapes[i].Width * shapes[i].Height;
shapes[i].AreaStr = shapes[i].Area.toFixed(2);
}
return shapes;
};
})();
</script>
</body>
</html>