d3实现线条标记效果
代码语言:html
所属分类:图表
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
@import url("https://fonts.googleapis.com/css?family=Acme|Open+Sans&display=swap");
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
body {
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: url("data:image/svg+xml,%3Csvg viewBox='0 0 73 95' opacity='0.1' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform='translate(36.5 47.5) scale(0.4)'%3E%3Cg transform='translate(-36.5 -47.5)'%3E%3Cg fill='none' stroke='hsl(0, 0%25, 30%25)' stroke-width='10'%3E%3Cpath d='M 10 95 v -75 h 25 l 8 8 h 25 v 35 h -25 l -8 -8 h -25 m 0 -42 l -3 -3 3 -3 3 3 -3 3z' /%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A"),
hsl(0, 0%, 97%);
background-size: 50px;
color: hsl(200, 10%, 20%);
font-family: "Open Sans", sans-serif;
}
#root {
padding: 1.5rem;
background: hsl(0, 0%, 100%);
box-shadow: 0 0 10px -8px hsl(200, 10%, 20%);
line-height: 1.5;
max-width: 550px;
width: 80vw;
}
h1 {
font-family: "Acme", sans-serif;
letter-spacing: 1px;
font-size: 2.8rem;
}
p {
font-size: 0.95rem;
}
svg {
width: 100%;
height: auto;
display: block;
}
svg text {
font-family: "Acme", sans-serif;
font-size: 1.3rem;
}
</style>
</head>
<body translate="no">
<div id="root"></div>
<script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/d3.js"></script>
<script>
// DATA
// highest mountains on earth, by name, elevation and country(ies)
// https://en.wikipedia.org/wiki/List_of_highest_mountains_on_Earth
const dataMountains = [
{
name: 'Mount Everest',
elevation: '8,848',
country: ['Nepal', 'China'] },
{
name: 'K2',
elevation: '8,611',
country: ['Pakistan', 'China'] },
{
name: 'Kangchenjunga',
elevation: '8,586',
country: ['Nepal', 'India'] },
{
name: 'Lhotse',
elevation: '8,516',
country: ['Nepal', 'China'] },
{
name: 'Makalu',
elevation: '8,485',
country: ['Nepal', 'China'] },
{
name: 'Cho Oyu',
elevation: '8,188',
country: ['Nepal', 'China'] },
{
name: 'Dhaulagiri I',
elevation: '8,167',
country: ['Nepal'] },
{
name: 'Manaslu',
elevation: '8,163',
country: ['Nepal'] },
{
name: 'Nanga Parbat',
elevation: '8,126',
country: ['Pakistan'] },
{
name: 'Annapurna I',
elevation: '8,091',
country: ['Nepal'] },
{
name: 'Gasherbrum I',
elevation: '8,080',
country: [�.........完整代码请登录后点击上方下载按钮下载查看
网友评论0