制作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 的好素材. 内 ...
随机推荐
- 18式优雅你的Python
本文来自读者梁云同学的投稿,公众号:Python与算法之美 一,优雅你的Jupyter 1,更改Jupyter Notebook初始工作路径 平凡方法: 在cmd中输入jupyter notebook ...
- python基础之数据类型与变量patr1
1:编写for循环,利用索引遍历出每一个字符 msg='hello egon 666' 2:编写while循环,利用索引遍历出每一个字符 msg='hello egon 666' 3:msg='hel ...
- Android 时间计算工具 通用类TimeUtil
1.整体分析 1.1.源代码如下,可以直接Copy. public class TimeUtil { private static final String TAG = "TimeUtil& ...
- 探究SynchronizationContext在.Net异步编程中的地位
原文:探究SynchronizationContext在.Net异步编程中的地位 引言: 多线程编程/异步编程非常复杂,有很多概念和工具需要去学习,贴心的.NET提供Task线程包装类和await/a ...
- SpringMVC---applicationContext.xml配置详解
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- centos使用--vim配置和推荐插件使用
目录 1.vimrc的配置内容 2.Vundle使用 简介 安装vundle 配置vundle插件: 安装需要的插件 移除不需要的插件 其他常用命令 3 使用插件 3.1 NERDTree 3.2 e ...
- 用 Flask 来写个轻博客
用 Flask 来写个轻博客 用 Flask 来写个轻博客 (1) — 创建项目 用 Flask 来写个轻博客 (2) — Hello World! 用 Flask 来写个轻博客 (3) — (M)V ...
- 更新域名解析以后,IP在cmd中ping不正确,清理DNS缓存
1清除ARP缓存,cmd下使用命令arp -d*代替执行. 2清除NETBT,cmd下使用命令nbtstat -R代替执行. 再清除DNS缓存,cmd下使用命令ipconfig /flushdns代替 ...
- .swp文件的恢复
.swp 编辑文件的过程中会出现这个隐藏文件. 文件如果正常保存,.swp就会自动删除.如果不正常退出,比如关机,.swp就会留下来. linux下: ls -all 可以查看隐藏文件 命令: vi ...
- 源码分析(一) HashMap 源码分析|JDK8
HashMap是一个普遍应用于各大JAVA平台的最最最常用的数据结构.<K,V>的存储形式使HashMap备受广大java程序员的喜欢.JDK8中HashMap发生了很大的变化,例如:之前 ...