DataGear 自定義數據可視化看板的圖表主題

DataGear看板的dg-chart-theme屬性,提供了簡單且強大的自定義圖表主題功能。html

一般,只須要設置其colorbackgroundColoractualBackgroundColor值便可,看板會根據它們自動生成標題、圖例、提示框、高亮框等相關配色。git

例如,在<body>元素上定義全局圖表配色:url

<body style="background-color: #17336c"
    dg-chart-theme="{
		color:'#FFF',
		backgroundColor:'#17336c',
		borderWidth:'2px'
	}">

對應的效果圖以下:spa

當看板有背景圖片時,一般但願圖表背景色是透明的,此時應設置actualBackgroundColor爲與背景圖片一致的顏色,例如:code

<body style="background-image: url(bg.png)"
    dg-chart-theme="{
		color:'#FFF',
		backgroundColor:'transparent',
		actualBackgroundColor:'#17336c',
		borderWidth:'2px'
	}">

也能夠爲單個圖表<div>元素添加dg-chart-theme屬性,僅定義此圖表的主題,例如:htm

<div dg-chart-widget="..."
	dg-chart-theme="{backgroundColor:'green',color:'yellow'}">
</div>

對應的效果圖以下(第一個圖表):blog

另外,設置dg-chart-themegraphColors值,能夠自定義圖表系列條目顏色序列,設置graphRangeColors值,則能夠定義圖表值域映射顏色(地圖區域顏色),例如:圖片

<body style="background-image: url(bg.png)"
    dg-chart-theme="{
		color:'#FFF',
		backgroundColor:'transparent',
		actualBackgroundColor:'#17336c',
		graphColors: ['#EE7942', '#FFFF00', '#EE1289'],
		graphRangeColors: ['#FFFF00', '#EE7942'],
		borderWidth:'2px'
	}">

對應的效果圖以下:get

官網地址:http://www.datagear.tech源碼

源碼地址:https://gitee.com/datagear/datagear

大屏模板地址:https://gitee.com/datagear/DataGearDashboardTemplate

相關文章
相關標籤/搜索