原創(chuàng)|其它|編輯:郝浩|2012-11-29 14:56:02.000|閱讀 928 次
概述:AnyChart閾值主要根據(jù)一些預(yù)先定義的條件,用于顏色圖表元素,讓你的數(shù)據(jù)輸出可視化。本文介紹了閾值的創(chuàng)建和設(shè)置方法,以及在標(biāo)簽和Tooltips中使用閾值的實例。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
閾值主要根據(jù)一些預(yù)先定義的條件,用于顏色圖表元素,讓你的數(shù)據(jù)輸出可視化。
若要創(chuàng)建閾需要在 <chart>節(jié)點里創(chuàng)建 <thresholds>節(jié)點,并在地方一個或幾個條件命名閾值:
<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的值將會被顯示為紅色,所有的負(fù)值,將會被顯示為藍(lán)色。就如你所看見的,你可以在value_1、value_2 、value_3中使用關(guān)鍵字,你可以使用在本文的末尾找到的關(guān)鍵字屬性完整列表。
還可以使用{%customattributename}自定義屬性值。
在下面的示例中,我們將創(chuàng)建柱形圖來顯示當(dāng)月不同經(jīng)理的銷售額,小于10.000的將會用暗紅色表示,從10.000到20.000的將會又能夠金色表示,大于20.000的將會用綠色表示,tooltip將會顯示銷售數(shù)據(jù)和評估。
這里有8種條件類型,下面的表格中就是浙西條件類型和相關(guān)的描述:
一旦定義了閾值,你就可以將它們應(yīng)用到圖表上所有的數(shù)據(jù)上或數(shù)據(jù)列,想要實現(xiàn)這一點,是需要設(shè)置一下閾值屬性的<data>或<series>節(jié)點,現(xiàn)在就來看看AnyChart閾值應(yīng)用。
<data threshold="Threshold1"> <series name="Series1" threshold="Threshold2"> </series> <series name="Series2"> </series> </data>
你可以將任何的數(shù)據(jù)添加到條件上邊來使用這些在標(biāo)簽上或tooltip上的數(shù)據(jù),比如說,你可以描述一個條件,然后將這個條件放在標(biāo)簽里面。
為了添加自定義屬性到條件,需要在<condition>中創(chuàng)建<attribute>節(jié)點,并將一些<attribute>節(jié)點放在你需要的地方。
<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>
在下面的示例中,將會看見顯示發(fā)動機溫度的區(qū)域圖,使用閾值,標(biāo)簽和tooltip來定義閾值的顏色,閾值使用描述和細(xì)節(jié)閾值條件的自定義屬性。
可以按照下面的代碼自定義條件屬性:
<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>
在標(biāo)簽中設(shè)置使用的條件數(shù)據(jù):
label_settings enabled="true" rotation="90"> <format>{%ConditionDescription}</format> </label_settings>
在tootip中顯示腳本
<tooltip_settings enabled="true">
<format>Temp: {%YValue}
{%ConditionDescription} {%ConditionDetails}</format>
</tooltip_settings>
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@ke049m.cn
文章轉(zhuǎn)載自:慧都控件