jQWidgets是一个 JavaScript 框架,用于为 PC 和移动设备制作基于 Web 的应用程序。它是一个非常强大且优化的框架,独立于平台,并且得到广泛支持。jqx图表是一个轻量级且函数强大的图表小部件,100% 用 JavaScript 编写。它提供许多高级函数并支持三种不同的渲染技术 - SVG、HTML5 Canvas 和 VML。在本文中,我们将看到 jQWidgets jqxChart 中的 toolTipFormatFunction 属性。
工具提示格式函数 property 是一个回调函数,用于显示用户定义的工具提示文本格式。它是函数类型,其默认值是未定义的。
用法:
seriesGroups: [{ type: 'rangecolumn', columnsGapPercent: 30, seriesGapPercent: 0, toolTipFormatFunction: toolTipCustomFormatFn, series: [ { dataFieldFrom: 'f1', dataFieldTo: 't1'}, { dataFieldFrom: 'f2', dataFieldTo: 't2'}, ] }];
链接文件:下载jQWidgets从给定的链接。在 HTML 文件中,找到下载文件夹中的脚本文件。
<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<script type=”text/javascript” src=”scripts/jquery-1.11.1.min.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxchart.core.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxdraw.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxdata.js”></script>
示例 1:下面的示例说明了 jQWidgets jqxChart工具提示格式函数 属性。
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet"
href="jqwidgets/styles/jqx.base.css"
type="text/css" />
<script type="text/javascript"
src="scripts/jquery-1.11.1.min.js">
</script>
<script type="text/javascript"
src="jqwidgets/jqxcore.js">
</script>
<script type="text/javascript"
src="jqwidgets/jqxchart.core.js">
</script>
<script type="text/javascript"
src="jqwidgets/jqxdraw.js">
</script>
<script type="text/javascript"
src="jqwidgets/jqxdata.js">
</script>
</head>
<body>
<center>
<h1 style="color: green">
GeeksforGeeks
</h1>
<h3>
jQWidgets jqxChart
toolTipFormatFunction property
</h3>
<div id='gfg1'
style="width:400px;
height: 200px" />
</center>
<script type="text/javascript">
$(document).ready(function () {
var data = [
{ Day: 'Monday', f1: 3, t1: 1, f2: 2, t2: 1 },
{ Day: 'Tuesday', f1: 3, t1: 1, f2: 2, t2: 1 },
{ Day: 'Wednesday', f1: 3, t1: 1, f2: 2, t2: 1 },
{ Day: 'Thursday', f1: 3, t1: 1, f2: 2, t2: 1 },
{ Day: 'Friday', f1: 3, t1: 1, f2: 2, t2: 1 },
{ Day: 'Saturday', f1: 3, t1: 1, f2: 2, t2: 1 },
{ Day: 'Sunday', f1: 3, t1: 1, f2: 2, t2: 1 }
];
var toolTipFormatFn = function (val,iIndex,s,grp,cValue) {
var dItem = data[iIndex];
return '<DIV style="text-align:left"><b>Day: ' + cValue +
'</b><br />Begin: ' + val.from +
'<br />End: ' + val.to;
};
var obj = {
title: "Coding Score",
description: "Coding Questions Solved Daily",
enableAnimations: true,
showLegend: true,
source: data,
categoryAxis: {
dataField: 'Day',
showGridLines: true
},
seriesGroups: [{
type: 'rangecolumn',
columnsGapPercent: 30,
seriesGapPercent: 0,
toolTipFormatFunction: toolTipFormatFn,
series: [
{ dataFieldFrom: 'f1', dataFieldTo: 't1' },
{ dataFieldFrom: 'f2', dataFieldTo: 't2' },
]
}]
};
$('#gfg1').jqxChart(obj);
});
</script>
</body>
</html>
输出:
示例 2:下面是jqxChart的另一个例子工具提示格式函数jQWidgets 中的属性。
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet"
href="jqwidgets/styles/jqx.base.css"
type="text/css" />
<script type="text/javascript"
src="scripts/jquery-1.11.1.min.js">
</script>
<script type="text/javascript"
src="jqwidgets/jqxcore.js">
</script>
<script type="text/javascript"
src="jqwidgets/jqxchart.core.js">
</script>
<script type="text/javascript"
src="jqwidgets/jqxdraw.js">
</script>
<script type="text/javascript"
src="jqwidgets/jqxdata.js">
</script>
</head>
<body>
<center>
<h1 style="color: green">
GeeksforGeeks
</h1>
<h3>
jQWidgets jqxChart
toolTipFormatFunction property
</h3>
<div id='gfg1'
style="width:400px;
height: 200px" />
</center>
<center>
<input type="button"
id="btn"
value="Click Here"
style="padding: 5px 14px;
margin-top: 15px;">
<br>
<div id="log"></div>
</center>
<script type="text/javascript">
$(document).ready(function () {
var data = [
{ Day: 'Monday', f1: 3, t1: 1, f2: 2, t2: 1 },
{ Day: 'Tuesday', f1: 3, t1: 1, f2: 2, t2: 1 },
{ Day: 'Wednesday', f1: 3, t1: 1, f2: 2, t2: 1 },
{ Day: 'Thursday', f1: 3, t1: 1, f2: 2, t2: 1 },
{ Day: 'Friday', f1: 3, t1: 1, f2: 2, t2: 1 },
{ Day: 'Saturday', f1: 3, t1: 1, f2: 2, t2: 1 },
{ Day: 'Sunday', f1: 3, t1: 1, f2: 2, t2: 1 }
];
var toolTipFormatFn = function (val, iIndex, s, grp, cValue) {
var dItem = data[iIndex];
return '<DIV style="text-align:left"><b>Day: ' + cValue +
'</b><br />Begin: ' + val.from +
'<br />End: ' + val.to;
};
var obj = {
title: "Coding Score",
description: "Coding Questions Solved Daily",
enableAnimations: true,
showLegend: true,
source: data,
categoryAxis: {
dataField: 'Day',
showGridLines: true
},
seriesGroups: [{
type: 'rangecolumn',
columnsGapPercent: 30,
seriesGapPercent: 0,
toolTipFormatFunction: toolTipFormatFn,
series: [
{ dataFieldFrom: 'f1', dataFieldTo: 't1' },
{ dataFieldFrom: 'f2', dataFieldTo: 't2' },
]
}]
};
$('#gfg1').jqxChart(obj);
$('#btn').click(function () {
var ttff = $('#gfg1').jqxChart('toolTipFormatFunction');
if (ttff === null) {
$('#log').text("Null!");
}
else {
$('#log').text("Not null!");
}
});
});
</script>
</body>
</html>
输出:
相关用法
- jQWidgets jqxChart toolTipHideDelay属性用法及代码示例
- jQWidgets jqxChart toolTipMoveDuration属性用法及代码示例
- jQWidgets jqxChart toolTipShowDelay属性用法及代码示例
- jQWidgets jqxChart title属性用法及代码示例
- jQWidgets jqxChart titlePadding属性用法及代码示例
- jQWidgets jqxChart addColorScheme()用法及代码示例
- jQWidgets jqxChart animationDuration属性用法及代码示例
- jQWidgets jqxChart backgroundColor属性用法及代码示例
- jQWidgets jqxChart borderLineColor属性用法及代码示例
- jQWidgets jqxChart borderLineWidth属性用法及代码示例
- jQWidgets jqxChart colorScheme属性用法及代码示例
- jQWidgets jqxChart columnSeriesOverlap属性用法及代码示例
- jQWidgets jqxChart crosshairsColor属性用法及代码示例
- jQWidgets jqxChart crosshairsDashStyle属性用法及代码示例
- jQWidgets jqxChart crosshairsLineWidth属性用法及代码示例
- jQWidgets jqxChart description属性用法及代码示例
- jQWidgets jqxChart enableAnimations属性用法及代码示例
- jQWidgets jqxChart enableAxisTextAnimation属性用法及代码示例
- jQWidgets jqxChart enableCrosshairs属性用法及代码示例
- jQWidgets jqxChart enabled属性用法及代码示例
- jQWidgets jqxChart getColorScheme()用法及代码示例
- jQWidgets jqxChart getItemCoord()用法及代码示例
- jQWidgets jqxChart getValueAxisLabels()用法及代码示例
- jQWidgets jqxChart getValueAxisRect()用法及代码示例
- jQWidgets jqxChart getXAxisLabels()用法及代码示例
注:本文由纯净天空筛选整理自nidhi1352singh大神的英文原创作品 jQWidgets jqxChart toolTipFormatFunction Property。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。