原創|其它|編輯:郝浩|2012-11-29 14:56:02.000|閱讀 914 次
概述:AnyChart閾值主要根據一些預先定義的條件,用于顏色圖表元素,讓你的數據輸出可視化。本文介紹了閾值的創建和設置方法,以及在標簽和Tooltips中使用閾值的實例。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
閾值主要根據一些預先定義的條件,用于顏色圖表元素,讓你的數據輸出可視化。
若要創建閾需要在 <chart>節點里創建 <thresholds>節點,并在地方一個或幾個條件命名閾值:
<chart> <thresholds> <threshold name="SampleThreshold"> <condition name="Excellent Rating" type="greaterThanOrEqualTo" value_1="{%YValue}" value_2="10000" color="Red" /> </threshold> </thresholds> </chart>
簡單的定義語法如下:
<threshold name="SampleThreshold"> <condition name="From 100 to 200" type="between" value_1="{%YValue}" value_2="100" value_3="200" color="Red" /> <condition name="Negative" type="lessThen" value_1="{%YValue}" value_2="0" color="Blue" /> </threshold>
在上面的例子中,所有的從100到200的值將會被顯示為紅色,所有的負值,將會被顯示為藍色。就如你所看見的,你可以在value_1、value_2 、value_3中使用關鍵字,你可以使用在本文的末尾找到的關鍵字屬性完整列表。
還可以使用{%customattributename}自定義屬性值。
在下面的示例中,我們將創建柱形圖來顯示當月不同經理的銷售額,小于10.000的將會用暗紅色表示,從10.000到20.000的將會又能夠金色表示,大于20.000的將會用綠色表示,tooltip將會顯示銷售數據和評估。
這里有8種條件類型,下面的表格中就是浙西條件類型和相關的描述:
一旦定義了閾值,你就可以將它們應用到圖表上所有的數據上或數據列,想要實現這一點,是需要設置一下閾值屬性的<data>或<series>節點,現在就來看看AnyChart閾值應用。
<data threshold="Threshold1"> <series name="Series1" threshold="Threshold2"> </series> <series name="Series2"> </series> </data>
你可以將任何的數據添加到條件上邊來使用這些在標簽上或tooltip上的數據,比如說,你可以描述一個條件,然后將這個條件放在標簽里面。
為了添加自定義屬性到條件,需要在<condition>中創建<attribute>節點,并將一些<attribute>節點放在你需要的地方。
<thresholds> <threshold name="TempreatureTreshold"> <condition name="c1" type="lessThanOrEqualTo" value_1="{%YValue]" value_2="127" color="Red"> <attributes> <attribute name="Description">The price is less or equal than 127 - and that is a very dangerous situation!</attribute> </attributes> </condition> <condition name="c2" type="greaterThan" value_1="{%YValue}" value_2="127" color="Yellow"> <attributes> <attribute name="Description">The price is greater than 127 - and that is fine.</attribute> </attributes> </condition> </threshold> </thresholds>
在下面的示例中,將會看見顯示發動機溫度的區域圖,使用閾值,標簽和tooltip來定義閾值的顏色,閾值使用描述和細節閾值條件的自定義屬性。
可以按照下面的代碼自定義條件屬性:
<thresholds> <threshold name="TempreatureTreshold"> <condition name="c1" type="lessThanOrEqualTo" value_1="{%YValue}" value_2="153" color="Black"> <attributes> <attribute name="Description">DANGER!</attribute> <attribute name="Details">The Temprature is less than or equal to 154.</attribute> </attributes> </condition> </threshold> </thresholds>
在標簽中設置使用的條件數據:
label_settings enabled="true" rotation="90"> <format>{%ConditionDescription}</format> </label_settings>
在tootip中顯示腳本
<tooltip_settings enabled="true">
<format>Temp: {%YValue}
{%ConditionDescription} {%ConditionDetails}</format>
</tooltip_settings>
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件