0
Flot과 함께 Zepto를 사용할 수 있습니까? 내가 FLOT을 알고Zepto와 Flot을 결합하십시오.
는 jQuery를 (테스트)와 함께 잘 작동하지만 Zepto 그냥 내가 그것을 시도하고 두 가지 문제로 실행 모바일 기기
Flot과 함께 Zepto를 사용할 수 있습니까? 내가 FLOT을 알고Zepto와 Flot을 결합하십시오.
는 jQuery를 (테스트)와 함께 잘 작동하지만 Zepto 그냥 내가 그것을 시도하고 두 가지 문제로 실행 모바일 기기
에 jQuery를보다 빠르고 부드러운 느낌. 첫째, flot
은 jQuery
을 정의하고 두 번째는 flot
은 outerWidth
을 사용합니다.이 값은 replicate이 아닙니다.
그래서, 이러한 문제를 해결 그것에게 작은 사랑하고 일을 해주지 :
<!DOCTYPE html>
<html>
<head>
<script>
</script>
<!-- Load Zepto -->
<script data-require="[email protected]" data-semver="1.1.4" src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.1.4/zepto.min.js"></script>
<!-- patch in the things we need -->
<script>
// define jquery
jQuery = $;
// create outerWidth/Height functions
// stolen from here: https://gist.github.com/pamelafox/1379704
['width', 'height'].forEach(function(dimension) {
var offset, Dimension = dimension.replace(/./, function(m) {
return m[0].toUpperCase()
});
$.fn['outer' + Dimension] = function(margin) {
var elem = this;
if (elem) {
var size = elem[dimension]();
var sides = {
'width': ['left', 'right'],
'height': ['top', 'bottom']
};
sides[dimension].forEach(function(side) {
if (margin) size += parseInt(elem.css('margin-' + side), 10);
});
return size;
} else {
return null;
}
};
});
</script>
<!-- now we can include flot -->
<script data-require="[email protected]" data-semver="0.8.2" src="//cdnjs.cloudflare.com/ajax/libs/flot/0.8.2/jquery.flot.min.js"></script>
</head>
<body>
<div id="placeholder" style="width:300px;height:300px"></div>
<script>
$(function() {
var d1 = [];
for (var i = 0; i < 14; i += 0.5) {
d1.push([i, Math.sin(i)]);
}
var d2 = [
[0, 3],
[4, 8],
[8, 5],
[9, 13]
];
// A null signifies separate line segments
var d3 = [
[0, 12],
[7, 12], null, [7, 2.5],
[12, 2.5]
];
$.plot("#placeholder", [d1, d2, d3]);
});
</script>
</body>
</html>