我想添加一個datepicker(jquery-ui)到範圍選擇器,但我無法讓它工作。Datechaicker jquery-ui for angular highcharts-ng rangeSelector
我想是這樣的例子使用jQuery:
$.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function (data) {
// Create the chart
$('#container').highcharts('StockChart', {
rangeSelector : {
selected : 1
},
title : {
text : 'AAPL Stock Price'
},
series : [{
name : 'AAPL',
data : data,
tooltip: {
valueDecimals: 2
}
}]
}, function (chart) {
// apply the date pickers
setTimeout(function() {
$('input.highcharts-range-selector').datepicker();
}, 0);
});
});
});
但隨着角度進行:
$scope.chartConfig = {
options: {
chart: {
zoomType: 'x'
},
rangeSelector: {
enabled: true
},
navigator: {
enabled: true
}
},
series: [],
title: {
text: 'Hello'
},
useHighStocks: true,
function (chart) {
// apply the date pickers
$timeout(function() {
$('input.highcharts-input-group').datepicker();
}, 0);
}
}
毫無疑問jquery-ui datepicker works in angular:
var app = angular.module('myApp', []);
app.directive('datepicker', function() {
return {
restrict: 'C',
require: 'ngModel',
link: function (scope, element, attrs, ngModelCtrl) {
$(element).datepicker({
dateFormat: 'dd, MM, yy',
onSelect: function (date) {
scope.date = date;
scope.$apply();
}
});
}
};
});
app.controller('myCtrl', function($scope) {
console.log('it works');
$scope.count = 0;
$scope.popdp=function(event){
console.log('XD')
event.preventDefault();
$('.datepicker2').datepicker({
dateFormat: 'dd, MM, yy',
onSelect: function (date) {
scope.date = date;
scope.$apply();
}
});
}
});
我喜歡的東西,我已經知道了一下打成一片。無論如何,我可能會有與angular-ui中的datepicker相同的問題。主要是關於從highcharts-ng創建的圖表中選擇正確的DOM元素。 – gugol