Commit 7183693da093d827f66af114fc5ec8fe243d2a2d
1 parent
d893e4ae
电子站牌项目
1、修改package.json,添加moment依赖 2、添加自定义日期时间显示控件(bsth-datetime.css,bsth-datetime.js,bsth-weather-realtime.js) 3、修改index.js,导入日期时间显示控件
Showing
9 changed files
with
450 additions
and
9 deletions
front-end/h5/package.json
| @@ -29,6 +29,7 @@ | @@ -29,6 +29,7 @@ | ||
| 29 | "font-awesome": "4.7.0", | 29 | "font-awesome": "4.7.0", |
| 30 | "hotkeys-js": "^3.7.6", | 30 | "hotkeys-js": "^3.7.6", |
| 31 | "html2canvas": "^1.0.0-rc.3", | 31 | "html2canvas": "^1.0.0-rc.3", |
| 32 | + "moment": "^2.29.1", | ||
| 32 | "papaparse": "^5.2.0", | 33 | "papaparse": "^5.2.0", |
| 33 | "proxy-agent": "^3.1.0", | 34 | "proxy-agent": "^3.1.0", |
| 34 | "qrcode": "^1.4.1", | 35 | "qrcode": "^1.4.1", |
front-end/h5/public/index.html
| @@ -15,9 +15,7 @@ | @@ -15,9 +15,7 @@ | ||
| 15 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> | 15 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 16 | <meta name="viewport" content="width=device-width,initial-scale=1.0"> | 16 | <meta name="viewport" content="width=device-width,initial-scale=1.0"> |
| 17 | <link rel="icon" href="<%= BASE_URL %>favicon.ico"> | 17 | <link rel="icon" href="<%= BASE_URL %>favicon.ico"> |
| 18 | - <title>鲁班-H5</title> | ||
| 19 | - <meta content="拖拽生成,拖拽生成页面,页面可视化,鲁班可视化搭建平台,鲁班,鲁班H5,可视化搭建,可视化平台,可视化搭建平台,开源易企秀,开源人人秀,开源百度H5,lubanh5,luban-h5,webpage buiilder,page builder,h5 builder" name="keywords" /> | ||
| 20 | - <meta content="鲁班H5-是一款基于Vue2.0 + 常见业务组件,可以通过拖拽的形式生成页面,类似易企秀、百度 H5 的可视化搭建系统;我们的初心也是希望能通过工程化的手段,大幅度提高简单H5页面的制作效率,提高工程师的幸福感,从这种需求频繁变更的简单任务中解脱出来" name="description" /> | 18 | + <title>电子站牌编辑器</title> |
| 21 | <style> | 19 | <style> |
| 22 | * { | 20 | * { |
| 23 | outline: none; | 21 | outline: none; |
front-end/h5/src/components/common/header/logo.js
| 1 | export default { | 1 | export default { |
| 2 | render () { | 2 | render () { |
| 3 | - return <div class="logo"><router-link to={{ path: '/' }}> | 3 | + return <div style="width: 150px;" class="logo"><router-link to={{ path: '/' }}> |
| 4 | {/* 鲁班 H5 Luban H5 */} | 4 | {/* 鲁班 H5 Luban H5 */} |
| 5 | {this.$t('app.title')} | 5 | {this.$t('app.title')} |
| 6 | </router-link></div> | 6 | </router-link></div> |
front-end/h5/src/components/core/plugins/bsth/bsth-datetime.css
0 → 100644
front-end/h5/src/components/core/plugins/bsth/bsth-datetime.js
0 → 100644
| 1 | +/** | ||
| 2 | + * 自定义日期时间显示组件。 | ||
| 3 | + */ | ||
| 4 | +import PropTypes from '@luban-h5/plugin-common-props' | ||
| 5 | +import './bsth-datetime.css' | ||
| 6 | +import moment from 'moment' | ||
| 7 | + | ||
| 8 | +export default { | ||
| 9 | + extra: { | ||
| 10 | + defaultStyle: { // 默认属性 | ||
| 11 | + top: 0, | ||
| 12 | + left: 0, | ||
| 13 | + width: 260, | ||
| 14 | + height: 90 | ||
| 15 | + } | ||
| 16 | + }, | ||
| 17 | + name: 'bsth-datetime', | ||
| 18 | + data () { | ||
| 19 | + // eslint-disable-next-line | ||
| 20 | + this.private_jQuery = jQuery.noConflict() // jquery引用 | ||
| 21 | + // eslint-disable-next-line | ||
| 22 | + this.private_d3 = d3 // d3引用 | ||
| 23 | + | ||
| 24 | + this.private_svg = null // 创建的根svg元素,由mounted钩子函数创建 | ||
| 25 | + this.private_date_svg_g = null // 包含日期的最外层g元素 | ||
| 26 | + this.private_time_svg_g = null // 包含时间的最外层g元素 | ||
| 27 | + | ||
| 28 | + return { | ||
| 29 | + // 日期数据 | ||
| 30 | + internalDate: { | ||
| 31 | + value: '1970年10月1日 星期一', // 格式:1970年10月1日 星期一 | ||
| 32 | + count: 0 | ||
| 33 | + }, | ||
| 34 | + // 时间数据 | ||
| 35 | + internalTime: { | ||
| 36 | + value: '12:00:00', // 格式:12:00:00 | ||
| 37 | + count: 0 | ||
| 38 | + }, | ||
| 39 | + internalTimer: { // 日期时间数据timer | ||
| 40 | + timer: null, | ||
| 41 | + count: 0, | ||
| 42 | + millisecond: 1000 | ||
| 43 | + }, | ||
| 44 | + /** | ||
| 45 | + * 监控外层元素的宽度高度变化 | ||
| 46 | + * 1、由于编辑器缩放,自定义组件无法监控,所以需要定义一个定时器监控最外层元素的大小变化 | ||
| 47 | + * 2、建议所有自定义组件,最外层都定义一个div包在自定义组件最外层,不要关联任何自定义的属性,样式对应编辑器的通用样式 | ||
| 48 | + */ | ||
| 49 | + watchWidthHeightTimer: { | ||
| 50 | + timer: null, | ||
| 51 | + count: 0, | ||
| 52 | + millisecond: 1000 | ||
| 53 | + }, | ||
| 54 | + datetime_diagram_width: 260, // 图宽度 | ||
| 55 | + datetime_diagram_height: 90 // 图高度 | ||
| 56 | + } | ||
| 57 | + }, | ||
| 58 | + props: { | ||
| 59 | + useMode: PropTypes.string({ // 自定义使用模式,alone:(单独使用),child:(子组件) | ||
| 60 | + defaultValue: 'alone', | ||
| 61 | + label: '使用模式', | ||
| 62 | + visible: false | ||
| 63 | + }), | ||
| 64 | + editorMode: PropTypes.string({ // 编辑模式会由编辑器自动注入(值:edit, preview) | ||
| 65 | + defaultValue: 'preview', | ||
| 66 | + label: '模式', | ||
| 67 | + visible: false | ||
| 68 | + }), | ||
| 69 | + datetime_outer_div_width: PropTypes.number({ | ||
| 70 | + defaultValue: 260, | ||
| 71 | + label: 'bsth-datetime-outer-div样式的div宽度', | ||
| 72 | + visible: false | ||
| 73 | + }), | ||
| 74 | + datetime_outer_div_height: PropTypes.number({ | ||
| 75 | + defaultValue: 160, | ||
| 76 | + label: 'bsth-datetime-outer-div样式的div高度', | ||
| 77 | + visible: false | ||
| 78 | + }), | ||
| 79 | + | ||
| 80 | + // 图外层css | ||
| 81 | + _flag_1_: PropTypes.string({ label: '', component: null, extra: function (h) { return (<hr data-label="图外层css属性" class="bsth-line-item-divider"></hr>) } }), | ||
| 82 | + margin_left: PropTypes.number({ label: '图左边margin', defaultValue: 0, layout: { prefixCls: 'bsth-line' } }), | ||
| 83 | + margin_right: PropTypes.number({ label: '图右边margin', defaultValue: 0, layout: { prefixCls: 'bsth-line' } }), | ||
| 84 | + margin_top: PropTypes.number({ label: '图上边margin', defaultValue: 0, layout: { prefixCls: 'bsth-line' } }), | ||
| 85 | + margin_bottom: PropTypes.number({ label: '图底部margin', defaultValue: 0, layout: { prefixCls: 'bsth-line' } }), | ||
| 86 | + border_size: PropTypes.number({ label: '图边框宽度', defaultValue: 1, layout: { prefixCls: 'bsth-line' } }), | ||
| 87 | + background_color: PropTypes.color({ label: '背景颜色', defaultValue: '#FFFFFF', layout: { prefixCls: 'bsth-line' } }), | ||
| 88 | + // 日期显示css | ||
| 89 | + _flag_2_: PropTypes.string({ label: '', component: null, extra: function (h) { return (<hr data-label="日期css属性" class="bsth-line-item-divider"></hr>) } }), | ||
| 90 | + date_left_padding: PropTypes.number({ label: '日期显示距离左边padding', defaultValue: 15, layout: { prefixCls: 'bsth-line' } }), | ||
| 91 | + date_top_padding: PropTypes.number({ label: '日期显示距离上边padding', defaultValue: 30, layout: { prefixCls: 'bsth-line' } }), | ||
| 92 | + date_font_size: PropTypes.number({ label: '日期字体大小', defaultValue: 16, layout: { prefixCls: 'bsth-line' } }), | ||
| 93 | + date_font_color: PropTypes.color({ label: '日期字体颜色', defaultValue: '#000000', layout: { prefixCls: 'bsth-line' } }), | ||
| 94 | + // 时间显示css | ||
| 95 | + _flag_3_: PropTypes.string({ label: '', component: null, extra: function (h) { return (<hr data-label="时间css属性" class="bsth-line-item-divider"></hr>) } }), | ||
| 96 | + time_left_padding: PropTypes.number({ label: '时间显示距离左边padding', defaultValue: 10, layout: { prefixCls: 'bsth-line' } }), | ||
| 97 | + time_top_padding: PropTypes.number({ label: '时间显示距离上边padding', defaultValue: 70, layout: { prefixCls: 'bsth-line' } }), | ||
| 98 | + time_font_size: PropTypes.number({ label: '时间字体大小', defaultValue: 30, layout: { prefixCls: 'bsth-line' } }), | ||
| 99 | + time_font_color: PropTypes.color({ label: '时间字体颜色', defaultValue: '#000000', layout: { prefixCls: 'bsth-line' } }) | ||
| 100 | + }, | ||
| 101 | + render () { | ||
| 102 | + const innerDivStyle = { | ||
| 103 | + 'width': this.datetime_diagram_width + 'px', | ||
| 104 | + 'height': this.datetime_diagram_height + 'px', | ||
| 105 | + 'border': this.border_size + 'px solid black', | ||
| 106 | + 'margin-left': this.margin_left + 'px', | ||
| 107 | + 'margin-right': this.margin_right + 'px', | ||
| 108 | + 'margin-top': this.margin_top + 'px', | ||
| 109 | + 'margin-bottom': this.margin_bottom + 'px', | ||
| 110 | + 'background': this.background_color, | ||
| 111 | + 'position': 'relative', | ||
| 112 | + 'overflow': 'hidden' | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + /** 最外层div对应编辑器的通用样式 */ | ||
| 116 | + return ( | ||
| 117 | + <div class="bsth-datetime-outer-div"> | ||
| 118 | + <div style={innerDivStyle}> | ||
| 119 | + <svg class="datetime-chart" | ||
| 120 | + style={{ 'height': this.datetime_diagram_height + 'px' }}> | ||
| 121 | + <g class="date"></g> | ||
| 122 | + <g class="time"></g> | ||
| 123 | + </svg> | ||
| 124 | + </div> | ||
| 125 | + </div> | ||
| 126 | + ) | ||
| 127 | + }, | ||
| 128 | + created () {}, | ||
| 129 | + mounted () { | ||
| 130 | + // 1、获取svg元素 | ||
| 131 | + this.private_svg = this.findD3SvgDom() | ||
| 132 | + this.private_date_svg_g = this.findD3DateSvgG() | ||
| 133 | + this.private_time_svg_g = this.findD3TimeSvgG() | ||
| 134 | + // 2、使用外部元素的框架定义图的长宽 | ||
| 135 | + let $jQuery = this.private_jQuery | ||
| 136 | + this.datetime_diagram_width = $jQuery(this.$el).width() - this.margin_left - this.margin_right | ||
| 137 | + this.datetime_diagram_height = $jQuery(this.$el).height() - this.margin_top - this.margin_bottom | ||
| 138 | + if (this.useMode === 'child') { | ||
| 139 | + this.datetime_diagram_width = this.datetime_outer_div_width - this.margin_left - this.margin_right | ||
| 140 | + this.datetime_diagram_height = this.datetime_outer_div_height - this.margin_top - this.margin_bottom | ||
| 141 | + } | ||
| 142 | + // 3、开启外部元素长宽监控计数 | ||
| 143 | + /** | ||
| 144 | + * 开启外部元素长宽监控逻辑(class='line-chart-outer-div') | ||
| 145 | + * 1、使用模式是alone,并且是编辑模式edit | ||
| 146 | + * 2、preview预览模式下有条件监控 | ||
| 147 | + */ | ||
| 148 | + if (this.useMode === 'alone' && this.editorMode === 'edit') { | ||
| 149 | + this.watchWidthHeightTimer.count++ | ||
| 150 | + } | ||
| 151 | + // 4、刷新svg | ||
| 152 | + this.refreshInternalData() | ||
| 153 | + this.refreshDateSvg() | ||
| 154 | + this.refreshTimeSvg() | ||
| 155 | + // 5、开启internalData监控 | ||
| 156 | + if (this.editorMode === 'preview') { | ||
| 157 | + this.internalTimer.count++ | ||
| 158 | + } | ||
| 159 | + }, | ||
| 160 | + destroyed () { | ||
| 161 | + // 组件删除的时候,删除监控定时器 | ||
| 162 | + let timer = this.watchWidthHeightTimer.timer | ||
| 163 | + if (timer) { | ||
| 164 | + clearTimeout(timer) | ||
| 165 | + this.watchWidthHeightTimer.timer = null | ||
| 166 | + } | ||
| 167 | + timer = this.internalTimer.timer | ||
| 168 | + if (timer) { | ||
| 169 | + clearTimeout(timer) | ||
| 170 | + this.internalTimer.timer = null | ||
| 171 | + } | ||
| 172 | + }, | ||
| 173 | + watch: { | ||
| 174 | + 'watchWidthHeightTimer.count' () { // 定时器监控 | ||
| 175 | + let timer = this.watchWidthHeightTimer.timer | ||
| 176 | + if (timer) { | ||
| 177 | + clearTimeout(timer) | ||
| 178 | + this.watchWidthHeightTimer.timer = null | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + let self = this | ||
| 182 | + let $jQuery = this.private_jQuery | ||
| 183 | + self.watchWidthHeightTimer.timer = setTimeout(function () { | ||
| 184 | + // 处理逻辑 | ||
| 185 | + let width = $jQuery(self.$el).width() | ||
| 186 | + let height = $jQuery(self.$el).height() | ||
| 187 | + | ||
| 188 | + if (width !== self.line_width) { | ||
| 189 | + self.datetime_diagram_width = width - self.margin_left - self.margin_right | ||
| 190 | + } | ||
| 191 | + if (height !== self.line_height) { | ||
| 192 | + self.datetime_diagram_height = height - self.margin_top - self.margin_bottom | ||
| 193 | + } | ||
| 194 | + self.watchWidthHeightTimer.count++ | ||
| 195 | + }, self.watchWidthHeightTimer.millisecond) | ||
| 196 | + }, | ||
| 197 | + 'internalTimer.count' () { | ||
| 198 | + let timer = this.internalTimer.timer | ||
| 199 | + if (timer) { | ||
| 200 | + clearTimeout(timer) | ||
| 201 | + this.internalTimer.timer = null | ||
| 202 | + } | ||
| 203 | + let self = this | ||
| 204 | + self.internalTimer.timer = setTimeout(function () { | ||
| 205 | + // 处理逻辑 | ||
| 206 | + self.refreshInternalData() | ||
| 207 | + self.refreshDateSvg() | ||
| 208 | + self.refreshTimeSvg() | ||
| 209 | + self.internalTimer.count++ | ||
| 210 | + }, self.internalTimer.millisecond) | ||
| 211 | + }, | ||
| 212 | + /** | ||
| 213 | + * 当组件作为子组件使用时(useMode=child),bsth-datetime-outer-div样式的div尺寸无法通过编辑器改变(通用样式) | ||
| 214 | + * 必须由父组件设定,自组件需要监控改变 | ||
| 215 | + */ | ||
| 216 | + datetime_outer_div_width: function (val) { | ||
| 217 | + let self = this | ||
| 218 | + if (self.useMode === 'child') { | ||
| 219 | + self.datetime_diagram_width = val - self.margin_left - self.margin_right | ||
| 220 | + } | ||
| 221 | + }, | ||
| 222 | + datetime_outer_div_height: function (val) { | ||
| 223 | + let self = this | ||
| 224 | + if (self.useMode === 'child') { | ||
| 225 | + self.datetime_diagram_height = val - self.margin_top - self.margin_bottom | ||
| 226 | + } | ||
| 227 | + }, | ||
| 228 | + // ----------- 本身宽高 ---------- // | ||
| 229 | + datetime_diagram_width () { | ||
| 230 | + this.refreshDateSvg() | ||
| 231 | + this.refreshTimeSvg() | ||
| 232 | + }, | ||
| 233 | + datetime_diagram_height () { | ||
| 234 | + this.refreshDateSvg() | ||
| 235 | + this.refreshTimeSvg() | ||
| 236 | + }, | ||
| 237 | + // ----------- 图外层css 监控 ----------- // | ||
| 238 | + margin_left () { | ||
| 239 | + let self = this | ||
| 240 | + self.datetime_diagram_width = self.datetime_diagram_width - self.margin_left - self.margin_right | ||
| 241 | + }, | ||
| 242 | + margin_right () { | ||
| 243 | + let self = this | ||
| 244 | + self.datetime_diagram_width = self.datetime_diagram_width - self.margin_left - self.margin_right | ||
| 245 | + }, | ||
| 246 | + margin_top () { | ||
| 247 | + let self = this | ||
| 248 | + self.datetime_diagram_height = self.datetime_diagram_height - self.margin_top - self.margin_bottom | ||
| 249 | + }, | ||
| 250 | + margin_bottom () { | ||
| 251 | + let self = this | ||
| 252 | + self.datetime_diagram_height = self.datetime_diagram_height - self.margin_top - self.margin_bottom | ||
| 253 | + }, | ||
| 254 | + border_size () { | ||
| 255 | + this.refreshDateSvg() | ||
| 256 | + this.refreshTimeSvg() | ||
| 257 | + }, | ||
| 258 | + // ------------ 日期css 监控 ----------- // | ||
| 259 | + date_left_padding () { | ||
| 260 | + this.refreshDateSvg() | ||
| 261 | + }, | ||
| 262 | + date_top_padding () { | ||
| 263 | + this.refreshDateSvg() | ||
| 264 | + }, | ||
| 265 | + date_font_size (val) { | ||
| 266 | + let svg = this.private_date_svg_g | ||
| 267 | + svg.selectAll('text') | ||
| 268 | + .style('font-size', val) | ||
| 269 | + }, | ||
| 270 | + date_font_color (val) { | ||
| 271 | + let svg = this.private_date_svg_g | ||
| 272 | + svg.selectAll('text') | ||
| 273 | + .style('fill', val) | ||
| 274 | + // .style('stroke', val) | ||
| 275 | + }, | ||
| 276 | + // ------------ 时间css 监控 ----------- // | ||
| 277 | + time_left_padding () { | ||
| 278 | + this.refreshTimeSvg() | ||
| 279 | + }, | ||
| 280 | + time_top_padding () { | ||
| 281 | + this.refreshTimeSvg() | ||
| 282 | + }, | ||
| 283 | + time_font_size (val) { | ||
| 284 | + let svg = this.private_time_svg_g | ||
| 285 | + svg.selectAll('text') | ||
| 286 | + .style('font-size', val) | ||
| 287 | + }, | ||
| 288 | + time_font_color (val) { | ||
| 289 | + let svg = this.private_time_svg_g | ||
| 290 | + svg.selectAll('text') | ||
| 291 | + .style('fill', val) | ||
| 292 | + // .style('stroke', val) | ||
| 293 | + } | ||
| 294 | + }, | ||
| 295 | + methods: { | ||
| 296 | + findD3SvgDom () { | ||
| 297 | + let $jQuery = this.private_jQuery | ||
| 298 | + let d3 = this.private_d3 | ||
| 299 | + let svgDom = $jQuery(this.$el).find('svg')[0] | ||
| 300 | + return d3.select(svgDom) | ||
| 301 | + }, | ||
| 302 | + findD3DateSvgG () { | ||
| 303 | + let $jQuery = this.private_jQuery | ||
| 304 | + let d3 = this.private_d3 | ||
| 305 | + let svgGDom = $jQuery(this.$el).find('svg g.date')[0] | ||
| 306 | + return d3.select(svgGDom) | ||
| 307 | + }, | ||
| 308 | + findD3TimeSvgG () { | ||
| 309 | + let $jQuery = this.private_jQuery | ||
| 310 | + let d3 = this.private_d3 | ||
| 311 | + let svgGDom = $jQuery(this.$el).find('svg g.time')[0] | ||
| 312 | + return d3.select(svgGDom) | ||
| 313 | + }, | ||
| 314 | + refreshInternalData () { | ||
| 315 | + let _dateNow = new Date() | ||
| 316 | + this.internalDate.value = moment(_dateNow).locale('zh-cn').format('YYYY年MM月DD日 dddd') | ||
| 317 | + this.internalTime.value = moment(_dateNow).format('HH:mm:ss') | ||
| 318 | + }, | ||
| 319 | + refreshDateSvg () { | ||
| 320 | + let self = this | ||
| 321 | + | ||
| 322 | + // let $jQuery = self.private_jQuery | ||
| 323 | + let d3 = self.private_d3 | ||
| 324 | + let width = self.datetime_diagram_width - self.border_size * 2 | ||
| 325 | + let height = self.datetime_diagram_height - self.border_size * 2 | ||
| 326 | + | ||
| 327 | + let dateSvgG = self.private_date_svg_g | ||
| 328 | + | ||
| 329 | + // ----------- 绘制svg ---------- // | ||
| 330 | + let xScale = d3.scaleLinear() | ||
| 331 | + .domain([0, 1]) | ||
| 332 | + .range([self.date_left_padding, width - self.date_left_padding]) | ||
| 333 | + let yScale = d3.scaleLinear() | ||
| 334 | + .domain([0, 1]) | ||
| 335 | + .range([self.date_top_padding, height - self.date_top_padding]) | ||
| 336 | + let dateTextUpdate = dateSvgG.selectAll('text') | ||
| 337 | + .data([self.internalDate], function (d) { | ||
| 338 | + return d.count // 使用count作为key | ||
| 339 | + }) | ||
| 340 | + let dateTextEnter = dateTextUpdate | ||
| 341 | + let dateTextExit = dateTextUpdate.exit() | ||
| 342 | + dateTextExit.remove() | ||
| 343 | + | ||
| 344 | + dateTextEnter.enter().append('text') | ||
| 345 | + .style('font-size', self.date_font_size + 'px') | ||
| 346 | + .style('fill', self.date_font_color) | ||
| 347 | + // .style('stroke', self.date_font_color) | ||
| 348 | + .text(function (d) { | ||
| 349 | + return d.value | ||
| 350 | + }) | ||
| 351 | + .attr('x', function () { | ||
| 352 | + return xScale(0) | ||
| 353 | + }) | ||
| 354 | + .attr('y', function () { | ||
| 355 | + return yScale(0) | ||
| 356 | + }) | ||
| 357 | + dateTextUpdate | ||
| 358 | + .text(function (d) { | ||
| 359 | + return d.value | ||
| 360 | + }) | ||
| 361 | + .attr('x', function () { | ||
| 362 | + return xScale(0) | ||
| 363 | + }) | ||
| 364 | + .attr('y', function () { | ||
| 365 | + return yScale(0) | ||
| 366 | + }) | ||
| 367 | + }, | ||
| 368 | + refreshTimeSvg () { | ||
| 369 | + let self = this | ||
| 370 | + | ||
| 371 | + // let $jQuery = self.private_jQuery | ||
| 372 | + let d3 = self.private_d3 | ||
| 373 | + let width = self.datetime_diagram_width - self.border_size * 2 | ||
| 374 | + let height = self.datetime_diagram_height - self.border_size * 2 | ||
| 375 | + | ||
| 376 | + let timeSvgG = self.private_time_svg_g | ||
| 377 | + | ||
| 378 | + // ----------- 绘制svg ---------- // | ||
| 379 | + let xScale = d3.scaleLinear() | ||
| 380 | + .domain([0, 1]) | ||
| 381 | + .range([self.time_left_padding, width - self.time_left_padding]) | ||
| 382 | + let yScale = d3.scaleLinear() | ||
| 383 | + .domain([0, 1]) | ||
| 384 | + .range([self.time_top_padding, height - self.time_top_padding]) | ||
| 385 | + let timeTextUpdate = timeSvgG.selectAll('text') | ||
| 386 | + .data([self.internalTime], function (d) { | ||
| 387 | + return d.count // 使用count作为key | ||
| 388 | + }) | ||
| 389 | + let timeTextEnter = timeTextUpdate | ||
| 390 | + let timeTextExit = timeTextUpdate.exit() | ||
| 391 | + timeTextExit.remove() | ||
| 392 | + | ||
| 393 | + timeTextEnter.enter().append('text') | ||
| 394 | + .style('font-size', self.time_font_size + 'px') | ||
| 395 | + .style('fill', self.time_font_color) | ||
| 396 | + // .style('stroke', self.time_font_color) | ||
| 397 | + .text(function (d) { | ||
| 398 | + return d.value | ||
| 399 | + }) | ||
| 400 | + .attr('x', function () { | ||
| 401 | + return xScale(0) | ||
| 402 | + }) | ||
| 403 | + .attr('y', function () { | ||
| 404 | + return yScale(0) | ||
| 405 | + }) | ||
| 406 | + timeTextUpdate | ||
| 407 | + .text(function (d) { | ||
| 408 | + return d.value | ||
| 409 | + }) | ||
| 410 | + .attr('x', function () { | ||
| 411 | + return xScale(0) | ||
| 412 | + }) | ||
| 413 | + .attr('y', function () { | ||
| 414 | + return yScale(0) | ||
| 415 | + }) | ||
| 416 | + } | ||
| 417 | + } | ||
| 418 | +} |
front-end/h5/src/components/core/plugins/bsth/bsth-weather-realtime.js
| @@ -57,12 +57,12 @@ export default { | @@ -57,12 +57,12 @@ export default { | ||
| 57 | }), | 57 | }), |
| 58 | weather_outer_div_width: PropTypes.number({ | 58 | weather_outer_div_width: PropTypes.number({ |
| 59 | defaultValue: 260, | 59 | defaultValue: 260, |
| 60 | - label: 'line-chart-outer-div样式的div宽度', | 60 | + label: 'bsth-weather-outer-div样式的div宽度', |
| 61 | visible: false | 61 | visible: false |
| 62 | }), | 62 | }), |
| 63 | weather_outer_div_height: PropTypes.number({ | 63 | weather_outer_div_height: PropTypes.number({ |
| 64 | defaultValue: 160, | 64 | defaultValue: 160, |
| 65 | - label: 'line-chart-outer-div样式的div高度', | 65 | + label: 'bsth-weather-outer-div样式的div高度', |
| 66 | visible: false | 66 | visible: false |
| 67 | }), | 67 | }), |
| 68 | 68 | ||
| @@ -216,7 +216,7 @@ export default { | @@ -216,7 +216,7 @@ export default { | ||
| 216 | }, self.watchWidthHeightTimer.millisecond) | 216 | }, self.watchWidthHeightTimer.millisecond) |
| 217 | }, | 217 | }, |
| 218 | /** | 218 | /** |
| 219 | - * 当组件作为子组件使用时(useMode=child),bsth_weather-outer-div样式的div尺寸无法通过编辑器改变(通用样式) | 219 | + * 当组件作为子组件使用时(useMode=child),bsth-weather-outer-div样式的div尺寸无法通过编辑器改变(通用样式) |
| 220 | * 必须由父组件设定,自组件需要监控改变 | 220 | * 必须由父组件设定,自组件需要监控改变 |
| 221 | */ | 221 | */ |
| 222 | weather_outer_div_width: function (val) { | 222 | weather_outer_div_width: function (val) { |
front-end/h5/src/components/core/plugins/index.js
| @@ -25,6 +25,7 @@ import BsthLineChartList from 'core/plugins/bsth/bsth-line-chart-list' | @@ -25,6 +25,7 @@ import BsthLineChartList from 'core/plugins/bsth/bsth-line-chart-list' | ||
| 25 | import BsthLineChartScrollList from 'core/plugins/bsth/bsth-line-chart-scrollList' | 25 | import BsthLineChartScrollList from 'core/plugins/bsth/bsth-line-chart-scrollList' |
| 26 | import BsthSlide from 'core/plugins/bsth/bsth-slide' | 26 | import BsthSlide from 'core/plugins/bsth/bsth-slide' |
| 27 | import BsthWeatherRealtime from 'core/plugins/bsth/bsth-weather-realtime' | 27 | import BsthWeatherRealtime from 'core/plugins/bsth/bsth-weather-realtime' |
| 28 | +import BsthDatetime from 'core/plugins/bsth/bsth-datetime' | ||
| 28 | 29 | ||
| 29 | export const pluginsList = [ | 30 | export const pluginsList = [ |
| 30 | // { | 31 | // { |
| @@ -372,6 +373,19 @@ export const pluginsList = [ | @@ -372,6 +373,19 @@ export const pluginsList = [ | ||
| 372 | visible: true, | 373 | visible: true, |
| 373 | name: BsthWeatherRealtime.name | 374 | name: BsthWeatherRealtime.name |
| 374 | // disabled: true | 375 | // disabled: true |
| 376 | + }, | ||
| 377 | + | ||
| 378 | + { | ||
| 379 | + i18nTitle: { | ||
| 380 | + 'en-US': 'Datetime', | ||
| 381 | + 'zh-CN': '日期时间' | ||
| 382 | + }, | ||
| 383 | + title: '日期时间', | ||
| 384 | + icon: 'photo', | ||
| 385 | + component: BsthDatetime, | ||
| 386 | + visible: true, | ||
| 387 | + name: BsthDatetime.name | ||
| 388 | + // disabled: true | ||
| 375 | } | 389 | } |
| 376 | ] | 390 | ] |
| 377 | 391 |
front-end/h5/src/locales/lang/en-US.js
front-end/h5/src/locales/lang/zh-CN.js