翻譯|使用教程|編輯:龔雪|2023-05-16 10:20:28.417|閱讀 120 次
概述:本文將為大家介紹界面控件DevExtreme如何完成雷達圖表的注釋操作,歡迎下載最新版體驗~
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
在之前的版本中,官方技術團隊為DevExtreme圖表引入了注釋支持。在v20.1版本中,繼續擴展了對Polar Chart(雷達圖)注釋的支持,現在可以根據需要應用文本、圖像或自定義注釋。創建注釋后,可以將其附加到Polar Chart(雷達圖)元素(例如一個序列點)或在特定坐標上顯示它。
DevExtreme擁有高性能的HTML5 / JavaScript小部件集合,使您可以利用現代Web開發堆棧(包括React,Angular,ASP.NET Core,jQuery,Knockout等)構建交互式的Web應用程序,該套件附帶功能齊全的數據網格、交互式圖表小部件、數據編輯器等。
本文中描述的新功能可以在DevExtreme支持的所有平臺上使用,包括Angular, Vue, React, jQuery,ASP. NET MVC和ASP. NET Core。
DevExpress技術交流群8:523159565 歡迎一起進群討論
要在Polar Chart(雷達圖)中顯示注釋,請使用新的“annotations”選項(接受一個表示單個注釋的配置對象數組),每個對象都包含一個type屬性。支持的注釋類型包括' image ', ' text '和' custom ',根據所需的注釋類型,您的配置對象必須指定' image ', ' text '或' template '。
下面的示例列出了所有支持的注釋類型:
<dx-polar-chart> … <dxi-annotation image="http://sun.png " type="image" argument="July" series="Day"> </dxi-annotation> <dxi-annotation text="Custom text" type="text" [radius]="100" [angle]="45"> </dxi-annotation> <dxi-annotation template="template" type="custom" argument="October" [value]="17"> </dxi-annotation> <svg *dxTemplate="let annotation of 'template'"> <image attr. width="60" height="40" /> <text x="8" y="60" >and text</text> </svg> </dx-polar-chart>
上述配置生成如下可視化:
用戶可以將注釋附加到Polar Chart(雷達圖) UI元素上,也可以不將其固定在絕對坐標上,讓我們回顧一下與位置相關的選擇:
在下面的示例中,注釋沒有連接到任何Polar Chart(雷達圖) UI元素,它們使用絕對坐標。
annotations: [{ x: 350, y: 140 }, { angle: -100, radius: 150 }]
annotations: [{ argument: "February", value: 7 }]
annotations: [{ argument: "March", series: "Series 1" }]
annotations: [{ argument: "May" }, { value: 15 }]
在這個示例中,像素和圖表坐標同時使用:
annotations: [{ argument: "May", y: 320 }, { value: 15, x: 600 }]
要為所有注釋指定通用選項,使用'commonAnnotationsSettings '選項,下面的代碼示例為Polar Chart(雷達圖)上的所有注釋應用背景和字體顏色(使用Angular標記):
<dx-common-annotation-settings color="#5258c7"> <dxo-font color="#ffffff"></dxo-font> </dx-common-annotation-settings>
Polar Chart(雷達圖)組件允許您通過' customizeAnnotation '回調函數定制單個注釋,這可以幫助那些希望從遠程數據服務獲得注釋數組的人。在下面的例子中,我們為屬于“DayTemperature”系列的注釋指定了一個背景顏色:
// app.component.html <dx-polar-chart ... customizeAnnotation: "customizeAnnotation"> <dxi-annotation ... series="DayTemperature" text="Custom text 1"> </dxi-annotation> <dxi-annotation ... text="Custom text 2"> </dxi-annotation> <dxi-annotation ... text="Custom text 3"> </dxi-annotation> <dxi-annotation ... series="DayTemperature" text="Custom text 4"> </dxi-annotation> </dx-polar-chart> // app.component.ts //... export class AppComponent { customizeAnnotation(item) { if (item.series === "DayTemperature") { item.color = "#5258c7"; item.font = { color: "#ffffff" }; } return item; } }
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都網