flex实现股票行情走势图
原文 http://blog.csdn.net/shenjiancomputer/article/details/8051873
第一步:
jsp:1
- <%@page import="java.util.Random,java.util.GregorianCalendar"%>
- <?xml version="1.0" encoding="utf-8"?>
- <items>
- <%
- GregorianCalendar calendar = new GregorianCalendar();
- int year = calendar.get(calendar.YEAR);
- int month = calendar.get(calendar.MONTH) + 1;
- int today = calendar.get(calendar.DAY_OF_MONTH);
- String strday=year+","+month+","+today+",";
- int sb = 400;
- String[] dates = new String[] {strday+"14,60"};
- String crutime=request.getParameter("time");
- ///crutime=crutime.replace(":",",");
- if(crutime!=null){
- crutime=crutime.replace(":",",");
- dates = new String[] {strday+crutime};
- }
- for (int i = 0; i < dates.length; i++) {
- Random random = new Random();
- int r = random.nextInt(1000);
- %>
- <item> <value>
- <%
- if (i < 10) {
- %><%=r%>
- <%
- }
- %>
- </value> <date><%=dates[i]%></date> <sb><%=sb%></sb> </item>
- <%
- }
- %>
- </items>
jsp:2
- <%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
- <%
- String path = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath();
- %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="pragma" content="no-cache">
- <meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="expires" content="0">
- <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
- <meta http-equiv="description" content="This is my page">
- <SCRIPT language="JScript.Encode" src="Js/SwfObject.js" type="text/javascript"></SCRIPT>
- </head>
- <body topmargin="0" leftmargin="0">
- <div align="center" style="margin-top: 40;">
- <div id="flashcontent" width="600" height="400" align="center" ></div>
- <script type="text/javascript">
- var so = new SWFObject("<%=path%>/testfrist.swf", "Main", "600", "400","9.0", "#ffffff", "high");
- so.addVariable("myAmfurl","<%=path%>/nxsy.jsp");
- so.addVariable("myAmtitle","牛熊双赢");
- so.write("flashcontent");
- </script>
- </div>
- </body>
- </html>
第二步flex代码:
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" backgroundColor="white" creationComplete="init();">
- <mx:Style>
- .font12{font-family:宋体;fontSize:15}
- .lenchar{
- bar-color:red;
- }
- .mypanelTitle {
- color: #66ccff;
- fontFamily: Comic Sans MS;
- fontWeight: normal;
- textDecoration: underline;
- }
- </mx:Style>
- <mx:Script><![CDATA[
- import flash.sampler.getMemberNames;
- import mx.charts.chartClasses.IAxis;
- import mx.charts.LinearAxis;
- import mx.charts.HitData;
- import mx.collections.ArrayCollection;
- import mx.rpc.events.ResultEvent;
- import mx.controls.Alert;
- import mx.charts.renderers.CircleItemRenderer;
- import mx.graphics.Stroke;
- import mx.controls.DateField;
- [Bindable]
- private var myAmfurl:String = ""; //用于连接到外部页面
- [Bindable]
- private var myAmtitle:String = ""; //用于连接到外部页面
- [Bindable]
- public var testDatas:ArrayCollection=new ArrayCollection();
- [Bindable]
- private var expenses:ArrayCollection = new ArrayCollection();
- [Bindable]
- private var arr:Array = new Array();
- [Bindable]
- private var mintime:Date;
- [Bindable]
- private var maxtime:Date;
- [Bindable]
- private var smintime:Date;
- [Bindable]
- private var emaxtime:Date;
- private var timer:Timer;
- private var stocksb:Number;
- private var dateVar:Date;
- private var d: Date = new Date();
- private function init():void{
- // setInterval(torequest,2000);
- myAmfurl = Application.application.parameters.myAmfurl; //风险追溯链接
- myAmtitle=Application.application.parameters.myAmtitle;
- timer = new Timer(1000);
- timer.addEventListener(TimerEvent.TIMER, torequest)
- timer.start();
- }
- public function torequest(et:Event):void{
- setstyle();
- realtimeservice.send();
- }
- //用于设置样式
- public function setstyle():void{
- }
- private function formatDataTip(hitData:HitData):String
- {
- var s:String = hitData.item.date.toString();
- var a:Array = s.split(",");
- var str:String=a[3]+":"+a[4];
- str += "\n";
- str += hitData.item.value;
- return str;
- }
- private function parseDate(value:String):Date{
- var a:Array = value.split(",");
- var newDate:Date = new Date(a[0],a[1],a[2],a[3],a[4]);
- return newDate;
- }
- private function getResult(e:ResultEvent):void{
- var min:String="";
- var pattern:RegExp=/,/gi;
- for each (var resultXML:XML in e.result.item){
- var tmpobj:Object=new Object();
- tmpobj.value=resultXML.value;
- tmpobj.date=resultXML.date;
- tmpobj.sb=resultXML.sb;
- stocksb=Number(tmpobj.sb);
- var str=tmpobj.date;
- var a:Array = str.split(",");
- mintime= new Date(a[0],a[1],a[2],9,30);
- smintime= new Date(a[0],a[1],a[2],11,30);
- min=tmpobj.date;
- maxtime=new Date(a[0],a[1],a[2],15,00);
- emaxtime=new Date(a[0],a[1],a[2],13,00);
- if(expenses.length==0){
- expenses.addItem(tmpobj);
- }else{
- var check:int=0;
- if(expenses.length>0){
- for each(var subtempobj:Object in expenses){
- if(String(subtempobj.date).replace(pattern,"")==String(tmpobj.date).replace(pattern,"")){
- check=1;
- }
- }
- }
- if(check==0){
- expenses.addItem(tmpobj);
- check=0;
- }
- }
- }
- var tmpobj1:Object=new Object();
- var tmpobj2:Object=new Object();
- var a:Array = min.split(",");
- tmpobj1.value=stocksb;
- tmpobj1.date=a[0]+","+a[1]+","+a[2]+","+"9,30";
- tmpobj2.value=stocksb;
- tmpobj2.date=a[0]+","+a[1]+","+a[2]+","+"15,00";
- testDatas.addItem(tmpobj1);
- testDatas.addItem(tmpobj2);
- }
- private function mylabel(labelValue:Object, previousValue:Object, d:IAxis):String {
- var temp:String="";
- var currvalue:Number = Number(labelValue.toString());
- if(currvalue>stocksb){
- temp = '<font color="#ff0000" size="11">'+labelValue.toString()+'</font>';
- }else{
- temp = '<font color="#48ff00" size="11">'+labelValue.toString()+'</font>';
- }
- return temp;
- }
- ]]></mx:Script>
- <!-- Define custom Strokes. -->
- <mx:Stroke id = "s1" color="#FFFFFF" weight="0.1"/>
- <mx:Stroke id = "s2" color="#F1F1B8" weight="1"/>
- <mx:Stroke id = "s3" color="green" weight="1"/>
- <mx:Stroke id="vstroke" color="red" weight="1" alpha="0.6"/>
- <mx:HTTPService result="getResult(event);" id="realtimeservice" url="{myAmfurl}" useProxy="false" resultFormat="e4x" method="POST">
- </mx:HTTPService>
- <mx:Panel title="{myAmtitle}" fontSize="15" height="100%" width="100%" color="red" backgroundColor="#000000" borderStyle="inset">
- <mx:LineChart styleName="lenchar" dataTipFunction="formatDataTip" showDataTips="true" height="100%" width="100%" id="chart" fontFamily="
宋体" fontSize="12"> - <mx:backgroundElements>
- <mx:GridLines direction="both">
- <mx:horizontalStroke>
- <mx:Stroke color="red" weight="1" alpha="0.6"/>
- </mx:horizontalStroke>
- <mx:verticalStroke>
- <mx:Stroke color="red" weight="1" alpha="0.2"/>
- </mx:verticalStroke>
- </mx:GridLines>
- </mx:backgroundElements >
- <!-- vertical axis -->
- <mx:verticalAxis>
- <mx:LinearAxis id="va" baseAtZero="false" title="" labelFunction="mylabel"/>
- </mx:verticalAxis>
- <mx:horizontalAxis>
- <!--mx:CategoryAxis id="ca" categoryField="date" displayName="date" title="date" /-->
- <!--mx:LinearAxis displayName="date" minimum="1" id="ca" interval="10"/ -->
- <!--<mx:DateTimeAxis dataUnits="seconds" interval="30" minimum="{minDate}" maximum="{maxDate}"/>-->
- <!--<mx:DateTimeAxis id="hAxis" parseFunction="parseDate" interval="1" minimum="{mintime}" maximum="{maxtime}" displayLocalTime="true" dataInterval="1" dataUnits="hours" labelUnits="hours" />-->
- <mx:DateTimeAxis id="hAxis"
- disabledDays="{[0,6]}"
- disabledRanges="{[{rangeStart:smintime, rangeEnd:emaxtime}]}"
- parseFunction="parseDate" interval="1" minimum="{mintime}" maximum="{maxtime}" displayLocalTime="true" dataInterval="30" dataUnits="minutes" labelUnits="minutes"
- />
- </mx:horizontalAxis>
- <!-- horizontal axis renderer -->
- <mx:horizontalAxisRenderers>
- <mx:AxisRenderer axis="{hAxis}" canDropLabels="true" axisStroke="{vstroke}" />
- </mx:horizontalAxisRenderers>
- <mx:verticalAxisRenderers>
- <mx:AxisRenderer axis="{va}" canDropLabels="true" axisStroke="{vstroke}" />
- </mx:verticalAxisRenderers>
- <!-- series -->
- <mx:series>
- <mx:LineSeries id="series" yField="value" xField="date" displayName="value" dataProvider="{this.expenses}" lineStroke="{s1}" />
- <mx:LineSeries yField="value" xField="date" displayName="TestData" dataProvider="{this.testDatas}" lineStroke="{s2}" />
- </mx:series>
- </mx:LineChart>
- </mx:Panel>
- </mx:Application>
flex实现股票行情走势图的更多相关文章
- WPF Devexpress 控件库中ChartControl 实现股票分时走势图
概要 从事金融行业开发 ,会接触些图表控件,这里我分享一下自己基于DevExpress.Charts.v16.2开发的股票分时走势图的经验. 附上源码:点击跳转 如果需要讨论,Q群:580749909 ...
- 【转】使用Python matplotlib绘制股票走势图
转载出处 一.前言 matplotlib[1]是著名的python绘图库,它提供了一整套绘图API,十分适合交互式绘图.本人在工作过程中涉及到股票数据的处理如绘制K线等,因此将matplotlib的使 ...
- WebService学习--股票走势图+天气预报实现
互联网上面有很多的免费webService服务,我们可以调用这些免费的WebService服务,将一些其他网站的内容信息集成到我们的Web应用中显示,下面就以获取股票数据和天气预报为例进行学习 ...
- canvas绘图,html5 k线图,股票行情图
canvas绘图,html5 k线图,股票行情图 canvas跟其他标签一样,也可以通过css来定义样式.但这里需要注意的是:canvas的默认宽高为300px * 150px,在css中为canva ...
- matplotlib绘图股票走势图实践
导入模块 import pandas as pdimport numpy as npfrom pandas import Series,DataFrameimport matplotlib.pyplo ...
- android 股票K线图
现在在手上的是一个证券资讯类型的app,其中有涉及到股票行情界面,行情中有K线图等,看到网上很多人在求这方面的资料,所以我特地写了一个demo在此处给大家分享一下. 下面是做出来的效果图: 这个 界面 ...
- !! A股历史平均市盈率走势图
http://value500.com/PE.asp 一. A股历史平均市盈率走势图 *数据来源:上海证券交易所 分享到: 354 - 上海A股 深圳A股更新时间 2017年6月7日 2017年6月7 ...
- 用C#开发的双色球走势图(二)
昨晚由于时间的原因只写了一部分内容,今天将这一部分内容补充完毕,多谢各位园友的支持. 这是用C#开发的双色球走势图(一)新的园友可以看昨晚写的内容,以免脱节.首先回复园友的评论,有说好的有说不好的,本 ...
- 用C#开发的双色球走势图(一)
首先声明,个人纯粹无聊之作,不作商业用途. 我相信每个人都拥有一个梦想那就是有朝一日能中500W,这个也一直是我的梦想,并默默每一期双色球或多或少要贡献自己一点点力量,本人并不属于那种铁杆的彩票迷,每 ...
随机推荐
- linux shell if语句
#!/bin/bash read -p "please input Y/N" keyWord if [ "$keyWord" == "Y" ...
- QP在STM32F10X上第一个应用
两天没有写博客了,这两天主要还是在考虑软件的结构性问题,用不用QP?用不用ST库函数?看了ucos,freertos,tinyos以及Contiki,库函数的问题看了使用库的软件结构,直接操作 ...
- Qt4.7文档翻译:Qt样式单参考,Qt Style Sheets Reference(超长,超全)
内容目录 Qt样式单参考 可进行样式设置的部件列表 属性列表 图标列表 属性类型列表 伪状态列表 子控件列表 Qt样式单参考 Qt样式单支持各种属性.伪状态和子控件,这样使得妳能够自行设计部件的外观. ...
- WPF 接收exe传的值
原文:WPF 接收exe传的值 一,首先重载APP protected override void OnStartup(StartupEventArgs e) { ...
- Inno Setup GIF 显示插件 GIFCtrl (V2.1 版本)
原文 http://restools.hanzify.org/article.asp?id=79 引用来自 test.iss ; -- test.iss --; restools; http://r ...
- python编辑器对比和推荐
python编辑器对比和推荐 我先给一个初步的表格吧,大家如果有什么意见,或有补充,欢迎提出.有些我没有用过,先不写了.以下是我使用过的python IDE: 除了PythonWin, Visua ...
- xcode 5与ios 7的屏幕适配问题
#define DEVICE_IS_IPHONE5 ([[UIScreen mainScreen] bounds].size.height == 568) float height = DEVICE_ ...
- poj 1940 Wine Trading in Gergovia_贪心
在一条街上有许多房屋,每间屋子里都住着人,并且都是做葡萄酒生意的商人,他们每天都要决定买卖多少瓶葡萄酒.有趣的地方是,供需总是完美地一致.商人总是能买到自己需要的葡萄酒,并且,他们从来不介意是从哪个商 ...
- ubuntu设置系统时间与网络时间同步和时区
Linux的时间分为System Clock(系统时间)和Real Time Clock (硬件时间,简称RTC). 系统时间:指当前Linux Kernel中的时间. 硬件时间:主板上有电池供电的时 ...
- java的静态代理
解决这个问题:在多个模块要插入一段功能,比方,在不同业务处理模块中,都须要检查用户是否登录,假设不使用代理的话,每添加一个模块,就须要添加非常多代码. 比方,除了推断是否登录,假设还须要添加一个记录日 ...