div做个横向百分比柱状图图

效果图


import React from 'react';
import numeral from 'numeral';
import { Empty } from 'antd';
import './LandscapeType.less'

// CDN START

class LandscapeType extends React.Component {
  render() {
    const { data = [], height = 600 } = this.props
    return (
      data.length > 0 ? <div>
        <div className='land-scape-type-item'>
          <div className='name color9size12'>名称</div>
          <div className='type color9size12'>分类</div>
        </div>
        {data.map((one, index) => {
          return <div key={one.key} className='land-scape-type-item'>
            <div className='name'>{one.name}</div>
            <div className='type'>{one.key}</div>
            <div className='land-scape-box-value'>
              <div className='land-scape-box' style={{ width: `calc(${100 * one.value}%)`, opacity: one.value + 0.2 }}></div>
              <div className='unit-value'>{numeral(one.value).format('0.0%')}</div>
            </div>
          </div>
        })}
      </div> : <Empty style={{ height: height + 18, paddingTop: height / 2 }} />
    );
  }
}
export default LandscapeType
复制代码

less


.land-scape-type-item {
    display: flex;

    .name,
    .type {
        min-width: 80px;
    }

    .land-scape-box-value {
        display: flex;
        height: 66px;
        width: 100%;
        border-left: 1px solid #ccc;

        .land-scape-box {
            background: #4786F5;
            height: 20px;
            border-radius: 10px;

        }

        .unit-value {
            margin-left: 4px
        }
    }

    .color9size12 {
        height: 60px;
        line-height: 60px;
        font-size: 12px;
        color: #999;
    }

}



复制代码


转载于:https://juejin.im/post/5d357815e51d454f6f16ecc9

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值