新聞中心
timeline.label | Object
設置 ECharts 時間軸的文本標簽。

創(chuàng)新互聯(lián)建站堅持“要么做到,要么別承諾”的工作理念,服務領域包括:網站設計、做網站、企業(yè)官網、英文網站、手機端網站、網站推廣等服務,滿足客戶于互聯(lián)網時代的侯馬網站設計、移動媒體設計的需求,幫助企業(yè)找到有效的互聯(lián)網解決方案。努力成為您成熟可靠的網絡建設合作伙伴!
ECharts 時間軸文本標簽的狀態(tài)有兩個: normal 和 emphasis。normal 是文本正常的樣式,emphasis 是文本高亮的樣式,比如鼠標懸浮或者圖例聯(lián)動高亮的時候會使用 emphasis 作為文本的樣式。
timeline.label.normal | Object
在 normal 狀態(tài)下設置 ECharts 時間軸文本標簽。
timeline.label.normal.position | string, number
[ default: 'auto' ]
時間軸文本標簽的位置。
可選的配置方式:
- 'auto': 完全自動決定。
- 'left': 貼左邊界放置。 當 timline.orient 為 'vertical' 時有效。
- 'right':當 timline.orient 為 'vertical' 時有效。 貼右邊界放置。
- 'top': 貼上邊界放置。 當 timline.orient 為 'horizontal' 時有效。
- 'bottom': 貼下邊界放置。 當 timline.orient 為 'horizontal' 時有效。
- number: 指定某個數(shù)值時,表示 label 和軸的距離。為 0 時則和坐標軸重合,可以為正負值,決定 label 在坐標軸的哪一邊。
timeline.label.normal.show | boolean
[ default: true ]
是否顯示 label。
timeline.label.normal.interval | string, number
[ default: 'auto' ]
label 的間隔。當指定為數(shù)值時,例如指定為 2,則每隔兩個顯示一個 label。
timeline.label.normal.rotate | prefix
[ default: 0 ]
label 的旋轉角度。正值表示逆時針旋轉。
timeline.label.normal.formatter | string, Function
[ default: null ]
刻度標簽的內容格式器,支持字符串模板和回調函數(shù)兩種形式。
示例:
// 使用字符串模板,模板變量為刻度默認標簽 {value}
formatter: '{value} kg'
// 使用函數(shù)模板,函數(shù)參數(shù)分別為刻度數(shù)值(類目),刻度的索引
formatter: function (value, index) {
// 格式化成月/日,只在第一個刻度顯示年份
var date = new Date(value);
var texts = [(date.getMonth() + 1), date.getDate()];
if (index === 0) {
texts.unshift(date.getYear());
}
return texts.join('/');
}
timeline.label.normal.color | Color
[ default: '#304654' ]
timeline.lable.normal文字的顏色。
timeline.label.normal.fontStyle | string
[ default: 'normal' ]
timeline.lable.normal文字字體的風格
可選:
- 'normal'
- 'italic'
- 'oblique'
timeline.label.normal.fontWeight | string
[ default: normal ]
timeline.lable.normal文字字體的粗細
可選:
- 'normal'
- 'bold'
- 'bolder'
- 'lighter'
- 100 | 200 | 300 | 400...
timeline.label.normal.fontFamily | string
[ default: 'sans-serif' ]
timeline.lable.normal文字的字體系列
還可以是 'serif' , 'monospace', 'Arial', 'Courier New', 'Microsoft YaHei', ...
timeline.label.normal.fontSize | number
[ default: 12 ]
timeline.lable.normal文字的字體大小
timeline.label.normal.align | string
文字水平對齊方式,默認自動。
可選:
- 'left'
- 'center'
- 'right'
rich 中如果沒有設置 align,則會取父層級的 align。例如:
{
align: right,
rich: {
a: {
// 沒有設置 `align`,則 `align` 為 right
}
}
}
timeline.label.normal.verticalAlign | string
文字垂直對齊方式,默認自動。
可選:
- 'top'
- 'middle'
- 'bottom'
rich 中如果沒有設置 verticalAlign,則會取父層級的 verticalAlign。例如:
{
verticalAlign: bottom,
rich: {
a: {
// 沒有設置 `verticalAlign`,則 `verticalAlign` 為 bottom
}
}
}
timeline.label.normal.lineHeight | number
時間軸文本標簽的行高。
rich 中如果沒有設置 lineHeight,則會取父層級的 lineHeight。例如:
{
lineHeight: 56,
rich: {
a: {
// 沒有設置 `lineHeight`,則 `lineHeight` 為 56
}
}
}
timeline.label.normal.backgroundColor | string, Object
[ default: 'transparent' ]
文字塊背景色。
可以是直接的顏色值,例如:'#123234', 'red', rgba(0,23,11,0.3)'。
可以支持使用圖片,例如:
backgroundColor: {
image: 'xxx/xxx.png'
// 這里可以是圖片的 URL,
// 或者圖片的 dataURI,
// 或者 HTMLImageElement 對象,
// 或者 HTMLCanvasElement 對象。
}當使用圖片的時候,可以使用 width 或 height 指定高寬,也可以不指定自適應。
timeline.label.normal.borderColor | string
[ default: 'transparent' ]
文字塊邊框顏色。
timeline.label.normal.borderWidth | number
[ default: 0 ]
文字塊邊框寬度。
timeline.label.normal.borderRadius | number, Array
[ default: 0 ]
文字塊的圓角。
timeline.label.normal.padding | number, Array
[ default: 0 ]
文字塊的內邊距。例如:
- padding: [3, 4, 5, 6]:表示 [上, 右, 下, 左] 的邊距。
- padding: 4:表示 padding: [4, 4, 4, 4]。
- padding: [3, 4]:表示 padding: [3, 4, 3, 4]。
注意,文字塊的 width 和 height 指定的是內容高寬,不包含 padding。
timeline.label.normal.shadowColor | string
[ default: 'transparent' ]
文字塊的背景陰影顏色。
timeline.label.normal.shadowBlur | number
[ default: 0 ]
文字塊的背景陰影長度。
timeline.label.normal.shadowOffsetX | number
[ default: 0 ]
文字塊的背景陰影 X 偏移。
timeline.label.normal.shadowOffsetY | number
[ default: 0 ]
文字塊的背景陰影 Y 偏移。
timeline.label.normal.width | number, string
文字塊的寬度。一般不用指定,不指定則自動是文字的寬度。在想做表格項或者使用圖片(參見 backgroundColor)時,可能會使用它。
注意,文字塊的 width 和 height 指定的是內容高寬,不包含 padding。width 也可以是百分比字符串,如 '100%'。表示的是所在文本塊的 contentWidth(即不包含文本塊的 padding)的百分之多少。之所以以 contentWidth 做基數(shù),因為每個文本片段只能基于 content box 布局。如果以 outerWidth 做基數(shù),則百分比的計算在實用中不具有意義,可能會超出。
注意,如果不定義 rich 屬性,則不能指定 width 和 height。
timeline.label.normal.height | number, string
文字塊的高度。一般不用指定,不指定則自動是文字的高度。在使用圖片(參見 backgroundColor)時,可能會使用它。
注意,文字塊的 width 和 height 指定的是內容高寬,不包含 padding。
注意,如果不定義 rich 屬性,則不能指定 width 和 height。
timeline.label.normal.textBorderColor | string
[ default: 'transparent' ]
文字本身的描邊顏色。
timeline.label.normal.textBorderWidth | number
[ default: 0 ]
文字本身的描邊寬度。
timeline.label.normal.textShadowColor | string
[ default: 'transparent' ]
文字本身的陰影顏色。
timeline.label.normal.textShadowBlur | number
[ default: 0 ]
文字本身的陰影長度。
timeline.label.normal.textShadowOffsetX | number
[ default: 0 ]
文字本身的陰影 X 偏移。
timeline.label.normal.textShadowOffsetY | number
[ default: 0 ]
文字本身的陰影 Y 偏移。
timeline.label.normal.rich | Object
在 rich 里面,可以自定義富文本樣式。利用富文本樣式,可以在標簽中做出非常豐富的效果。
例如:
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
},
...
}
}
}詳情參見教程:富文本標簽
timeline.label.emphasis | Object
在 emphasis 狀態(tài)下設置 ECharts 時間軸文本標簽。
timeline.label.emphasis.show | boolean
[ default: true ]
是否顯示 label。
timeline.label.emphasis.interval | string, number
[ default: 'auto' ]
label 的間隔。當指定為數(shù)值時,例如指定為 2,則每隔兩個顯示一個 label。
timeline.label.emphasis.rotate | prefix
[ default: 0 ]
label 的旋轉角度。正值表示逆時針旋轉。
timeline.label.emphasis.formatter | string, Function
[ default: null ]
刻度標簽的內容格式器,支持字符串模板和回調函數(shù)兩種形式。
示例:
// 使用字符串模板,模板變量為刻度默認標簽 {value}
formatter: '{value} kg'
// 使用函數(shù)模板,函數(shù)參數(shù)分別為刻度數(shù)值(類目),刻度的索引
formatter: function (value, index) {
// 格式化成月/日,只在第一個刻度顯示年份
var date = new Date(value);
var texts = [(date.getMonth() + 1), date.getDate()];
if (index === 0) {
texts.unshift(date.getYear());
}
return texts.join('/');
}
timeline.label.emphasis.color | Color
[ default: '#c23531' ]
timeline.lable.emphasis文字的顏色。
timeline.label.emphasis.fontStyle | string
[ default: 'normal' ]
timeline.lable.emphasis文字字體的風格
可選:
- 'normal'
- 'italic'
- 'oblique'
timeline.label.emphasis.fontWeight | string
[ default: normal ]
timeline.lable.emphasis文字字體的粗細
可選:
- 'normal'
- 'bold'
- 'bolder'
- 'lighter'
- 100 | 200 | 300 | 400...
timeline.label.emphasis.fontFamily | string
[ default: 'sans-serif' ]
timeline.lable.emphasis文字的字體系列
還可以是 'serif' , 'monospace', 'Arial', 'Courier New', 'Microsoft YaHei', ...
timeline.label.emphasis.fontSize | number
[ default: 12 ]
timeline.lable.emphasis文字的字體大小
timeline.label.emphasis.align | string
文字水平對齊方式,默認自動。
可選:
- 'left'
- 'center'
- 'right'
rich 中如果沒有設置 align,則會取父層級的 align。例如:
{
align: right,
rich: {
a: {
// 沒有設置 `align`,則 `align` 為 right
}
}
}
timeline.label.emphasis.verticalAlign | string
文字垂直對齊方式,默認自動。
可選:
- 'top'
- 'middle'
- 'bottom'
rich 中如果沒有設置 verticalAlign,則會取父層級的 verticalAlign。例如:
{
verticalAlign: bottom,
rich: {
a: {
// 沒有設置 `verticalAlign`,則 `verticalAlign` 為 bottom
}
}
}
timeline.label.emphasis.lineHeight | number
emphasis 狀態(tài)下時間軸文本標簽的行高。
rich 中如果沒有設置 lineHeight,則會取父層級的 lineHeight。例如:
{
lineHeight: 56,
rich: {
a: {
// 沒有設置 `lineHeight`,則 `lineHeight` 為 56
}
}
}
timeline.label.emphasis.backgroundColor | string, Object
[ default: 'transparent' ]
文字塊背景色。
可以是直接的顏色值,例如:'#123234', 'red', rgba(0,23,11,0.3)'。
可以支持使用圖片,例如:
backgroundColor: {
image: 'xxx/xxx.png'
// 這里可以是圖片的 URL,
// 或者圖片的 dataURI,
// 或者 HTMLImageElement 對象,
// 或者 HTMLCanvasElement 對象。
}當使用圖片的時候,可以使用 width 或 height 指定高寬,也可以不指定自適應。
timeline.label.emphasis.borderColor | string
[ default: 'transparent' ]
文字塊邊框顏色。
timeline.label.emphasis.borderWidth | number
[ default: 0 ]
文字塊邊框寬度。
timeline.label.emphasis.borderRadius | number, Array
[ default: 0 ]
文字塊的圓角。
timeline.label.emphasis.padding | number, Array
[ default: 0 ]
文字塊的內邊距。例如:
- padding: [3, 4, 5, 6]:表示 [上, 右, 下, 左] 的邊距。
- padding: 4:表示 padding: [4, 4, 4, 4]。
- padding: [3, 4]:表示 padding: [3, 4, 3, 4]。
注意,文字塊的 width 和 height 指定的是內容高寬,不包含 padding。
timeline.label.emphasis.shadowColor | string
[ default: 'transparent' ]
文字塊的背景陰影顏色。
timeline.label.emphasis.shadowBlur | number
[ default: 0 ]
文字塊的背景陰影長度。
timeline.label.emphasis.shadowOffsetX | number
[ default: 0 ]
文字塊的背景陰影 X 偏移。
timeline.label.emphasis.shadowOffsetY | number
[ default: 0 ]
文字塊的背景陰影 Y 偏移。
timeline.label.emphasis.width | number, string
文字塊的寬度。一般不用指定,不指定則自動是文字的寬度。在想做表格項或者使用圖片(參見 backgroundColor)時,可能會使用它。
注意,文字塊的 width 和 height 指定的是內容高寬,不包含 padding。width 也可以是百分比字符串,如 '100%'。表示的是所在文本塊的 contentWidth(即不包含文本塊的 padding)的百分之多少。之所以以 contentWidth 做基數(shù),因為每個文本片段只能基于 content box 布局。如果以 outerWidth 做基數(shù),則百分比的計算在實用中不具有意義,可能會超出。
注意,如果不定義 rich 屬性,則不能指定 width 和 height。
timeline.label.emphasis.height | number, string
文字塊的高度。一般不用指定,不指定則自動是文字的高度。在使用圖片(參見 backgroundColor)時,可能會使用它。
注意,文字塊的 width 和 height 指定的是內容高寬,不包含 padding。
注意,如果不定義 rich 屬性,則不能指定 width 和 height。
timeline.label.emphasis.textBorderColor | string
[ default: 'transparent' ]
文字本身的描邊顏色。
timeline.label.emphasis.textBorderWidth | number
[ default: 0 ]
文字本身的描邊寬度。
timeline.label.emphasis.textShadowColor | string
[ default: 'transparent' ]
文字本身的陰影顏色。
timeline.label.emphasis.textShadowBlur | number
[ default: 0 ]
文字本身的陰影長度。
timeline.label.emphasis.textShadowOffsetX | number
[ default: 0 ]
文字本身的陰影 X 偏移。
timeline.label.emphasis.textShadowOffsetY | number
[ default: 0 ]
文字本身的陰影 Y 偏移。
timeline.label.emphasis.rich | Object
在 rich 里面,可以自定義富文本樣式。利用富文本樣式,可以在標簽中做出非常豐富的效果。
例如:
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
},
...
}
}
}詳情參見教程:富文本標簽
新聞名稱:創(chuàng)新互聯(lián)ECharts教程:設置ECharts時間軸的文本標簽
文章地址:http://m.fisionsoft.com.cn/article/cddpsph.html


咨詢
建站咨詢
