谷歌饼图切片通过变量传递值为偏移量(google pie chart slices pass value through variable for offset)
我正在使用谷歌图表api和angularjs.I需要通过变量设置切片值。所有示例我已经看到它们是硬编码或使用foreach循环。如何通过变量设置选定的饼图片值。这是我的代码?“selectedRow”变量作为字符串传递而不是作为变量传递。
$scope.onSelectRowFunction = function(selectedItem) { var selectedRow = parseInt(selectedItem.row); $scope.chartpie.options = { "slices": {selectedRow : {"offset": 0.4}}, "title": "Title is here", "isStacked": "true", "sliceVisibilityThreshold": 0, "displayExactValues": true }; };
I am using google chart api and angularjs.I need to set slices value through variable.All example i have seen they are hardcoded or using foreach loop.How could i set selected pie slice value through variable.Here is my code?"selectedRow" variable is passing as a string not as a variable.
$scope.onSelectRowFunction = function(selectedItem) { var selectedRow = parseInt(selectedItem.row); $scope.chartpie.options = { "slices": {selectedRow : {"offset": 0.4}}, "title": "Title is here", "isStacked": "true", "sliceVisibilityThreshold": 0, "displayExactValues": true }; };
原文:https://stackoverflow.com/questions/26764504
更新时间:2023-08-14 19:08
最满意答案
你可以这样做 :
$('a[href~="tel:{{telefono}}"]').attr('href', 'tel:'+telefono);
如果你想要更通用的东西,那就是你要在所有属性
href
替换{{telefono}}
,你可以使用:$('[href~="{{telefono}}"]').attr('href', function(i, v) { return v.replace('{{telefono}}', telefono); });
编辑:
如果您还想更改
a
元素的内容,可以执行以下操作:$('[href~="{{telefono}}"]').attr('href', function(i, v) { return v.replace('{{telefono}}', telefono); }).html(telefono);
You can do this :
$('a[href~="tel:{{telefono}}"]').attr('href', 'tel:'+telefono);
If you want something more generic, that is you want to replace
{{telefono}}
in all your attributeshref
, you could use this :$('[href~="{{telefono}}"]').attr('href', function(i, v) { return v.replace('{{telefono}}', telefono); });
EDIT :
If you also want to change the content of the
a
element, you can do this :$('[href~="{{telefono}}"]').attr('href', function(i, v) { return v.replace('{{telefono}}', telefono); }).html(telefono);
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
这是我将如何检索href属性列表: var loader:URLLoader = new URLLoader(); var request:URLRequest = new URLRequest("xml/main.xml"); loader.addEventListener(IOErrorEvent.IO_ERROR, function errorHandler(event:IOErrorEvent):void { trace("Error loading XML" + event.type); ...
-
谜语与“href”(Riddle with “href”)[2023-06-24]
-
你可以这样做 : $('a[href~="tel:{{telefono}}"]').attr('href', 'tel:'+telefono); 如果你想要更通用的东西,那就是你要在所有属性href替换{{telefono}} ,你可以使用: $('[href~="{{telefono}}"]').attr('href', function(i, v) { return v.replace('{{telefono}}', telefono); }); 编辑: 如果您还想更改a元素的内容,可以执行以 ...
-
如果这个href包含var(if this href contains a var)[2023-01-06]
由于href具有特殊字符,因此需要包装属性值。 此外,.find()返回一个jQuery对象,无论是否找到匹配项,因此您需要检查jQuery对象是否包含任何元素 - 您可以检查该属性的长度属性 var navcur = window.location.href; $(".subnavli").each(function () { if ($(this).find("a[href='" + navcur + "']").length) { alert('works!'); } ... -
如何超时href?(How to timeout a href?)[2022-12-01]
在保存图像的回调函数中重新加载图像: function capture() { $('#zoomTarget').html2canvas({ onrendered: function (canvas) { var url = "ajax.php"; var imgSrc = canvas.toDataURL(); $.post(url, {contentVar: imgSrc }, function(data) ... -
由于您选择的选择了id为#cartLink的任何元素,因此您可以在函数中将其称为$(this)。 在var url = ...之后; 写下面的内容: $(this).attr('href', url); http://api.jquery.com/attr/ Since your selected has selected any element with id #cartLink, you'll be able to refer to it as $(this) from within your fun ...
-
Javascript HREF更新(Javascript HREF updating)[2022-09-24]
主要编辑: 问题是在表单标签内的单个将提交表单,所以发生的是,输入输入,按Enter键,这会导致blor,因此onchange事件会触发,一切都会显示出来在调试器中很好。 完成后,页面重新加载(因为默认表单action是GET当前页面)而没有闪烁,重置输入值。 解决方案1:删除 -
得到href onclick(getting href onclick)[2024-01-06]