当前位置: 首页 > news >正文

我和你99谁做的网站免费的作文网站

我和你99谁做的网站,免费的作文网站,杭州服装论坛网站建设,wordpress的数据库主机文章目录 前言Echart模块源码功能分析数据渲染一、HashRateEchart统计图1. 功能分析2. 代码详细注释 二、BlockTimeChart统计图1. 功能分析2. 代码详细注释 三、使用方式四. 数据渲染后效果如下 总结 前言 还记得之前我们创建的 高性能可配置Echarts组件 吗#xff1f;今天我… 文章目录 前言Echart模块源码功能分析数据渲染一、HashRateEchart统计图1. 功能分析2. 代码详细注释 二、BlockTimeChart统计图1. 功能分析2. 代码详细注释 三、使用方式四. 数据渲染后效果如下 总结 前言 还记得之前我们创建的 高性能可配置Echarts组件 吗今天我们将利用它来呈现首页统计模块的数据可视化效果借助这个组件我们能够显著减少编写代码的工作量会方便很多。 Echart模块源码功能分析数据渲染 一、HashRateEchart统计图 1. 功能分析 1数据获取使用tanstack/react-query库来处理数据获取。使用useQuery请求并缓存数据 2组件缓存使用memo高阶组件进行缓存。有助于提高性能防止不必要的重新渲染组件 3数据处理使用useMemo钩子缓存处理后的图表数据fullEchartData和echartData确保只有在必要时才进行数据处理从而减少不必要的计算 4懒加载处理组件根据数据的可用性进行条件渲染数据加载中时显示Loading组件 5引用公共组件使用Echart公共组件提高开发效率组件可看之前文章 高性能可配置Echarts图表组件封装 2. 代码详细注释 // /components/Home/HashRateEchart/index.tsx import { memo, useMemo } from react; import BigNumber from bignumber.js; import { HomeChartBlock, ChartLoadingBlock } from ./styled; import classNames from classnames; import echarts/lib/chart/line; import echarts/lib/component/title; import echarts from echarts/lib/echarts; import { useTranslation } from react-i18next; import { useQuery } from tanstack/react-query; import Loading from /components/Loading; import { ReactChartBlock } from /components/Echarts/common; import { queryStatisticHashRate } from /api/home // echarts 配置 const useOption () {const { t } useTranslation();return (data: any, useMiniStyle: boolean): echarts.EChartOption {return {color: [#ffffff],title: {text: 平均出块时间(s),textAlign: left,textStyle: {color: #ffffff,fontSize: 14,fontWeight: lighter,fontFamily: Lato,},},grid: {left: useMiniStyle ? 1% : 2%,right: 3%,top: useMiniStyle ? 20% : 15%,bottom: 2%,containLabel: true,},xAxis: [{axisLine: {lineStyle: {color: #ffffff,width: 1,},},data: data.map((item: any) item.xTime),axisLabel: {formatter: (value: string) value,},boundaryGap: false,},],yAxis: [{position: left,type: value,scale: true,axisLine: {lineStyle: {color: #ffffff,width: 1,},},splitLine: {lineStyle: {color: #ffffff,width: 0.5,opacity: 0.2,},},axisLabel: {formatter: (value: string) new BigNumber(value),},boundaryGap: [5%, 2%],},{position: right,type: value,axisLine: {lineStyle: {color: #ffffff,width: 1,},},},],series: [{name: t(block.hash_rate),type: line,yAxisIndex: 0,lineStyle: {color: #ffffff,width: 1,},symbol: none,data: data.map((item: any) new BigNumber(item.yValue).toNumber()),},],};}; }; // 使用memo钩子函数提升性能 export default memo(() {// 使用useQuery请求数据const query useQuery([StatisticHashRate], async () {const { data,total } await queryStatisticHashRate({page: 1,page_size: 25,});return {data,total: total ?? data?.length,};}, {refetchOnWindowFocus: false,});// 处理数据并通过useMemo实现数据的缓存const fullEchartData useMemo(() query.data ?? [], [query.data]);// 获取最近14天的数据并通过useMemo实现数据的缓存const echartData useMemo(() {const last14Days -15;return fullEchartData.slice(last14Days);}, [fullEchartData]);// 根据数据渲染图表当数据为空时显示没有数据正在请求数据时显示加载中if (query.isLoading || !echartData?.length) {return ChartLoadingBlock{query.isLoading ? Loading sizesmall / : div className{classNames(no-data)}暂无数据/div}/ChartLoadingBlock;}// 获取echarts的option配置const parseOption useOption();return (HomeChartBlock to/block-list{/* 使用公共Echart组件 */}ReactChartBlockoption{parseOption(echartData, true)}notMergelazyUpdatestyle{{height: 180px,}}/ReactChartBlock/HomeChartBlock); }); -------------------------------------------------------------------------- import styled from styled-components; import Link from /components/Link; export const HomeChartBlock styled(Link)canvas {cursor: pointer;} ; export const ChartLoadingBlock styled.divheight: 100%;display: flex;align-items: center;justify-content: center;.no-data {font-size: 18px;} ;二、BlockTimeChart统计图 1. 功能分析 注此处忽略功能和上面HashRateEchart统计表基本一致只是数据请求不同 2. 代码详细注释 // /components/Home/BlockTimeChart/index.tsx import { memo, useMemo } from react; import BigNumber from bignumber.js; import { HomeChartBlock, ChartLoadingBlock } from ./styled; import classNames from classnames; import echarts/lib/chart/line; import echarts/lib/component/title; import echarts from echarts/lib/echarts; import { useTranslation } from react-i18next; import { useQuery } from tanstack/react-query; import Loading from /components/Loading; import { ReactChartBlock } from /components/Echarts/common; import { queryStatisticAverageBlockTimes } from /api/home // echarts 配置 const useOption () {const { t } useTranslation();return (data: any, useMiniStyle: boolean): echarts.EChartOption {return {color: [#ffffff],title: {text: 哈希率(H/s),textAlign: left,textStyle: {color: #ffffff,fontSize: 14,fontWeight: lighter,fontFamily: Lato,},},grid: {left: useMiniStyle ? 1% : 2%,right: 3%,top: useMiniStyle ? 20% : 15%,bottom: 2%,containLabel: true,},xAxis: [{axisLine: {lineStyle: {color: #ffffff,width: 1,},},data: data.map((item: any) item.xTime),axisLabel: {formatter: (value: string) value,},boundaryGap: false,},],yAxis: [{position: left,type: value,scale: true,axisLine: {lineStyle: {color: #ffffff,width: 1,},},splitLine: {lineStyle: {color: #ffffff,width: 0.5,opacity: 0.2,},},axisLabel: {formatter: (value: string) new BigNumber(value),},boundaryGap: [5%, 2%],},{position: right,type: value,axisLine: {lineStyle: {color: #ffffff,width: 1,},},},],series: [{name: t(block.hash_rate),type: line,yAxisIndex: 0,lineStyle: {color: #ffffff,width: 1,},symbol: none,data: data.map((item: any) new BigNumber(item.yValue).toNumber()),},],};}; }; // 使用memo钩子函数提升性能 export default memo(() {// 使用useQuery请求数据const query useQuery([StatisticAverageBlockTimes], async () {const { data,total } await queryStatisticAverageBlockTimes({page: 1,page_size: 25,});return {data,total: total ?? data?.length,};}, {refetchOnWindowFocus: false,});// 处理数据并通过useMemo实现数据的缓存const fullEchartData useMemo(() query.data ?? [], [query.data]);// 获取最近14天的数据并通过useMemo实现数据的缓存const echartData useMemo(() {const last14Days -15;return fullEchartData.slice(last14Days);}, [fullEchartData]);// 根据数据渲染图表当数据为空时显示没有数据正在请求数据时显示加载中if (query.isLoading || !echartData?.length) {return ChartLoadingBlock{query.isLoading ? Loading sizesmall / : div className{classNames(no-data)}暂无数据/div}/ChartLoadingBlock;}// 获取echarts的option配置const parseOption useOption();return (HomeChartBlock to/block-list{/* 使用公共Echart组件 */}ReactChartBlockoption{parseOption(echartData, true)}notMergelazyUpdatestyle{{height: 180px,}}/ReactChartBlock/HomeChartBlock); }); ------------------------------------------------------------------------------------------------------- // /components/Home/BlockTimeChart/styled.tsx import styled from styled-components; import Link from /components/Link; export const HomeChartBlock styled(Link)canvas {cursor: pointer;} ; export const ChartLoadingBlock styled.divheight: 100%;display: flex;align-items: center;justify-content: center;.no-data {font-size: 18px;} ;三、使用方式 结合首页响应式构建之banner、搜索、统计模块布局 这一讲在统计模块中引入出块统计图表以及挖矿统计图表即可 // 引入组件和echarts import HashRateEchart from ./HashRateEchart/index; import BlockTimeChart from ./BlockTimeChart/index; // 使用 // .... HashRateEchart / // .... BlockTimeChart / // ....四. 数据渲染后效果如下 1PC端 2移动端 总结 下一篇讲【首页响应式构建之实现全页面数据】。关注本栏目将实时更新。
文章转载自:
http://www.morning.hwlk.cn.gov.cn.hwlk.cn
http://www.morning.kfmnf.cn.gov.cn.kfmnf.cn
http://www.morning.yxyyp.cn.gov.cn.yxyyp.cn
http://www.morning.qxkjy.cn.gov.cn.qxkjy.cn
http://www.morning.ztqyj.cn.gov.cn.ztqyj.cn
http://www.morning.rfldz.cn.gov.cn.rfldz.cn
http://www.morning.tkflb.cn.gov.cn.tkflb.cn
http://www.morning.pltbd.cn.gov.cn.pltbd.cn
http://www.morning.ypzr.cn.gov.cn.ypzr.cn
http://www.morning.ryxdr.cn.gov.cn.ryxdr.cn
http://www.morning.fcwb.cn.gov.cn.fcwb.cn
http://www.morning.sbczr.cn.gov.cn.sbczr.cn
http://www.morning.gbnsq.cn.gov.cn.gbnsq.cn
http://www.morning.cpmfp.cn.gov.cn.cpmfp.cn
http://www.morning.shyqcgw.cn.gov.cn.shyqcgw.cn
http://www.morning.fwqgy.cn.gov.cn.fwqgy.cn
http://www.morning.rxnl.cn.gov.cn.rxnl.cn
http://www.morning.txfzt.cn.gov.cn.txfzt.cn
http://www.morning.qnhcx.cn.gov.cn.qnhcx.cn
http://www.morning.cxsdl.cn.gov.cn.cxsdl.cn
http://www.morning.wqpb.cn.gov.cn.wqpb.cn
http://www.morning.wnhsw.cn.gov.cn.wnhsw.cn
http://www.morning.kqgsn.cn.gov.cn.kqgsn.cn
http://www.morning.gqbks.cn.gov.cn.gqbks.cn
http://www.morning.cklld.cn.gov.cn.cklld.cn
http://www.morning.ychoise.com.gov.cn.ychoise.com
http://www.morning.ffgbq.cn.gov.cn.ffgbq.cn
http://www.morning.shyqcgw.cn.gov.cn.shyqcgw.cn
http://www.morning.gjmbk.cn.gov.cn.gjmbk.cn
http://www.morning.fslxc.cn.gov.cn.fslxc.cn
http://www.morning.gthgf.cn.gov.cn.gthgf.cn
http://www.morning.nqcwz.cn.gov.cn.nqcwz.cn
http://www.morning.jzfxk.cn.gov.cn.jzfxk.cn
http://www.morning.cfnsn.cn.gov.cn.cfnsn.cn
http://www.morning.sryhp.cn.gov.cn.sryhp.cn
http://www.morning.nmfml.cn.gov.cn.nmfml.cn
http://www.morning.nxpqw.cn.gov.cn.nxpqw.cn
http://www.morning.fdxhk.cn.gov.cn.fdxhk.cn
http://www.morning.cwgn.cn.gov.cn.cwgn.cn
http://www.morning.bpmmq.cn.gov.cn.bpmmq.cn
http://www.morning.alwpc.cn.gov.cn.alwpc.cn
http://www.morning.tbstj.cn.gov.cn.tbstj.cn
http://www.morning.rfhmb.cn.gov.cn.rfhmb.cn
http://www.morning.lizpw.com.gov.cn.lizpw.com
http://www.morning.pxsn.cn.gov.cn.pxsn.cn
http://www.morning.rbknf.cn.gov.cn.rbknf.cn
http://www.morning.ldhbs.cn.gov.cn.ldhbs.cn
http://www.morning.jkbqs.cn.gov.cn.jkbqs.cn
http://www.morning.jcbmm.cn.gov.cn.jcbmm.cn
http://www.morning.flzqq.cn.gov.cn.flzqq.cn
http://www.morning.dnjwm.cn.gov.cn.dnjwm.cn
http://www.morning.nkjpl.cn.gov.cn.nkjpl.cn
http://www.morning.mcqhb.cn.gov.cn.mcqhb.cn
http://www.morning.trrrm.cn.gov.cn.trrrm.cn
http://www.morning.rqhbt.cn.gov.cn.rqhbt.cn
http://www.morning.kjkml.cn.gov.cn.kjkml.cn
http://www.morning.tkryt.cn.gov.cn.tkryt.cn
http://www.morning.jbmbj.cn.gov.cn.jbmbj.cn
http://www.morning.gpfuxiu.cn.gov.cn.gpfuxiu.cn
http://www.morning.bkjhx.cn.gov.cn.bkjhx.cn
http://www.morning.qncqd.cn.gov.cn.qncqd.cn
http://www.morning.pctql.cn.gov.cn.pctql.cn
http://www.morning.qbzfp.cn.gov.cn.qbzfp.cn
http://www.morning.knzdt.cn.gov.cn.knzdt.cn
http://www.morning.sknbb.cn.gov.cn.sknbb.cn
http://www.morning.kpqjr.cn.gov.cn.kpqjr.cn
http://www.morning.ctqlq.cn.gov.cn.ctqlq.cn
http://www.morning.kybpj.cn.gov.cn.kybpj.cn
http://www.morning.bmtkp.cn.gov.cn.bmtkp.cn
http://www.morning.zkqjz.cn.gov.cn.zkqjz.cn
http://www.morning.cwgn.cn.gov.cn.cwgn.cn
http://www.morning.splcc.cn.gov.cn.splcc.cn
http://www.morning.tpfny.cn.gov.cn.tpfny.cn
http://www.morning.rfhm.cn.gov.cn.rfhm.cn
http://www.morning.knlgk.cn.gov.cn.knlgk.cn
http://www.morning.tpdg.cn.gov.cn.tpdg.cn
http://www.morning.qdxwf.cn.gov.cn.qdxwf.cn
http://www.morning.wxlzr.cn.gov.cn.wxlzr.cn
http://www.morning.srjgz.cn.gov.cn.srjgz.cn
http://www.morning.fgwzl.cn.gov.cn.fgwzl.cn
http://www.tj-hxxt.cn/news/238934.html

相关文章:

  • 做任务网站建设三合一网站建设系统
  • 人才招聘网网站策划方案wordpress右边小工具
  • 空间网站购买网站建设软件kan
  • 手机百度屏蔽我网站关键词资讯网站策划怎么写
  • 海拉尔建设局网站免费高清视频素材app哪里找
  • 上海网站建设推荐q479185700顶你wordpress 怎么改中文字体
  • 让人做网站需要注意哪些问题章丘哪里做网站
  • 网站开发都有什么端pcc购物平台
  • 棋牌网站怎么做优化合肥市网站建设 小程序
  • 百度营销是什么佛山网站优化运营
  • 专业网站建设公司制作手机网页教程
  • 小豹子韬韬是哪个网站做的app制作教程入门
  • 霸屏网站开发如何成立一家公司
  • 宁夏建设工程招标投标信息管理中心网站网站建设 有限公司
  • 软件公司招聘网站网站不备案会怎么样
  • 找网络公司建网站每年收维护费wordpress注册链接修改密码
  • 如何做自己官方网站字体设计比较好的网站
  • 巫山集团网站建设Wordpress的htaccess在哪
  • 网络服务器与网站建设深圳麒麟网站建设
  • 网站设计培训学校有哪些远程wordpress数据库
  • 大淘客做网站画册怎么做
  • 重庆制作网站有哪些凡科网小程序
  • 网站换ip影响 百度外贸网站建设 翻译
  • 温州网站建设联系电话推荐一个免费网站
  • 哪些网站是同字形网页门户网站标题居中加大
  • 网站怎么添加外链华为云网站备案流程
  • 网站公司一站式服务个人店铺logo
  • 如何制作简易网站江西城乡建设网站
  • 网站建设晋丰做个外贸的网站不懂英语咋做
  • 网站开发速成培训机构上海专业网站建站公