利用vml制作统计图全攻略----饼图的制作 (二)

 

做完了一系列的准备工作,那么现在应该开始真正介绍如何绘制Pie了吧。首先看看下面的一个示意图,清楚地描述了VMLPie的元素结构。

<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />CSDN_Dev_Image_2003-8-19907290.gif

 

为了更加清楚的显示构成VML的文本结构,我使用XML的格式给出了如下的方式。

<v:group>

    <!--设置饼图的背景及其标题 -->

   <v:rect>

           <v:textbox>VML饼图</v:textbox>

   </v:rect>

    <!--设置饼图的各个块-->

   <v:shape path="...">      

   </v:shape>

   <!--图例元素集合 -->

   <v:group>

           <!--设置图例的颜色 -->

           <v:rect fillcolor="green"></v:rect>

           <v:rect>

                    <!-- 设置图例文字-->

                    <v:textbox>重庆(50)</v:textbox>

           </v:rect>

   </v:group>

</v:group>

完成了制图的基本思路之后,剩下的就是通过DOM逐步完成建立过程了,为了简单起见,我们安装函数的功能进行逐步分析。

 

1.             VMLPie

      this.Container=pContainer;

         this.Width= pWidth || "400px";

         this.Height=pHeight || "250px";

         this.Caption = pCaption || "VML Chart";

         this.backgroundColor="";

         this.Shadow=false;

         this.BorderWidth=0;

         this.BorderColor=null;

         this.all=new Array();

         this.id=document.uniqueID;

         this.RandColor=function(){                  

                 return "rgb("+ parseInt( Math.random() * 255) +"," +parseInt( Math.random() * 255) +"," +parseInt( Math.random() * 255)+")";

         }

         this.VMLObject=null;

         this.LegendObject=null;

 

这个函数只是简单的初始化了一些变量,将class可以使用的一些属性在这里做了声明。RandColor函数提供了生成随机颜色的作用,这个也就是我在前文提到的,对于饼图的各个块的颜色,我都采用随机颜色,这样带来的一个问题就是会出现有些时候两个颜色比较接近,如果随能够给我提供几个基础的颜色列表,我将感激不尽。

2.             VMLPie.prototype.AddData

添加图表数据,在这里我采用了prototype滞后加载的方式实现,如果读者认为这样不够清晰,可以修改成this.RandColor那样的内置形式。

实现代码如下:

VMLPie.prototype.AddData=function(sName,sValue,sTooltipText){

     var oData=new Object();

     oData.Name=sName;

     oData.Value=sValue;

     oData.TooltipText=sTooltipText;

     var iCount=this.all.length;

     this.all[iCount]=oData;

}

这里使用一个Object来存储每一个数据项,然后放到this.all这个数组中。

3.             VMLPie.prototype.Draw

整个类实现最关键的函数,也就是在这个函数和后续的CreatePie函数中,一步一步地实现了图形的绘制工作。

//画外框

var o=document.createElement("v:group");

o.id=this.id;

o.style.width=this.Width;

o.style.height=this.Height;

o.coordsize="21600,21600";

//添加一个背景层

var vRect=document.createElement("v:rect");

vRect.style.width="21600px"

vRect.style.height="21600px"

o.appendChild(vRect);

//添加标题     

var vCaption=document.createElement("v:textbox");

vCaption.style.fontSize="24px";                 

vCaption.style.height="24px"

vCaption.preSize="24";

vCaption.style.fontWeight="bold";

vCaption.innerHTML=this.Caption;

vCaption.style.textAlign="center";

 

vRect.appendChild(vCaption);

//设置边框大小 

if(this.BorderWidth){

     vRect.strokeweight=this.BorderWidth;

}

//设置边框颜色

if(this.BorderColor){

     vRect.strokecolor=this.BorderColor;

}

//设置背景颜色

if(this.backgroundColor){               

     vRect.fillcolor=this.backgroundColor;

}

//设置是否出现阴影

if(this.Shadow){

     var vShadow=document.createElement("v:shadow");

     vShadow.on="t";

     vShadow.type="single";

     vShadow.color="graytext";

     vShadow.offset="4px,4px";

     vRect.appendChild(vShadow);

}

this.VMLObject=o;

 

完成上述工作之后,已经构建出了一个canvas(画布),完成了图形外框及其标题的制作,剩下的也就是最最重要的工作调用CreatePie来画出各个块,并且作出图例。

转载于:https://www.cnblogs.com/erikfeng/archive/2006/02/07/326626.html

RM机器人麦轮底盘实战:从零搭建到PID调参全记录(附避坑指南) 本文详细记录了RM机器人麦轮底盘从零搭建到PID调参的全过程,涵盖硬件组装、开发环境搭建、底盘解算和PID调参等关键步骤,并附有实用的避坑指南。特别针对麦轮控制、底盘解算和电机调试等核心问题提供了专业解决方案,帮助开发者快速提升机器人性能。 阅读详情

相关推荐

MATLAB去雾算法实战:5种经典方法对比+1种改进方案(附完整源码)

本文详细对比了MATLAB中5种经典去雾算法(包括暗通道先验、多尺度Retinex等)的实现效果,并提出一种创新的自适应融合改进方案。通过完整的源码展示和性能对比,帮助开发者掌握图像去雾的核心技术,提升计算机视觉应用中的图像质量。特别针对去雾算法中的光晕效应问题,给出了工程实践中的优化技巧。

weixin_26801149的博客 418

利用vml制作统计图全攻略----饼图的制作(一)

利用vml制作统计图全攻略----饼图的制作          作者:蓝翼  CSDN账号:liuruhong(蓝色街灯)电子邮件: liuruhong@263.net   MSN: blueswing_liu@hotmail.com 关键字: VML Javascript OOP 统计图提要:    VML是Microsoft IE 5.0及其后续版本内嵌的矢量图形实现,

4117

网络可视媒体的智能计算-胡事民

本文为胡事民教授在山大做报告的笔记,现场见下图: 可视媒体是承载视觉信息的媒体类型,如图像、视频等,它具有网络化、海量和无序涌现等特征。 可视媒体计算的研究意义 可视媒体作为一种信息承载的介质,是用来表达语义信息的。那么就有一种介质与信息之间相互转化的问题。转化方向正反两种,举个栗子说明一下: 1. 可视媒体→→\rightarrow语义信息:比如看到画面,理解其中发生的事件、各主题之...

gdymind的博客 2451

利用vml制作统计图全攻略----饼图的制作(四)

我们现在就开始来看如上代码的实现。 1. 首先建立一个v:shape,left,top,width,height分别设置为1000px,4000px,15000px;14000px;这个的数字是我根据大致的位置确定的。 2. 设置每个shape的id,我采用了docume...

dianwo2466的博客 186

博客系统 - 系统简介与首页设计

用Bootstrap实现手机端的博客导航栏效果。

m0_53450409的博客 1242

Xilinx Vitis HLS教程1--Vitis HLS概述[01/12]

Xilinx Vitis HLS教程[01/10]前言1. Vitis HLS简介1.1 软件工程师的设计原则1.1.1 简介1.1.2 吞吐量和性能1.2.3 架构问题1.2.4 FPGA编程的3大范式1.2.4.1 生产者-消费者范式1.2.4.2 流式数据范式1.2.4.3 流水线范式1.2.5 3种范式结合 前言 项目中使用到Xilinx Zynq UltraScale+ MPSoC ZCU102 开发板,领导指示研究"xilinx软件自带的c语言综合器"。对于一个硬件一窍不通的我来说,甚至不知道

B10030607的博客 5242

利用vml制作统计图全攻略----饼图的制作 (三)

4.             VMLPie.prototype.CreatePieCreatePie提供了一个参数,也就是饼图制作的容器,我们通过Draw的上述代码已经建立了一个V:Group元素,这个也就是饼图绘制的容器了。var mX=Math.pow(2,16) * 360;//这个参数是划图形的关键//AE x y width height startangle endangle//x

2217

气象大模型光伏功率预测中的应用:从短期,超短期,中长期的实现与开源代码详解

本文详细介绍了基于大模型的光伏功率预测方法,涵盖超短期(15分钟-1小时)、短期(1-6小时)和中长期(1天-1周)预测。文章首先讨论了数据准备与预处理,包括历史功率、气象、天文和电站特性数据的收集与特征工程。随后,针对不同预测需求,提出了多种深度学习模型:超短期预测采用1DCNN-LSTM混合模型,短期预测使用Transformer模型,中长期预测则通过多尺度特征提取模型和概率预测方法处理不确定性。文章还提供了模型训练、评估、部署和优化的完整流程,并开源了代码实现。未来研究方向包括结合数值天气预报、开发时

专注AI大模型,软件混淆,授权 1605

通过xslt制作统计图

今天突然兴起写了这个xslt,主要的制作功能在我原来的文章利用vml制作统计图全攻略----饼图的制作这个里头详细介绍了如何使用VML来制作统计饼图,而本文的代码只是通过xslt的形式完成,因为时间原因,我只是简单的贴出代码,运行环境需要msxml3.0以上版本如下是效果图xmlchart.html html xmlns:v>head>title>tit

2451

38.XDMA寄存器详解2-H2C、C2H通道寄存器组剖析

目录 1.上节回顾 2. H2C寄存器剖析 2.1 H2C通道标识寄存器(0x00) 2.2 H2C通道控制寄存器(0x04) 2.3 H2C通道状态寄存器(0x40) 2.4 H2C通道完成描述符数量寄存器(0x48) 2.5 H2C通道对齐寄存器(0x4C) 2.6 H2C通道查询模式回写地址寄存器(0x88、0x8C) 2.7 H2C通道中断掩码寄存器(0x90)​ 2.8 H2C通道性能监视控制寄存器(0xC0) 2.9 H2C通道周期计数性能寄存器(0xC4、0xC8) 2

一个早起的程序员 5214

【问题解决】Python 异步 asyncio 卡死、协程不执行、任务泄漏,保姆级排错

本文详细分析了Python异步编程中常见的卡死、协程不执行和任务泄漏问题。文章首先列举了这些问题的典型表现,如程序卡住、死锁、任务未启动等。然后深入剖析了各类问题的根源,包括同步阻塞操作、未正确await、资源未清理等。针对这些问题,文章提供了两套解决方案:一是异步编程最佳实践,包括安全协程执行、带超时的执行、任务清理等实用方法;二是死锁检测和预防机制,通过锁管理和等待图分析来避免死锁。文章还包含可直接使用的代码示例,帮助开发者快速定位和解决异步编程中的常见问题。

博客 451

利用vml制作统计图全攻略(饼图)[转自CSDN]

提要:    VML是Microsoft IE 5.0及其后续版本内嵌的矢量图形实现,虽然MS也提倡日后使用SVG,但是作为一个IE内嵌的标记语言,在某些时候的应用还是比较方便的。本文通过完整的描述一个统计饼图的建立过程,来展现VML在Web方面的魅力。文章通过实现一个JavaScript类,读者能够完整地看到整个饼图的制作过程。    VML(Vector Markup Language)自从问...

weixin_34218579的博客 268

利用vml制作统计图全攻略----饼图的制作(四) (转)

利用vml制作统计图全攻略----饼图的制作(四) (转)[@more@]我们现在就开始来看如上代码的实现。XML:namespace prefix = o ns = "urn:schemas-microsoft-com:Off...

csd3176的博客 139

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

利用vml制作统计图全攻略----饼图的制作 (三) (转)

利用vml制作统计图全攻略----饼图的制作 (三) (转)[@more@]4. VMLPie.prototype.CreatePieXML:namespace prefix = o ns = "urn:schemas-mic...

ciya3282的博客 158

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

VML

作者:peterzb(个人开发历程知识库 -博客园) 出处:http://peterzb.cnblogs.com/ VML相当于IE里面的画笔,能实现你所想要的图形,而且结合脚本,可以让图形产生动态的效果。VML是微软1999年9月附带IE5.0发布的,在我认为,VML其

yangzlgg的专栏 1345

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Altium Designer导入STEP 3D模型到封装库,PCB结构干涉提前查

在电子设计与机械结构协同开发中,PCB与外壳的装配干涉是导致项目返工的高频原因。借助三维模型技术,工程师可以在设计阶段直观检查元器件高度、连接器方向及壳体间距。Altium Designer支持将机械CAD软件导出的STEP格式模型嵌入PCB封装库,实现原理图符号、封装与三维实体的统一管理。STEP作为ISO标准中立格式,保留了精确的实体几何信息,成为机电协作的首选桥梁。该方法适用于电源板、连接器、屏蔽罩等复杂场景,能显著减少试产阶段的结构问题。通过规范建模原点、单位与导出协议,并在封装库内完成对齐验证,即

ciya3282的博客 306

Web开发系列 - VML

VML相当于IE里面的画笔,能实现你所想要的图形,而且结合脚本,可以让图形产生动态的效果。VML是微软1999年9月附带IE5.0发布的,在我认为, VML其实是Word和HTML结合的产物。可以将Word文档另存为HTML,其中的文本和图片可以很容易的转换,但如果是手绘制的图形在以往的IE里面就无法解释了,如果都转换成图形文件又不太现实。于是微软把Wo...

weixin_34396103的博客 173
上一篇: 利用vml制作统计图全攻略----饼图的制作(一)
下一篇: 利用vml制作统计图全攻略----饼图的制作(四)
dianwo2466
博客等级 码龄11年 0粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值