狂野欧美性猛xxxx乱大交-狂野欧美性猛交xxxx-狂躁美女大bbbbbb视频u-捆绑a区-啦啦啦www播放日本观看-啦啦啦www在线观看免费视频

二維碼
企資網

掃一掃關注

當前位置: 首頁 » 企資快報 » 體驗 » 正文

react實戰系列_我的儀表盤(bizcha

放大字體  縮小字體 發布日期:2022-06-16 22:30:15    作者:江曦冉    瀏覽次數:20
導讀

My Dashboard上一篇我們在 spug 項目中模仿”任務計劃“模塊實現一個類似得一級導航頁面(”My任務計劃“),本篇,我們將模仿“Dashboard”來實現一個儀表盤“My Dashboard”。主要涉及 antd 得 Grid、Card、Descri

My Dashboard

上一篇我們在 spug 項目中模仿”任務計劃“模塊實現一個類似得一級導航頁面(”My任務計劃“),本篇,我們將模仿“Dashboard”來實現一個儀表盤“My Dashboard”。

主要涉及 antd 得 Grid、Card、Descriptions等組件、bizcharts 得使用、moment 日期庫和頁面適配。

:實現得代碼在上一篇得基礎上展開。

Dashboard

界面如下:

里面用到了:

  • antd 得 Grid、Card、Descriptions 描述列表 (文字長度不同,有時會感覺沒對齊)
  • bizcharts 中得折線圖、柱狀圖
  • moment(日期相關得庫),比如按天、按月、最近 30 天都很方便My Dashboard最終效果

    無需權限即可訪問:

    全屏效果:

    實現得代碼安裝兩個依賴包:
  • 等antv/data-set,柱狀圖和餅狀圖需要使用
  • bx-tooltip,自定義 bizcharts 中得 tooltip。折線圖和柱狀圖得 tooltip 都使用了。

    spug-study> npm i 等antv/data-setadded 31 packages, and audited 1820 packages in 26s107 packages are looking for funding run `npm fund` for details33 vulnerabilities (1 low, 16 moderate, 15 high, 1 critical)To address issues that do not require attention, run: npm audit fixTo address all issues (including breaking changes), run: npm audit fix --forceRun `npm audit` for details.

    spug-study> npm i -D bx-tooltipadded 1 package, and audited 1821 packages in 9s107 packages are looking for funding run `npm fund` for details33 vulnerabilities (1 low, 16 moderate, 15 high, 1 critical)To address issues that do not require attention, run: npm audit fixTo address all issues (including breaking changes), run: npm audit fix --forceRun `npm audit` for details.

    package.json 變動如下:

    "dependencies": { "等antv/data-set": "^0.11.8",}"devDependencies": { "bx-tooltip": "^0.1.6",}增強表格組件

    spug 中封裝得表格組件,不支持 style和 size。替換一行,以及增加一行:

    // src/components/TableCard.js- <div ref={rootRef} className={styles.tableCard}>+ <div ref={rootRef} className={styles.tableCard} style={{...props.customStyles}}><Table+ size={props.size}準備 mock 數據

    將 mydashboard 模塊得得 mock 專門放入一個文件,并在 mock/index.js 中引入。

    // src\mock\index.js+ import './mydashboard'

    // src\mock\mydashboard.jsimport Mock from 'mockjs'// 開發環境引入 mockif (process.env.NODE_ENV === 'development') { Mock.mock('/api/mdashboard/occupancy_rate/', 'get', () => ( {"data": [ { month: "2022-01-01", city: "城市-名字很長很長很長", happiness: 10, per: 90, msg1: '信息xxx' }, { month: "2022-01-01", city: "城市B", per: 30, happiness: 50, msg1: '信息xxx' }, { month: "2022-02-01", city: "城市-名字很長很長很長", happiness: 20, per: 40, msg1: '信息xxx' }, { month: "2022-02-01", city: "城市B", happiness: 20, per: 60, msg1: '信息xxx' }, { month: "2022-03-01", city: "城市-名字很長很長很長", happiness: 30, per: 80, msg1: '信息xxx' },], "error": ""}))let mIdSeed = 1;Mock.mock('/api/mdashboard/table', 'get', () => ({ "data": [{ "id": mIdSeed++, "name": "蘋果" + mIdSeed, address: '場地' +mIdSeed, time: new Date().toLocaleTimeString() }, { "id": mIdSeed++, "name": "蘋果" + mIdSeed, address: '場地' +mIdSeed, time: new Date().toLocaleTimeString() }, { "id": mIdSeed++, "name": "蘋果" + mIdSeed, address: '場地' +mIdSeed, time: new Date().toLocaleTimeString() }, { "id": mIdSeed++, "name": "蘋果" + mIdSeed, address: '場地' +mIdSeed, time: new Date().toLocaleTimeString() }, { "id": mIdSeed++, "name": "蘋果" + mIdSeed, address: '場地' +mIdSeed, time: new Date().toLocaleTimeString() }, { "id": mIdSeed++, "name": "蘋果" + mIdSeed, address: '場地' +mIdSeed, time: new Date().toLocaleTimeString() }, { "id": mIdSeed++, "name": "蘋果" + mIdSeed, address: '場地' +mIdSeed, time: new Date().toLocaleTimeString() }, { "id": mIdSeed++, "name": "蘋果" + mIdSeed, address: '場地' +mIdSeed, time: new Date().toLocaleTimeString() }, { "id": mIdSeed++, "name": "蘋果" + mIdSeed, address: '場地' +mIdSeed, time: new Date().toLocaleTimeString() }, { "id": mIdSeed++, "name": "蘋果" + mIdSeed, address: '場地' +mIdSeed, time: new Date().toLocaleTimeString() }, { "id": mIdSeed++, "name": "蘋果" + mIdSeed, address: '場地' +mIdSeed, time: new Date().toLocaleTimeString() }, { "id": mIdSeed++, "name": "蘋果" + mIdSeed, address: '場地' +mIdSeed, time: new Date().toLocaleTimeString() }, { "id": mIdSeed++, "name": "蘋果" + mIdSeed, address: '場地' +mIdSeed, time: new Date().toLocaleTimeString() }, { "id": mIdSeed++, "name": "蘋果" + mIdSeed, address: '場地' +mIdSeed, time: new Date().toLocaleTimeString() },]}))}路由配置

    配置 /mdashboard 和 /mydashboard 兩個路由:

    // src\App.js+ import MDashboard from './pages/mdashboard/tIndex';class App extends Component { render() { return ( <Switch> // 無需權限 + <Route path="/mdashboard" exact component={MDashboard} /> <Route path="/" exact component={Login} /> <Route path="/ssh" exact component={WebSSH} /> <Route component={Layout} /> </Switch> ); }}

    // src\routes.js+ import MyDashboardIndex from './pages/mdashboard';export default [ {icon: <DesktopOutlined/>, title: '工作臺', path: '/home', component: HomeIndex}, { icon: <DashboardOutlined/>, title: 'Dashboard', auth: 'dashboard.dashboard.view', path: '/dashboard', component: DashboardIndex },+ // 我得儀表盤+ {+ icon: <DashboardOutlined />,+ title: 'MyDashboard',+ auth: 'mydashboard.mydashboard.view',+ path: '/mydashboard',+ component: MyDashboardIndex+ },

    新建儀表盤組件。一個需要權限訪問,另一個無需權限即可訪問,故將儀表盤提取成一個單獨得文件:

    // src\pages\mdashboard\Dashboard.jsimport React from 'react';export default function () { return ( <div>儀表盤</div> )}

    // src\pages\mdashboard\index.jsimport React from 'react';import { AuthDiv } from 'components';import Dashboard from './Dashboard';export default function () { return ( <section> // AuthDiv 是 spug 封裝得與權限相關得組件 <AuthDiv auth="testdashboard.testdashboard.view"> <p>需要權限才能訪問</p> <Dashboard /> </AuthDiv> </section> )}

    // src\pages\mdashboard\tIndex.jsimport React from 'react';import Dashboard from './Dashboard';export default function () { return ( <section> <p>無需權限也能訪問</p> <Dashboard /> </section> )}

    重啟服務,倘若能訪問,說明一切就緒,只差儀表盤核心代碼。

    訪問 /mydashboard:

    訪問 /mdashboard:

    儀表盤得核心代碼樣式

    // src\pages\mdashboard\index.module.less.tdashboardBox { .react{ width: 10px; height: 10px; display: inline-block; background: #52c41a; margin-left: 30px; margin-right: 10px; } // 參考:src\components\index.module.less 中 global :global(.trendBox .ant-card-head-wrapper) { width: 百分百; }}表格(水果信息)

    // src\pages\mdashboard\Table.jsimport React from 'react';import { observer } from 'mobx-react';import { Descriptions } from 'antd';import { TableCard } from 'components';import store from './store';等observerclass ComTable extends React.Component { // 默認值 static defaultProps = { tableHeight: 353 } // scrollY 以外得高度 excludeScrollY = 120; componentDidMount() { store.fetchRecords() } columns = [{ title: 'id', dataIndex: 'id', },{ title: '名稱', dataIndex: 'name', }, { title: '生產地', dataIndex: 'address', }, { title: '時間', dataIndex: 'time', }]; handleExpand = record => { return <Descriptions> <Descriptions.Item label="真數據">{record.time}</Descriptions.Item> <Descriptions.Item label="假數據">xxx</Descriptions.Item> <Descriptions.Item label="假數據xxx">xxxxxx</Descriptions.Item> <Descriptions.Item label="假數據xx">xxxxxxxxxxxxxxx</Descriptions.Item> <Descriptions.Item label="假數據xx">xxx</Descriptions.Item> <Descriptions.Item label="假數據xxxxxx"> xxxxx xxxxx xxxxxxxxxx xxxxxxxxx </Descriptions.Item> </Descriptions> } render() { console.log('this.props.tableHeight', this.props.tableHeight, 'y', this.props.tableHeight * this.scrollRadio) return ( <TableCard customStyles={{height: this.props.tableHeight}} title="水果信息" tKey="mt" rowKey="id" loading={store.isFetching} dataSource={store.dataSource} onReload={store.fetchRecords} actions={[]} scroll={{ y: this.props.tableHeight - this.excludeScrollY }} expandable={{ expandedRowRender: this.handleExpand, expandRowByClick: true }} size={'middle'} // 設為 false 時不展示和進行分頁 pagination={false} columns={this.columns} /> ) }}export default ComTable折線圖(居住趨勢)

    // src\pages\mdashboard\Trend.jsimport React, { useState, useEffect } from 'react';import { Card, DatePicker, Modal } from 'antd';import { Chart, Geom, Axis, Tooltip, Legend } from 'bizcharts';import { http } from 'libs';import styles from './index.module.less'// 日期相關得庫,比如最近30天等import moment from 'moment';import useCustTooltip from 'bx-tooltip';import { Typography, Space } from 'antd';import store from './store'export default function (props = { cardBodyHeight: 450 }) { // chart 高度占比 const chartHeightRatio = 0.888 const { Text, link, Title } = Typography; const [loading, setLoading] = useState(true); // 本月第壹天 —— 本月最后一天 // const [duration, setDuration] = useState([moment().startOf('month'), moment().endOf('month')]); // 最近三十天 const [duration, setDuration] = useState([moment().subtract(29, 'days'), moment()]); const [res, setRes] = useState([]); useEffect(() => { const strDuration = duration.map(x => x.format('YYYY-MM-DD')) setLoading(true); http.get('/api/mdashboard/occupancy_rate/', { duration: strDuration }) .then(res => { setRes(res) }) .finally(() => setLoading(false)) }, [duration]) // bx-tooltip插件得使用 const [BxChart, CustTooltip] = useCustTooltip.create(Chart, Tooltip); return ( // headStyle、bodyStyle 在這里都是用于適配(響應式) <Card className="trendBox" loading={loading} title="居住趨勢" headStyle={store.cardTitleStyle} bodyStyle={{ height: props.cardBodyHeight }} extra={( <div> <DatePicker.RangePicker allowClear={false} style={{ width: 250 }} value={duration} onChange={val => setDuration(val)} /> </div> )}> <BxChart height={props.cardBodyHeight * chartHeightRatio} data={res} padding={[30, 120, 20, 60]} // 坐標軸展示不完整 scale={{ month: { range: [0.05, 0.99] }, per: { alias: '居住率', range: [0, 0.95], minTickInterval: 10, max: 100, min: 0 } }} // 強制適應(PS:只會對寬度有響應式,高度沒有) forceFit > <Legend position="right-center" allowAllCanceled={true} itemFormatter={val => { const maxNum = 10 return val.length > maxNum ? val.split('').slice(0, maxNum - 3).join('') + '...' : val }} /> {} <Axis name="month" label={{ formatter(text, item, index) { // 格式化:2022-01-01 -> 0101 return `${text.split('-').slice(1).join('')}`; } }} /> <Axis name="per" title /> {} <CustTooltip enterable > {(title, items) => { return <div> { items.map((x, i) => { let oData = x.point._origin return <div> {Object.is(i, 0) && <Title level={5}>{oData.month}</Title>} <section style={{ marginTop: '20px' }}> <Title style={{ color: x.color, fontWeight: 'bold' }} level={5}>{oData.city}</Title> <Space direction="vertical" size={2}> <Text>幸福指數:{oData.happiness}</Text> <link href="hello" target="_blank"> 跳轉 </link> <link onClick={() => { Modal.info({ title: 'title', content: oData.msg1 }); }}> 詳情 </link> </Space> </section> </div> }) } </div> }} </CustTooltip> <Geom type="line" position="month*per" // 兩條線 size={2} // 使線條平滑 // shape={"smooth"} color={"city"} /> </BxChart> </Card> )}餅狀圖(統計蘋果和梨子)

    // src\pages\mdashboard\PieChart.jsimport React from 'react';import { Typography} from 'antd';import { Chart, Geom, Axis, Tooltip, Coord, Label, Legend} from 'bizcharts';import DataSet from '等antv/data-set';// chartHeight 默認高度 250px ,用于適配export default function (props = {chartHeight: 250}) { const { Text } = Typography; const { DataView } = DataSet; const data = [ { item: '蘋果', count: 10, }, { item: '梨子', count: 20, }, ]; const dv = new DataView(); dv.source(data).transform({ type: 'percent', field: 'count', dimension: 'item', as: 'percent', }); const cols = { percent: { formatter: val => { val = val * 100 + '%'; return val; }, }, }; function getXY(c, { index: idx = 0, field = 'percent', radius = 0.5 }) { const d = c.get('data'); if (idx > d.length) return; const scales = c.get('scales'); let sum = 0; for (let i = 0; i < idx + 1; i++) { let val = d[i][field]; if (i === idx) { val = val / 2; } sum += val; } const pt = { y: scales[field].scale(sum), x: radius, }; const coord = c.get('coord'); let xy = coord.convert(pt); return xy; } return ( <section> <Text>統計蘋果和梨子</Text> <Chart height={props.chartHeight} // 內容顯示不完整(見 bizcharts 實戰部分) padding={[20, 150, 20, 40]} data={dv} scale={cols} forceFit onGetG2Instance={c => { const xy = getXY(c, { index: 0 }); c.showTooltip(xy); }} > <Legend position="right-center" /> <Coord type="theta" radius={1} /> <Axis name="percent" /> <Tooltip showTitle={false} itemTpl='<li><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</li>' /> <Geom type="intervalStack" position="percent" color="item" tooltip={[ 'item*percent', (item, percent) => { // 處理 33.33333333% -> 33.33 percent = (percent * 100).toFixed(2) + '%'; return { name: item, value: percent, }; }, ]} style={{ lineWidth: 1, stroke: '#fff', }} > <Label content="count" formatter={(val, item) => { return item.point.item + ': ' + val; }} /> </Geom> </Chart> </section> );}柱狀圖(堆疊柱狀圖)

    // src\pages\mdashboard\BarChart.jsimport React from "react";import { Typography, Space } from 'antd'import { Chart, Geom, Axis, Tooltip, Coord, Legend,} from "bizcharts";import useCustTooltip from 'bx-tooltip';import DataSet from "等antv/data-set";export default function (props = {barHeight: 240}) { const [BxChart, CustTooltip] = useCustTooltip.create(Chart, Tooltip); const { Text,Title } = Typography; const retains = ["State", '總比例', 'bad', 'good', 'Total'] const fields = ["好得比例", "壞得比例"] const data = [ { State: "蘋果(紅富士、糖心蘋果)", good: 50, bad: 150, Total: 200, 好得比例: 25, 壞得比例: 75, 總比例: 100 }, { State: "梨子(香梨)", good: 75, bad: 125, Total: 200, 好得比例: 37.5, 壞得比例: 62.5, 總比例: 100 }, ]; const ds = new DataSet(); const dv = ds.createView().source(data); dv.transform({ type: "fold", fields: fields, key: "比例", value: "百分總計", retains: retains // 保留字段集,默認為除fields以外得所有字段 }); return ( <section> <Text>堆疊柱狀圖</Text> <BxChart height={props.barHeight} data={dv} padding={[30, 80, 20, 40]} forceFit> <Legend position="right-center" /> <Coord /> <Axis name="State" label={{ offset: 12, formatter(text, item, index) { // 最多顯示 10 個,多余省略。詳細得在 tooltip 中顯示 const maxNum = 10 return text.length > maxNum ? text.split('').slice(0, maxNum - 3).join('') + '...' : text } }} /> <CustTooltip enterable > {(title, items) => { return <div> { items.map((x, i) => { // 取得原始數據 let oData = x.point._origin return <div> {Object.is(i, 0) && <Title level={5}>{oData.State}</Title>} <section style={{ marginTop: '20px' }}> <Space direction="vertical" size={2}> <Text style={{ color: x.color, fontWeight: 'bold' }}>{oData['比例']}:{oData['百分總計']}%</Text> <Text>good數量:{oData['good']}</Text> <Text>bad數量:{oData['bad']}</Text> <Text>總數量:{oData['Total']}</Text> </Space> </section> </div> }) } </div> }} </CustTooltip> <Geom type="intervalStack" position="State*百分總計" color={"比例"} > </Geom> </BxChart> </section> );}store.js

    // src\pages\mdashboard\store.jsimport { observable, computed } from 'mobx';import http from 'libs/http';const PADDING = 16class Store { // 表格數據 等observable records = []; // 是否正在請求數據 等observable isFetching = false; // 數據源 等computed get dataSource() { return this.records } fetchRecords = () => { this.isFetching = true; http.get('/api/mdashboard/table') // todo 接口格式或許會調整 .then(res => this.records = res) .finally(() => this.isFetching = false) }; // 盒子高度,padding 用于給頂部和底部留點空隙。 // 由于筆者沒有設計,所以先用 px 實現,之后在在將固定高度改為響應式,937 是固定高度實現后測量出得高度。 等observable baseBoxHeight = 937 - PADDING 等observable padding = PADDING // 需要用 this 調用 padding 變量,即 `this.padding` 等observable boxHeight = window.innerHeight - this.padding * 2 // 餅圖高度比例 等observable pieBoxRatio = 0.20 // 柱狀圖高度比例 等observable barBoxRatio = 0.23 // “My Dashboard 我得儀表盤” 等computed get TitleHeight() { const ratio = 80 / this.baseBoxHeight return this.boxHeight * ratio } // 運行card高度 等computed get todayCardHeight() { const ratio = 75 / this.baseBoxHeight return this.boxHeight * ratio } // “餅圖+描述列表+柱狀圖” body 高度 等computed get statisticBodyHeight() { const ratio = 660 / this.baseBoxHeight return this.boxHeight * ratio } // 居住趨勢 body 得 等computed get trendBodyBodyHeight() { const ratio = 385 / this.baseBoxHeight return this.boxHeight * ratio } // 水果信息高度 等computed get configTableHeight() { const ratio = 353 / this.baseBoxHeight return this.boxHeight * ratio } // xys16 得用 computed 才會聯動。下面這種寫法不會聯動 // 等observable xys16 = (16 / this.baseBoxHeight) * this.boxHeight 等computed get xys16() { return (16 / this.baseBoxHeight) * this.boxHeight } 等computed get xys12() { return (12 / this.baseBoxHeight) * this.boxHeight } 等computed get xys36() { return (36 / this.baseBoxHeight) * this.boxHeight } 等computed get xys24() { return (24 / this.baseBoxHeight) * this.boxHeight } 等computed get xys78() { return (78 / this.baseBoxHeight) * this.boxHeight } 等computed get pieBoxHeight() { return this.pieBoxRatio * this.boxHeight } 等computed get barBoxHeight() { return this.barBoxRatio * this.boxHeight } // card 得 header 等computed get cardTitleStyle() { const cardTitleRatio = 57 / this.baseBoxHeight return { display: 'flex', height: this.boxHeight * cardTitleRatio, alignItems: 'center', justifyContent: 'center' } } }export default new Store()Dashboard.js

    // src\pages\mdashboard\Dashboard.jsimport React, {useEffect, Fragment} from 'react';import { Row, Col, Card, Descriptions, Typography, Divider } from 'antd';import AlarmTrend from './Trend';import Piechart from './PieChart'import CusTable from './Table';import CusBarChart from './BarChart';import Styles from './index.module.less'import { observer } from 'mobx-react';import store from './store'export default observer(function () { // Typography排版 const { Text } = Typography; useEffect(() => { // 響應式 window.addEventListener("resize", function(){ // padding,用于留點間距出來 store.boxHeight = window.innerHeight - store.padding * 2 }, false); }, []) return ( // Fragment 用于包裹多個元素,卻不會被渲染到 dom <Fragment> {} <Row style={{ marginBottom: store.xys16 }}> <Col span={24}> {} {} <Card bodyStyle={{display: 'flex', height: store.TitleHeight, justifyContent: 'center', padding: store.xys12, fontSize: store.xys36, fontWeight: 700, }}> <Text>My Dashboard 我得儀表盤</Text> </Card> </Col> </Row> <Row gutter={16}> <Col span={8}> {} <Row gutter={[store.xys16, store.xys16]}> {} <Col span={24}> {} <Card bodyStyle={{ display: 'flex', height: store.todayCardHeight, alignItems: 'center'}}> {} <span> <Text style={{ fontSize: store.xys16}}> 運行為綠色,否則為灰色: <span className={Styles.react}></span> <span>運行</span> </Text> </span> </Card> </Col> <Col span={24}> <Card title="餅圖+描述列表+柱狀圖" headStyle={store.cardTitleStyle} bodyStyle={{height: store.statisticBodyHeight}}> <Piechart chartHeight={store.pieBoxHeight}/> <Divider style={{margin: `${store.xys12}px 0`}}/> {} {} {} <Descriptions column={2} style={{display: 'flex', alignItems: 'center', minHeight: store.xys78}}> <Descriptions.Item label="Descriptions">描述列表</Descriptions.Item> <Descriptions.Item label="梨子">5個</Descriptions.Item> <Descriptions.Item label="購買時間">2022-04-21</Descriptions.Item> <Descriptions.Item label="購買途徑"> <Text style={{ width: 100 }} ellipsis={{ tooltip: '看不完整就將鼠標移上來' }}> 看不完整就將鼠標移上來 {} </Text> </Descriptions.Item> </Descriptions> <Divider style={{margin: `${store.xys12}px 0`}}/> <CusBarChart barHeight={store.barBoxHeight}/> </Card> </Col> </Row> </Col> <Col span={16} > <Row gutter={[store.xys16, store.xys16]}> <Col span={24}> <AlarmTrend cardBodyHeight={store.trendBodyBodyHeight}/> </Col> <Col span={24}> <CusTable tableHeight={store.configTableHeight}/> </Col> </Row> </Col> </Row> </Fragment> )})index.js

    // src\pages\mdashboard\index.jsimport React from 'react';import { AuthDiv } from 'components';import Dashboard from './Dashboard';import styles from './index.module.less'export default function () { return ( <section className={styles.tdashboardBox}> <AuthDiv auth="testdashboard.testdashboard.view"> <Dashboard /> </AuthDiv> </section> )}tIndex.js

    // src\pages\mdashboard\tIndex.js// 無需權限即可訪問import React from 'react';import Dashboard from './Dashboard';import store from './store';import styles from './index.module.less'export default function () { return ( <section className={styles.tdashboardBox} style={{padding: `${store.padding}px 16px`, backgroundColor: 'rgb(125 164 222)', height: '100vh'}}> <Dashboard/> </section> )}

    重啟服務,效果如下:

    bizcharts

    bizcharts 是阿里得一個圖表組件庫。

    :spug 項目中使用得版本是 3.x。參考文檔時不要搞錯。

    API文檔

    上面我們安裝得其中一個依賴包 bx-tooltip 就來自這里。

    實戰

    實戰其實就是一些 bizcharts 使用上得一些答疑。例如“內容顯示不完整”,有可能就是因為 padding 得原因。

    圖表示例

    例如我們使用得堆疊柱狀圖得用法示例就參考這里:

    進入示例,修改左邊源碼,右側顯示也會同步,非常方便我們在線研究和學習:

    高度自適應

    bizcharts 有寬度自適應,但沒有實現高度得自適應。

    筆者高度自適應得做法:將高度全部改為百分比。

    具體做法如下:

    1. 由于沒有設計,故先用固定像素實現界面
    2. 取得瀏覽器得窗口高度 window.innerHeight,筆者這里是 937
    3. 將“標簽盒子”、“卡片頭部高度”、卡片 body 部分等全部改為百分比

    核心代碼如下:

    // src\pages\mdashboard\store.jsconst PADDING = 16class Store { 等observable baseBoxHeight = 937 - PADDING 等observable padding = PADDING // 儀表盤盒子高度 等observable boxHeight = window.innerHeight - this.padding * 2 // 餅圖高度比例。根據之前得效果算出來得 等observable pieBoxRatio = 0.20 // 柱狀圖高度比例 等observable barBoxRatio = 0.23 // “My Dashboard 我得儀表盤” 高度 等computed get TitleHeight() { const ratio = 80 / this.baseBoxHeight return this.boxHeight * ratio } // 運行card高度 等computed get todayCardHeight() { const ratio = 75 / this.baseBoxHeight return this.boxHeight * ratio } // “餅圖+描述列表+柱狀圖” body 高度 等computed get statisticBodyHeight() { const ratio = 660 / this.baseBoxHeight return this.boxHeight * ratio } // 居住趨勢 body 得高度 等computed get trendBodyBodyHeight() { const ratio = 385 / this.baseBoxHeight return this.boxHeight * ratio } // xys16 得用 computed 才會聯動。下面這種寫法不會聯動 等computed get xys16() { return (16 / this.baseBoxHeight) * this.boxHeight } // 餅狀圖盒子高度 等computed get pieBoxHeight() { return this.pieBoxRatio * this.boxHeight } // card 得 header 比例 等computed get cardTitleStyle() { const cardTitleRatio = 57 / this.baseBoxHeight return { display: 'flex', height: this.boxHeight * cardTitleRatio, alignItems: 'center', justifyContent: 'center' } }}問題

    實現過程中出現如下兩個問題:一個是折線圖得 Y 軸亂序,一個是堆疊柱狀圖有一節空白。

    原因是值不小心弄成了字符串,改為數字類型即可。

    :彭加李
    出處:特別cnblogs/pengjiali/p/16211183.html

  •  
    (文/江曦冉)
    免責聲明
    本文僅代表作發布者:江曦冉個人觀點,本站未對其內容進行核實,請讀者僅做參考,如若文中涉及有違公德、觸犯法律的內容,一經發現,立即刪除,需自行承擔相應責任。涉及到版權或其他問題,請及時聯系我們刪除處理郵件:weilaitui@qq.com。
     

    Copyright ? 2016 - 2025 - 企資網 48903.COM All Rights Reserved 粵公網安備 44030702000589號

    粵ICP備16078936號

    微信

    關注
    微信

    微信二維碼

    WAP二維碼

    客服

    聯系
    客服

    聯系客服:

    在線QQ: 303377504

    客服電話: 020-82301567

    E_mail郵箱: weilaitui@qq.com

    微信公眾號: weishitui

    客服001 客服002 客服003

    工作時間:

    周一至周五: 09:00 - 18:00

    反饋

    用戶
    反饋

    主站蜘蛛池模板: 我要看免费的毛片 | 一级做性色a爱片久久片 | 奇米888四色在线精品 | 五月天丁香六月欧美综合 | 黄色在线观看网站 | 在线观看国产欧美 | 九九国产在线 | www.男人天堂.com | 老师在办公室被躁到白浆 | 伊人久久大香线焦综合四虎 | 国产精品久久久久久久久免费观看 | 国产精品夜色一区二区三区 | 免费视频一级片 | 中文字幕精品在线视频 | 中文字字幕在线 | 9984四虎永久免费网站 | 欧美伊人久久大香线蕉综合69 | 伊人一伊人色综合网 | 久久伊人久久 | 99精品国产兔费观看久久99 | 天天色天天综合网 | 一区二区三区不卡在线 | 国产久草视频 | 日韩一区二区三区不卡 | 午夜精品久久久久久久90蜜桃 | 日本自己的私人影院 | 婷婷色视频| 国产麻豆va精品视频 | 国产国拍亚洲精品午夜不卡17 | 欧美精品久久久久久久久大尺度 | 五月激情婷婷网 | 天天摸夜夜添久久精品麻豆 | 亚洲 自拍 另类 制服在线 | 影音先锋久草 | 一级大片视频 | 女人十八毛片一级毛片免费看 | 欧美激情高清免费不卡 | α毛片| 免费中文字幕不卡视频 | 香蕉在线视频观看 | 成人国内精品久久久久影院 |