Skip to content

Instantly share code, notes, and snippets.

View szu-bee's full-sized avatar
🎯

bee szu-bee

🎯
  • Shenzhen, Guangdong, China
View GitHub Profile
import React, { useState } from 'react'
import { Modal } from 'antd'
function useAntModal (initVisibleState = false) {
const [visible, setVisible] = useState(initVisibleState)
const handleCancel = ({ onCancel }) => {
onCancel && onCancel()
setVisible(false)
}
import React, { useRef, useLayoutEffect } from 'react'
import PropTypes from 'prop-types'
import { message } from 'antd'
import ClipboardJS from 'clipboard'
function Copy (props) {
const copyCtrl = useRef(null)
useLayoutEffect(() => {
const clipboard = new ClipboardJS(copyCtrl.current)
@szu-bee
szu-bee / sankeyOptionExample5.js
Created October 14, 2019 06:16
桑基图配置项样例5
option = {
"title": {
"text": "品牌流动关系"
},
"tooltip": {
"trigger": "item",
"triggerOn": "mousemove",
formatter: (params) => {
const { name, data } = params
if (name === '苹果') { // 此样例centerNode为'苹果'
@szu-bee
szu-bee / sankeyOptionExample4-1.js
Created October 13, 2019 20:00
桑基图配置项样例4
option = {
"title": {
"text": "品牌流动关系"
},
"color": [
"#3583FF",
"#FB7962",
"#A5D33E",
"#FFCD3A",
"#68A2FF",
@szu-bee
szu-bee / sankeyOptionExample3-1.js
Created October 13, 2019 19:44
桑基图配置项样例3
{
"title": {
"text": "品牌流动关系"
},
"color": [
"#3583FF",
"#FB7962",
"#A5D33E",
"#FFCD3A",
"#68A2FF",
@szu-bee
szu-bee / sankeyOptionExample2.js
Last active October 13, 2019 19:04
桑基图配置项样例2
option = {
"title": {
"text": "品牌流动关系"
},
"color": [
"#3583FF",
"#FB7962",
"#A5D33E",
"#FFCD3A",
"#68A2FF",
@szu-bee
szu-bee / sankeyOptionExample1.js
Last active October 12, 2020 06:58
桑基图配置项
option = {
"title": {
"text": "品牌流动关系"
},
"color": [
"#3583FF",
"#FB7962",
"#A5D33E",
"#FFCD3A",
"#68A2FF",
@szu-bee
szu-bee / floatToPercent.js
Created October 4, 2019 16:54
2.33333 -> 2.33%
const floatToPercent = (value) => {
if (isNaN(value)) return value
return `${Number(value * 100).toFixed(2)}%`
}
@szu-bee
szu-bee / formatBigIntNum.js
Created October 4, 2019 16:53
100000 -> 100,000
const formatBigIntNum = (value) => {
if (isNaN(value)) return value
const isInteger = Math.floor(value) === value
return isInteger ?
String(value).replace(/(?=(\B\d{3})+$)/g, ',') :
value
}
@szu-bee
szu-bee / value2TimeFormat.js
Last active October 4, 2019 13:26
时间格式转换——秒数转时分秒
const value2TimeFormat = (value) => {
return moment.utc().startOf('day').second(parseInt(value)).format('HH:mm:ss')
}