新聞中心
xAxis.data[i].textStyle.rich | Object
在 xAxis 的 rich 里面,您可以對其富文本樣式進行自定義。

讓客戶滿意是我們工作的目標,不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領域值得信任、有價值的長期合作伙伴,公司提供的服務項目有:國際域名空間、雅安服務器托管、營銷軟件、網(wǎng)站建設、邗江網(wǎng)站維護、網(wǎng)站推廣。
在標簽中,很多豐富的效果都是通過利用富文本樣式得到的。
例如下面的一段代碼:
label: {
normal: {
// 在文本中,可以對部分文本采用 rich 中定義樣式。
// 這里需要在文本中使用標記符號:
// `{styleName|text content text content}` 標記樣式名。
// 注意,換行仍是使用 '\n'。
formatter: [
'{a|這段文本采用樣式a}',
'{b|這段文本采用樣式b}這段用默認樣式{x|這段用樣式x}'
].join('\n'),
rich: {
a: {
color: 'red',
lineHeight: 10
},
b: {
backgroundColor: {
image: 'xxx/xxx.jpg'
},
height: 40
},
x: {
fontSize: 18,
fontFamily: 'Microsoft YaHei',
borderColor: '#449933',
borderRadius: 4
},
...
}
}
}詳情參見教程:富文本標簽
xAxis.data[i].textStyle.rich. | Object
用戶可以自定義富文本標簽的樣式(樣式的名字由用戶自行獲?。?/p>
xAxis.data[i].textStyle.rich..color | Color
[ default: "#fff" ]
用戶對 xAxis 中富文本標簽的文字顏色進行設置。
xAxis.data[i].textStyle.rich..fontStyle | string
[ default: 'normal' ]
用戶對 xAxis 中富文本標簽的文字字體風格進行設置。
可供選擇的類型:
- 'normal'
- 'italic'
- 'oblique'
xAxis.data[i].textStyle.rich..fontWeight | string
[ default: normal ]
設置富文本標簽文字字體的粗細。
可以選擇的類型:
- 'normal'
- 'bold'
- 'bolder'
- 'lighter'
- 100 | 200 | 300 | 400...
xAxis.data[i].textStyle.rich..fontFamily | string
[ default: 'sans-serif' ]
設置富文本標簽文字的字體系列
富文本標簽中的字體類型還可以是: 'serif' , 'monospace', 'Arial', 'Courier New', 'Microsoft YaHei', ...
xAxis.data[i].textStyle.rich..fontSize | number
[ default: 12 ]
設置富文本標簽中文字的字體大小
xAxis.data[i].textStyle.rich..align | string
富文本標簽中文字水平對齊方式的設置,默認情況下是自動的。
可以選擇:
- 'left'
- 'center'
- 'right'
但是 rich 中如果沒有設置 align,則會取父層級的 align。
例如:
{
align: right,
rich: {
a: {
// 沒有設置 `align`,則 `align` 為 right
}
}
}xAxis.data[i].textStyle.rich..verticalAlign | string
設置富文本標簽文字的垂直對齊方式,默認自動。
可以選擇的類型:
- 'top'
- 'middle'
- 'bottom'
rich 中如果沒有設置 verticalAlign,則會取父層級的 verticalAlign。
例如:
{
verticalAlign: bottom,
rich: {
a: {
// 沒有設置 `verticalAlign`,則 `verticalAlign` 為 bottom
}
}
}xAxis.data[i].textStyle.rich..lineHeight | number
行高。
rich 中如果沒有設置 lineHeight,則會取父層級的 lineHeight。例如:
{
lineHeight: 56,
rich: {
a: {
// 沒有設置 `lineHeight`,則 `lineHeight` 為 56
}
}
}xAxis.data[i].textStyle.rich..backgroundColor | string, Object
[ default: 'transparent' ]
設置富文本標簽中文字塊的背景色。
此處的顏色值可以直接列出,例如:'#123234', 'red', rgba(0,23,11,0.3)'。
當然,也支持使用圖片,例如:
backgroundColor: {
image: 'xxx/xxx.png'
// 這里可以是圖片的 URL,
// 或者圖片的 dataURI,
// 或者 HTMLImageElement 對象,
// 或者 HTMLCanvasElement 對象。
}當使用圖片的時候,可以使用 width 或 height 指定高寬,也可以不指定,讓其自適應。xAxis.data[i].textStyle.rich..borderColor | string
[ default: 'transparent' ]
對 xAxis 中富文本標簽的文字塊邊框顏色進行設置。
xAxis.data[i].textStyle.rich..borderWidth | number
[ default: 0 ]
設置富文本標簽的文字塊邊框?qū)挾取?/p>
xAxis.data[i].textStyle.rich..borderRadius | number, Array
[ default: 0 ]
設置富文本標簽的文字塊圓角。
xAxis.data[i].textStyle.rich..padding | number, Array
[ default: 0 ]
設置富文本標簽文字塊的內(nèi)邊距。例如:
- padding: [3, 4, 5, 6]:表示 [上, 右, 下, 左] 的邊距。
- padding: 4 :表示 padding: [4, 4, 4, 4]。
- padding: [3, 4]:表示 padding: [3, 4, 3, 4]。
注意,文字塊的 width 和 height 指定的是內(nèi)容高寬,不包含 padding。xAxis.data[i].textStyle.rich..shadowColor | string
[ default: 'transparent' ]
設置富文本標簽文字塊的背景陰影顏色。
xAxis.data[i].textStyle.rich..shadowBlur | number
[ default: 0 ]
設置富文本標簽文字塊的背景陰影長度。
xAxis.data[i].textStyle.rich..shadowOffsetX | number
[ default: 0 ]
設置富文本標簽文字塊的背景陰影 X 偏移量。
xAxis.data[i].textStyle.rich..shadowOffsetY | number
[ default: 0 ]
設置富文本標簽文字塊的背景陰影 Y 偏移量。
xAxis.data[i].textStyle.rich..width | number, string
設置富文本標簽文字塊的寬度。
一般情況下不用指定,不指定則默認為文字的寬度。在想做表格項或者使用圖片(參見 backgroundColor)時,可能會使用它。
注意,文字塊的 width 和 height 指定的是內(nèi)容高寬,不包含 padding。width 也可以是百分比字符串,如 '100%',表示的是所在文本塊的 contentWidth(即不包含文本塊的 padding)的百分之多少。之所以以 contentWidth 做基數(shù),因為每個文本片段只能基于 content box 布局。如果以 outerWidth 做基數(shù),則百分比的計算在實用中不具有意義,可能會超出。
注意,如果不定義 rich 屬性,則不能指定 width 和 height。xAxis.data[i].textStyle.rich..height | number, string
設置富文本標簽中文字塊的高度。
一般不用指定,不指定則默認是文字的高度。在使用圖片(參見 backgroundColor)時,可能會使用它。
注意,文字塊的 width 和 height 指定的是內(nèi)容高寬,不包含 padding。
注意,如果不定義 rich 屬性,則不能指定 width 和 height。
xAxis.data[i].textStyle.rich..textBorderColor | string
[ default: 'transparent' ]
對 xAxis 中富文本標簽文字本身的描邊顏色進行設置。
xAxis.data[i].textStyle.rich..textBorderWidth | number
[ default: 0 ]
設置富文本標簽的文字本身的描邊寬度。
xAxis.data[i].textStyle.rich..textShadowColor | string
[ default: 'transparent' ]
設置富文本標簽的文字本身的陰影顏色。
xAxis.data[i].textStyle.rich..textShadowBlur | number
[ default: 0 ]
設置富文本標簽的文字本身的陰影長度。
xAxis.data[i].textStyle.rich..textShadowOffsetX | number
[ default: 0 ]
設置富文本標簽的文字本身的陰影 X 偏移。
xAxis.data[i].textStyle.rich..textShadowOffsetY | number
[ default: 0 ]
設置富文本標簽的文字本身的陰影 Y 偏移。
分享名稱:創(chuàng)新互聯(lián)ECharts教程:ECharts xAxis配置 類目標簽的富文本樣式
標題來源:http://fisionsoft.com.cn/article/cdojecp.html


咨詢
建站咨詢
