久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

“類型 {} 上不存在屬性"使用帶有 D3 SVG 符號(hào)

quot;Property does not exist on type {}quot; error when using anonymous function with D3 SVG Symbol(“類型 {} 上不存在屬性使用帶有 D3 SVG 符號(hào)的匿名函數(shù)時(shí)出錯(cuò))
本文介紹了“類型 {} 上不存在屬性"使用帶有 D3 SVG 符號(hào)的匿名函數(shù)時(shí)出錯(cuò)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我正在嘗試創(chuàng)建 D3 SVG 符號(hào),符號(hào)形狀根據(jù)數(shù)據(jù)中的類別屬性動(dòng)態(tài)設(shè)置.這將是 PowerBI 中自定義視覺(jué)對(duì)象的一部分,因此我使用的是 Typings 庫(kù).

I'm trying to create D3 SVG Symbols, with the symbol shape set dynamically based on a category property in the data. This will be part of a custom visual in PowerBI, so I'm using Typings library.

從我在網(wǎng)上看到的例子來(lái)看,下面的代碼應(yīng)該可以工作.

From the examples I've seen online, the below code should work.

var milestoneSymbols = this.milestoneContainer.selectAll('.path').data(viewModel.milestones);
milestoneSymbols.enter().append('path');
milestoneSymbols.attr('d', d3.svg.symbol() 
                            .size(25) 
                            .type( function(d){ return d.typeSymbol})
    );
milestoneSymbols.attr("transform", function(d,i) {
        return "translate("+ xScale(d.date) + "," 
            + ((i % heightGroups) * (milestoneContainerHeight/heightGroups) + margins.top )
            + ")";
        });
milestoneSymbols.style("stroke", "function(d) {  return findTaskTypeShape(d.label).color; }
                .style("stroke-width", 1)
                .style("fill", function(d) {  return findTaskTypeShape(d.label).color; });

但我得到錯(cuò)誤 Property 'typeSymbol' does not exist on type '{}' for code .type(function(d){ return d.typeSymbol}).d 似乎在 type() 中不可用,因?yàn)樗?d3.svg.symbol() 代碼中使用.如果我用square"之類的字符串文字替換匿名函數(shù),它就可以工作.

But I get the error Property 'typeSymbol' does not exist on type '{}' for the code .type( function(d){ return d.typeSymbol}). It appears that d is not available inside type() because it's being used in the d3.svg.symbol() code. If I replace the anonymous function with a string literal like "square", it works.

如何解決這個(gè)問(wèn)題?

推薦答案

Typescript 對(duì)您的數(shù)據(jù)對(duì)象類型一無(wú)所知.您可以定義數(shù)據(jù)對(duì)象類型,也可以嘗試使用任何類型:

Typescript does not know anything about your data object type. You can define the data object type or you could try to use the type any:

milestoneSymbols.attr('d', d3.svg.symbol() 
                            .size(25) 
                            .type( function(d: any){ return d.typeSymbol;})

這篇關(guān)于“類型 {} 上不存在屬性"使用帶有 D3 SVG 符號(hào)的匿名函數(shù)時(shí)出錯(cuò)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機(jī)器人提及發(fā)出該機(jī)器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復(fù)必須使用導(dǎo)入來(lái)加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來(lái)自特定服務(wù)器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復(fù)“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務(wù)器時(shí)的歡迎消息)
主站蜘蛛池模板: 日本久久久久久久久 | av黄色在线观看 | 韩日一区二区三区 | 国产精品入口久久 | 国产精品久久久久一区二区三区 | 日本三级在线视频 | 韩国av一区二区 | 亚洲精品二区 | 国产黄色网址在线观看 | 在线欧美一区 | 免费视频中文字幕 | 国产精品污www在线观看 | 久久久久国产一区二区三区不卡 | 日日摸日日碰夜夜爽亚洲精品蜜乳 | 狠狠入ady亚洲精品经典电影 | 久久精品欧美一区二区三区不卡 | 91黄在线观看 | 国产在线中文字幕 | 久久精品av麻豆的观看方式 | 国产美女自拍视频 | 99福利网| 色婷婷久久 | 日韩和的一区二区 | 色屁屁在线观看 | 久久久美女 | 男女免费观看在线爽爽爽视频 | 精品国产乱码久久久久久88av | 九九99靖品 | 一级特黄a大片 | 国产精品污污视频 | 中文字幕一区二区三区四区 | 天天操天天射天天舔 | 免费黄色在线 | 精品欧美乱码久久久久久1区2区 | 日韩视频中文字幕 | 欧美精品91| 欧美一级大片 | 97超碰中文网 | 亚洲精品一区二区冲田杏梨 | 午夜黄色影院 | 国产精品久久久久久久久久久久久久 |