制作TimeLine物流信息展示效果
var TimeLine = function (_id) {
this.id = _id;
this._top = 40;
this.vHeight = 40;
this.global_top = 40;
this.line_height = 4;
this.radius = 6;
this.startPosition = 6;
this.text_top = 40;
this.text_margin = 20;
this.text_left = [6, 15];
this.canvas = null;
this.totalWidth = 0;
this.totalHeight = 0;
this.context = null;
this.stepPosition = 100;
this.font = "bold 35px sans-serif";
this.Init();
};
TimeLine.prototype = {
Init: function () {
this.canvas = document.getElementById(this.id);
if (this.canvas == null) {
return false;
}
this.totalWidth = this.canvas.clientWidth * 0.95;
this.totalHeight = this.canvas.clientHeight;
this.stepPosition = 0.1 * this.totalWidth;
this.global_top = 0.1 * this.totalHeight;
this.vHeight = 0.1 * this.totalHeight;
this.text_margin = 0.06 * this.totalHeight;
this.radius = 0.01 * this.totalHeight;
this.text_left = [0.01 * this.totalHeight, 0.01 * this.totalWidth];
this.startPosition = 0.02 * this.totalWidth;
this.context = this.canvas.getContext("2d");
//每次重绘前清空
this.context.clearRect(0, 0, this.totalWidth, this.totalHeight);
},
/**
*strDate:时间
*strContent:显示文本
*direction:走势,0水平,1垂直,-1结束
*status:状态,1,2已完成,0未完成
*/
AddEvent: function (strDate, strContent, direction, status) {
if (this.canvas == null) {
return false;
}
var okColor = 'green', onColor = 'gray';
var passColor = "rgba(0,255,0,0.5)", waitColor = "rgba(99,99,99,0.5)";
var passStrokeColor = "green", waitStrokeColor = "rgba(99,99,99,0.5)";
if (direction == 0) {
this.stepPosition = strContent.length * 6;
if (this.stepPosition < 0.20 * this.totalWidth) this.stepPosition = 0.20 * this.totalWidth;
//设置透明度实践证明透明度值>0,<1值越低,越透明,值>=1时为纯色,值<=0时为完全透明
this.context.fillStyle = ((status == 1 || status == 2) ? passColor : waitColor);
this.context.fillRect(this.startPosition + this.radius, this.global_top, this.stepPosition, this.line_height);
//设置新图形(红色圆形)
this.context.beginPath();
this.context.fillStyle = ((status == 1 || status == 2) ? okColor : onColor);
this.context.arc(this.startPosition + this.line_height / 2, this.global_top + this.line_height / 2, this.radius, 0, Math.PI * 2, false);
this.context.fill();
this.context.fillStyle = ((status == 1 || status == 2) ? okColor : onColor);
this.context.font = this.font;
//this.text_top=this.global_top+this.line_height+this.text_margin;
this.text_top = this.text_margin;
//context.strokeStyle = ((status==1||status==2)?passStrokeColor:waitStrokeColor);
//context.strokeText(strContent,this.startPosition+text_left[0],this.text_top);
this.context.fillText(strContent, this.startPosition + this.text_left[0], this.text_top);
this.context.fillText(strDate, this.startPosition + this.text_left[0], this.global_top + this.text_top + 10);
this.startPosition += this.stepPosition;
}
else if (direction == 1) {
stepPosition = 50;
//设置透明度实践证明透明度值>0,<1值越低,越透明,值>=1时为纯色,值<=0时为完全透明
this.context.fillStyle = ((status == 1) ? passColor : waitColor);
this.context.fillRect(this.startPosition, this.vHeight + this.radius + this.line_height / 2, this.line_height, this.stepPosition * 0.2);
this.vHeight += this.stepPosition * 0.2;
this._top += +this.stepPosition * 0.2;
//设置新图形(红色圆形)
this.context.beginPath();
this.context.fillStyle = ((status == 1) ? okColor : onColor);
this.context.arc(this.startPosition + this.line_height / 2, this.vHeight + this.line_height / 2, this.radius, 0, Math.PI * 2, false);
this.context.fill();
this.context.fillStyle = ((status == 1) ? okColor : onColor);
this.context.font = this.font;
this.text_top = this._top + this.line_height / 2;
//this.context.strokeStyle = ((status==1)?passStrokeColor:waitStrokeColor);
//this.context.strokeText(strDate+' '+strContent,this.startPosition+text_left[1],this.text_top);
this.context.fillText(strDate + ' ' + strContent, this.startPosition + this.text_left[1], this.vHeight + 10);
//this.context.fillText(strContent,this.startPosition+this.text_left[1],this.text_top+this.text_margin);
}
else if (direction == -1) {
//设置透明度实践证明透明度值>0,<1值越低,越透明,值>=1时为纯色,值<=0时为完全透明
this.context.fillStyle = ((status == 1 || status == 2) ? passColor : waitColor);
this.context.fillRect(this.startPosition + this.radius, this.global_top, this.stepPosition * 0.7, this.line_height);
//设置新图形(红色圆形)
this.context.beginPath();
this.context.fillStyle = ((status == 1 || status == 2) ? okColor : onColor);
this.context.arc(this.startPosition + this.line_height / 2 + this.stepPosition * 0.7 + this.radius, this.global_top + this.line_height / 2, this.radius, 0, Math.PI * 2, false);
this.context.fill();
this.context.fillStyle = ((status == 1 || status == 2) ? okColor : onColor);
this.context.font = this.font;
this.text_top = this.text_margin;
//context.strokeStyle = ((status==1||status==2)?passStrokeColor:waitStrokeColor);
//context.strokeText(strContent,this.startPosition+this.text_left[0]+this.stepPosition*2.5,this.text_top);
this.context.fillText(strContent, this.startPosition + this.text_left[0] + this.stepPosition * 0.4, this.text_top);
this.context.fillText(strDate, this.startPosition + this.text_left[0] + this.stepPosition * 0.4, this.global_top + this.text_margin + 10);
}
}
};
制作TimeLine物流信息展示效果的更多相关文章
- Photoshop将普通照片快速制作二次元漫画风格效果
今天为大家分享Photoshop将普通照片快速制作二次元漫画风格效果,教程很不错,对于喜欢漫画的朋友可以参考本文,希望能对大家有所帮助! 一提到日本动画电影,大家第一印象肯定是宫崎骏,但是日本除了宫崎 ...
- Simptip – 使用 Sass 制作的 CSS Tooltip 效果
Simptip 是一个简单基于 Sass 的 CSS 工具提示效果.帮助你在网站中加入在不同的方向(上.左.右.下)的工具提示,也可以设置不同的颜色如成功.信息.警告和危险.最后还有其他特性如软边.半 ...
- Elastislide - 响应式的图片循环展示效果
Elastislide 是一款非常优秀的响应式 jQuery 图片循环展示(旋转木马)插件,集成了 Touchwipe 插件以支持触屏设备.提供了四种效果:水平图片传送带.垂直图片传送带.固定在屏幕底 ...
- 利用TabHost制作QQ客户端标签栏效果(低版本QQ)
学习一定要从基础学起,只有有一个好的基础,我们才会变得更加的perfect 下面小编将利用TabHost制作QQ客户端标签栏效果(这个版本的QQ是在前几年发布的)…. 首先我们看一下效果: 看到这个界 ...
- JS实现有点炫的图片展示效果-图片解体和组合
经过4个月的努力学习,迎来了进入市场的最后一个学习项目.自己模仿了一个图片展示效果,用在了项目中,感觉挺炫的.在这里分享一下,希望大家喜欢~! bomb-showImg : 在线演示http://ru ...
- 响应式的dribbble作品集魔术布局展示效果
在线演示1 本地下载 相信做设计的朋友肯定都知道dribbble.com,它是一个非常棒的设计师分享作品的网站,全世界数以万计的设计高手和行家都在这个网站上分享自己的作品,当然,如果你常在上面闲逛的话 ...
- jQuery制作Web全屏效果
需要的资源 1.jQuery版本库是必不可少的2.jQuery FullScreen plugin如果你下载不方便的话,你可以直接把下面的代码copy到你本地JQuery FullScreen plu ...
- CSS3 实现六边形Div图片展示效果
原文:CSS3 实现六边形Div图片展示效果 效果图: 实现原理: 这个效果的主要css样式有: 1.>transform: rotate(120deg); 图片旋转 2.>overflo ...
- cesium 之地图切换展示效果篇(附源码下载)
前言 cesium 官网的api文档介绍地址cesium官网api,里面详细的介绍 cesium 各个类的介绍,还有就是在线例子:cesium 官网在线例子,这个也是学习 cesium 的好素材. 内 ...
随机推荐
- 图解HTTP总结(2)——简单的HTTP协议
HTTP协议是一种不保存状态,即无状态(stateless)协议.HTTP协议自身不对请求和响应之间的通信状态进行保存.也就是说在HTTP这个级别,协议对于发送过的请求或响应都不做持久化处理. 使用H ...
- 3、springboot配置文件占位符
RandomValuePropertySource:配置文件中可以使用随机数 ${random.value}.${random.int}.${random.long}.${random.int(10) ...
- 笔记-python-lib-contextlib
笔记-python-lib-contextlib 1. contextlib with 语句很好用,但不想每次都写__enter_-和__exit__方法: py标准库也为此提供了工具模块c ...
- tar命令,vi编辑器
一.将用户信息数据库文件和组信息数据库文件纵向合并为一个文件/1.txt(覆盖): [root@localhost /]# cat /etc/passwd /etc/group > 1.txt ...
- scala高级特性-01
目标一:深入理解高阶函数 高阶函数 1.1概念 Scala混合了面向对象和函数式的特性, 我们通常将可以做为参数传递到方法中的表达式叫做函数. 在函数式编程语言中,函数是“头等公民”, 高阶函数包含: ...
- MAC中mongodb的连接遇到的问题及调试
今天在MAC环境下连接mongodb,遇到了一些报错,最终调试全部搞定.在此特做记录! 首先,mongod启动失败 上面有一句话是 exception in initAndListen: 20 Att ...
- java.lang.RuntimeException: Handler (com.***.behavior.BEvent$1) {421bca80} sending message to a Hand
java.lang.RuntimeException: Handler (com.***.behavior.BEvent$1) {421bca80} sending message to a Hand ...
- Result Maps collection does not contain value for XXXXX
在做mybatis多表查询的时候,出现了下面的错误: java.lang.IllegalArgumentException: Result Maps collection does not conta ...
- TCP close seq问题
测试mt_hls一条流时,发现会话的时长总是对应不上. 仔细观察发现: 注意 1.包1735 (客户端) 发送FIN 请求,seq = 2435582428 2.包1736,1737,1738 (服务 ...
- wget 下载页面下所有文件
先介绍几个参数:-c 断点续传(备注:使用断点续传要求服务器支持断点续传),-r 递归下载(目录下的所有文件,包括子目录),-np 递归下载不搜索上层目录,-k 把绝对链接转为相对链接,这样下载之后的 ...