- 时间:2022-08-24 01:55 编辑: 来源: 阅读:289
- 扫一扫,手机访问
摘要:Echarts将图片添加到直方图轴。
《php源码》
在少量的直方图数据中,如天气数据、男女比例等。,在轴上添加图片可以更直观的查看数据。 效果图:image.png/* * *绘制直方图,轴上有图片* @param container容器* @param seriesData图表数据*/函数绘制图像栏(container,series data){ var myCharts = echarts . init(document . getelementbyid(container));var myOption = { color: ['#7473FF'],grid : { left : '4% ',right : '4% ',Bottom: '4% ',top: 30,//图形位置包含坐标轴的刻度标签。//如果调整了图形位置但不包含坐标轴,轴信息会显示不完整containLabel: true},xAxis: { axisLine : { show : false },splitLine : { show : true,line style:{ color:# 1d 3039 ' } },type: 'value ',min: 0,max: 100,Axis label:' { value } ' },},yAxis: { type: 'category ',data: ['woman ',' man'],//y轴样式axisLine : { show : false },//设置线平行于},margin: 20,rich: { value: { lineHeight: 30,align: 'center ',color: 'white' },woman: { height: 40,align: 'center ',backgroundColor:'。/img/woman.png' } },男:{ height: 40,align: 'center ',backgroundColor: { image:'。/img/man.png' } } },series: [ { type: 'bar ',barWidth: '20 ',data: seriesData,//直方图描述信息样式标签:{normal: {show: true,position: 'right ',distance: 20,color: 'white ',backgroundColor: '#7473FF ',padding: 5,borderRadius: 10 } },}]};my charts . setoption(my option);}调用方法:varseriesdata = [{value: 55},{ value:45 }];drawImageBar('bar ',series data);yAxis中有丰富的设置,可以设置y轴的显示方式,比如添加图片等。 剩下的,在系列标签设置中,你可以设置直方图文本描述的样式。