Commit 2f196a23 by 匡雅琴

样式调整

1 parent 94c9e556
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</div> </div>
</div> </div>
<div class="container"> <div class="container">
<BarChart domId="analyseChart" :revese="true" boxHeight="14.54vh" :analysisList="analysisList"></BarChart> <BarChart domId="analyseChart" :revese="true" boxHeight="14.54vh" :analysisList="analysisList" :colorList="colorList"></BarChart>
</div> </div>
</div> </div>
</template> </template>
...@@ -31,7 +31,8 @@ export default { ...@@ -31,7 +31,8 @@ export default {
data() { data() {
return { return {
analysisList: {}, analysisList: {},
isShow: true isShow: true,
colorList: ['#5C56FF', '#22D8FF']
} }
}, },
mounted() { mounted() {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<span>区域分布</span> <span>区域分布</span>
</div> </div>
<div class="container"> <div class="container">
<BarChart domId="areaChart" :analysisList="areaList"></BarChart> <BarChart domId="areaChart" :analysisList="areaList" :colorList="colorList"></BarChart>
</div> </div>
</div> </div>
</template> </template>
...@@ -17,7 +17,9 @@ export default { ...@@ -17,7 +17,9 @@ export default {
BarChart BarChart
}, },
data() { data() {
return {} return {
colorList: ['#22D8FF', '#223FA9', '#071735']
}
}, },
props: { props: {
areaList: { areaList: {
......
...@@ -50,6 +50,9 @@ export default { ...@@ -50,6 +50,9 @@ export default {
type: Number, type: Number,
default: 0 default: 0
}, },
colorList: {
type: Array
},
tooltipFormatterObj: { tooltipFormatterObj: {
type: Array, type: Array,
default: () => { default: () => {
...@@ -103,13 +106,13 @@ export default { ...@@ -103,13 +106,13 @@ export default {
watch: { watch: {
analysisList: { analysisList: {
handler() { handler() {
const { rotate, analysisList } = this const { rotate, analysisList, colorList } = this
const obj = { const obj = {
rotate, rotate,
analysisList, analysisList,
ValueAnalysis ValueAnalysis
} }
this.lineOptions = this.revese ? getBarReverseOptions(obj) : getBarOptions(obj) this.lineOptions = this.revese ? getBarReverseOptions(obj, colorList) : getBarOptions(obj, colorList)
this.chartBindEvent() this.chartBindEvent()
}, },
deep: true deep: true
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<span>品牌分布</span> <span>品牌分布</span>
</div> </div>
<div class="container"> <div class="container">
<BarChart domId="brandChart" :rotate="30" :analysisList="brandList"></BarChart> <BarChart domId="brandChart" :rotate="30" :analysisList="brandList" :colorList="colorList"></BarChart>
</div> </div>
</div> </div>
</template> </template>
...@@ -17,7 +17,9 @@ export default { ...@@ -17,7 +17,9 @@ export default {
BarChart BarChart
}, },
data() { data() {
return {} return {
colorList: ['#2AD191', '#0E958D', '#071735']
}
}, },
props: { props: {
brandList: { brandList: {
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
* @FilePath: \dj-data-view\src\components\barOptions.js * @FilePath: \dj-data-view\src\components\barOptions.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
import * as echarts from 'echarts'
import utils from '../../../utils/util' import utils from '../../../utils/util'
function getBarOptions(obj) { function getBarOptions(obj, colorList) {
const { analysisList, rotate } = obj const { analysisList, rotate } = obj
const num = analysisList.map(item => item.ratio * 100) const num = analysisList.map(item => item.ratio * 100)
console.log(num)
const name = analysisList.map(item => item.name) const name = analysisList.map(item => item.name)
var options = { var options = {
xAxis: { xAxis: {
...@@ -56,8 +56,28 @@ function getBarOptions(obj) { ...@@ -56,8 +56,28 @@ function getBarOptions(obj) {
{ {
type: 'bar', type: 'bar',
symbol: 'circle', symbol: 'circle',
backgroundStyle: { // backgroundStyle: {
color: '#6578FF' // color: '#6578FF'
// },
itemStyle: {
barBorderRadius: [2, 2, 0, 0], // 柱体圆角
color: function(params) {
// var colorItem = []
return new echarts.graphic.LinearGradient(
0, 0, 0, 1, [{ // 代表渐变色从正上方开始
offset: 0, // offset范围是0~1,用于表示位置,0是指0%处的颜色
color: colorList[0]
}, // 柱图渐变色
{
offset: 0.5, // 指100%处的颜色
color: colorList[1]
},
{
offset: 1, // 指100%处的颜色
color: colorList[2]
}]
)
}
}, },
barWidth: '35%', barWidth: '35%',
data: num data: num
...@@ -66,7 +86,7 @@ function getBarOptions(obj) { ...@@ -66,7 +86,7 @@ function getBarOptions(obj) {
} }
return options return options
} }
function getBarReverseOptions(obj) { function getBarReverseOptions(obj, colorList) {
const { analysisList, ValueAnalysis } = obj const { analysisList, ValueAnalysis } = obj
// const value = Object.values(analysisList) // const value = Object.values(analysisList)
const entries = Object.entries(analysisList) const entries = Object.entries(analysisList)
...@@ -151,6 +171,20 @@ function getBarReverseOptions(obj) { ...@@ -151,6 +171,20 @@ function getBarReverseOptions(obj) {
lineHeight: 16 lineHeight: 16
} }
} }
},
barBorderRadius: [2, 2, 0, 0], // 柱体圆角
color: function(params) {
// var colorItem = []
return new echarts.graphic.LinearGradient(
0, 0, 0, 1, [{ // 代表渐变色从正上方开始
offset: 0, // offset范围是0~1,用于表示位置,0是指0%处的颜色
color: colorList[0]
}, // 柱图渐变色
{
offset: 1, // 指100%处的颜色
color: colorList[1]
}]
)
} }
}, },
data: value.map(item => item.value) data: value.map(item => item.value)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!