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: ['Pakistan', 'China'] }, { name: 'Broad Peak', elevation: '8,051', country: ['Pakistan', 'China'] }, { name: 'Gasherbrum II', elevation: '8,035', country: ['Pakistan', 'China'] }, { name: 'Shishapangma', elevation: '8,027', country: ['China'] }, { name: 'Gyachung Kang', elevation: '7,952', country: ['Nepal', 'China'] }, { name: 'Gasherbrum III', elevation: '7,946', country: ['Pakistan', 'China'] }, { name: 'Annapurna II', elevation: '7,937', country: ['Nepal'] }, { name: 'Gasherbrum IV', elevation: '7,932', country: ['Pakistan'] }, { name: 'Himalchuli', elevation: '7,893', country: ['Nepal'] }, { name: 'Distaghil Sar', elevation: '7,884', country: ['Pakistan'] }, { name: 'Ngadi Chuli', elevation: '7,871', country: ['Nepal'] }, { name: 'Nuptse', elevation: '7,864', country: ['Nepal'] }, { name: 'Khunyang Chhish', elevation: '7,823', country: ['Pakistan'] }, { name: 'Masherbrum', elevation: '7,821', country: ['Pakistan'] }, { name: 'Nanda Devi', elevation: '7,816', country: ['India'] }, { name: 'Chomo Lonzo', elevation: '7,804', country: ['China'] }, { name: 'Batura Sar', elevation: '7,795', country: ['Pakistan'] }, { name: 'Kanjut Sar', elevation: '7,790', country: ['Pakistan'] }, { name: 'Rakaposhi', elevation: '7,788', country: ['Pakistan'] }, { name: 'Namcha Barwa', elevation: '7,782', country: ['China'] }, { name: 'Kamet', elevation: '7,756', country: ['India'] }, { name: 'Dhaulagiri II', elevation: '7,751', country: ['Nepal'] }, { name: 'Saltoro Kangri', elevation: '7,742', country: ['India', 'Pakistan'] }, { name: 'Kumbhakarna', elevation: '7,711', country: ['Nepal'] }, { name: 'Tirich Mir', elevation: '7,708', country: ['Pakistan'] }, { name: 'Molamenqing', elevation: '7,703', country: ['China'] }, { name: 'Gurla Mandhata', elevation: '7,694', country: ['China'] }, { name: 'Saser Kangri I', elevation: '7,672', country: ['India'] }, { name: 'Chogolisa', elevation: '7,665', country: ['Pakistan'] }, { name: 'Dhaulagiri IV', elevation: '7,661', country: ['Nepal'] }, { name: 'Kongur Tagh', elevation: '7,649', country: ['China'] }, { name: 'Dhaulagiri V', elevation: '7,618', country: ['Nepal'] }, { name: 'Shispare', elevation: '7,611', country: ['Pakistan'] }, { name: 'Trivor', elevation: '7,577', country: ['Pakistan'] }, { name: 'Gangkhar Puensum', elevation: '7,570', country: ['Bhutan', 'China'] }, { name: 'Gongga Shan', elevation: '7,556', country: ['China'] }, { name: 'Annapurna III', elevation: '7,555', country: ['Nepal'] }, { name: 'Skyang Kangri', elevation: '7,545', country: ['Pakistan', 'China'] }, { name: 'Changtse', elevation: '7,543', country: ['China'] }, { name: 'Kula Kangri', elevation: '7,538', country: ['China', 'Bhutan'] }, { name: 'Kongur Tiube', elevation: '7,530', country: ['China'] }, { name: 'Mamostong Kangri', elevation: '7,516', country: ['India'] }, { name: 'Saser Kangri II E', elevation: '7,513', country: ['India'] }, { name: 'Muztagh Ata', elevation: '7,509', country: ['China'] }, { name: 'Ismoil Somoni Peak', elevation: '7,495', country: ['Tajikistan'] }, { name: 'Saser Kangri III', elevation: '7,495', country: ['India'] }, { name: 'Noshaq', elevation: '7,492', country: ['Afghanistan', 'Pakistan'] }, { name: 'Pumari Chhish', elevation: '7,492', country: ['Pakistan'] }, { name: 'Passu Sar', elevation: '7,476', country: ['Pakistan'] }, { name: 'Yukshin Gardan Sar', elevation: '7,469', country: ['Pakistan'] }, { name: 'Teram Kangri I', elevation: '7,462', country: ['India', 'China'] }, { name: 'Jongsong Peak', elevation: '7,462', country: ['India', 'China', 'Nepal'] }, { name: 'Malubiting', elevation: '7,458', country: ['Pakistan'] }, { name: 'Gangapurna', elevation: '7,455', country: ['Nepal'] }, { name: 'Jengish Chokusu', elevation: '7,439', country: ['Kyrgyzstan', 'China'] }, { name: 'Sunanda Devi', elevation: '7,434', country: ['India'] }, { name: 'K12', elevation: '7,428', c.........完整代码请登录后点击上方下载按钮下载查看
网友评论0