react实现多种可拖动滑块图表效果代码
代码语言:html
所属分类:图表
代码描述:react实现多种可拖动滑块图表效果代码,包括柱状图声音、范围面积图、价格区间、体积调节、扇形百分比进度调节、仪表盘指针调节等。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
body{
color: #424E82;
background: #e5e7eb;
padding: 24px 0px;
}
:root {
--thumb-size: 24px;
--thumb-color:transparent;
}
input[type="range"]{
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
width: 100%;
outline: none;
position: absolute;
margin: auto;
top: 0;
height: var(--thumb-size);
background-color: transparent;
pointer-events: none;
}
input[type="range"]::-webkit-slider-runnable-track{
-webkit-appearance: none;
height: var(--thumb-size);
}
input[type="range"]::-moz-range-track{
-moz-appearance: none;
height: var(--thumb-size);
}
input[type="range"]::-ms-track{
appearance: none;
height: var(--thumb-size);
}
input[type="range"]::-webkit-slider-thumb{
-webkit-appearance: none;
height:100px;
width: var(--thumb-size);
background-color: var(--thumb-color);
cursor: pointer;
pointer-events: auto;
}
input[type="range"]::-moz-range-thumb{
border: none;
outline: none;
-webkit-appearance: none;
height:100px;
width: var(--thumb-size);
cursor: pointer;
background-color: var(--thumb-color);
pointer-events: auto;
}
input[type="range"]::-ms-thumb{
border: none;
outline: none;
appearance: none;
height:100px;
width: var(--thumb-size);
cursor: pointer;
background-color: var(--thumb-color);
pointer-events: auto;
}
input[type="range"]:active::-webkit-slider-thumb{
background-color: none;
}
input[type="range"]:focus::-moz-range-thumb {
border: none;
outline: none;
}
input[type="range"]:active::-moz-range-thumb {
border: none;
outline: none;
}
.rt90{
transform: rotate(90deg);
}
</style>
</head>
<body >
<div id="root"></div>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/babel.7.18.13.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/tailwindcss.3.0.0.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react.production.17.1.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react-dom.production.17.1.js"></script>
<script type="text/babel">
const { useEffect, useRef, useState} = window.React;
const { render } = window.ReactDOM;
function App() {
return (
<>
<div className="max-w-7xl mx-auto flex flex-wrap items-center justify-center">
<DemoA />
<DemoB />
<DemoC />
</div>
<div className="max-w-7xl mx-auto flex flex-wrap items-center justify-center">
<DemoD />
<DemoE />
<DemoF />
</div>
</>
);
}
function Card({ title, children }) {
return (
<div className="p-2">
<div className="p-4 bg-white shadow-md rounded-md inline-block">
<div className="px-3 font-bold text-xl pb-4">{title}</div>
{children}
</div>
</div>
);
}
const demoAGraphData = [
{
key: 0,
path: "M7 95H5C2.23858 95 0 97.2386 0 100H12C12 97.2386 9.76142 95 7 95Z",
},
{
key: 1,
path: "M27 100V97C27 93.6863 24.3137 91 21 91C17.6863 91 15 93.6863 15 97V100H27Z",
},
{
key: 2,
path: "M42 100V92C42 88.6863 39.3137 86 36 86C32.6863 86 30 88.6863 30 92V100H42Z",
},
{
key: 3,
path: "M57 100V87C57 83.6863 54.3137 81 51 81C47.6863 81 45 83.6863 45 87V100H57Z",
},
{
key: 4,
path: "M72 100V82C72 78.6863 69.3137 76 66 76C62.6863 76 60 78.6863 60 82V100H72Z",
},
{
key: 5,
path: "M87 100V78C87 74.6863 84.3137 72 81 72C77.6863 72 75 74.6863 75 78V100H87Z",
},
{
key: 6,
path: "M102 100V73C102 69.6863 99.3137 67 96 67C92.6863 67 90 69.6863 90 73V100H102Z",
},
{
key: 7,
path: "M117 100V68C117 64.6863 114.314 62 111 62C107.686 62 105 64.6863 105 68V100H117Z",
},
{
key: 8,
path: "M132 100V63C132 59.6863 129.314 57 126 57C122.686 57 120 59.6863 120 63V100H132Z",
},
{
key: 9,
path: "M147 100V59C147 55.6863 144.314 53 141 53C137.686 53 135 55.6863 135 59V100H147Z",
},
{
key: 10,
path: "M162 100V54C162 50.6863 159.314 48 156 48C152.686 48 150 50.6863 150 54V100H162Z",
},
{
key: 11,
path: "M177 100V49C177 45.6863 174.314 43 171 43C167.686 43 165 45.6863 165 49V100H177Z",
},
{
key: 12,
path: "M192 100V44C192 40.6863 189.314 38 186 38C182.686 38 180 40.6863 180 44V100H192Z",
},
{
key: 13,
path: "M207 100V40C207 36.6863 204.314 34 201 34C197.686 34 195 36.6863 195 40V100H207Z",
},
{
key: 14,
path: "M222 100V35C222 31.6863 219.314 29 216 29C212.686 29 210 31.6863 210 35V100H222Z",
},
{
key: 15,
path: "M237 100V30C237 26.6863 234.314 24 231 24C227.686 24 225 26..........完整代码请登录后点击上方下载按钮下载查看
















网友评论0