JavaScript

超轻量级php框架startmvc

jQuery插件FusionCharts绘制2D双折线图效果示例【附demo源码】

更新时间:2020-05-07 00:00:01 作者:startmvc
本文实例讲述了jQuery插件FusionCharts绘制2D双折线图效果。分享给大家供大家参考,具体如下

本文实例讲述了jQuery插件FusionCharts绘制2D双折线图效果。分享给大家供大家参考,具体如下:

1、设计思路

(1)根据双折线图的特性和共性,设计出双折线图;

(2)设置数据源XML格式

2、设计步骤

(1)写出双折线引入的图类型和数据源路径


var doubleLine = new FusionCharts( "FusionCharts/MSLine.swf", "doubleLineId", "100%", "540", "0" );
doubleLine.setXMLUrl("doubleLine.xml");
doubleLine.render("doubleLineChart");

(2)设置双折线图的数据源 doubleLine.xml:


<?xml version="1.0" encoding="UTF-8"?>
<chart caption='(jb51.net统计)2015和2016年某桥一周通过的人数' xAxisName='星期' yAxisName='人数' showValues='0'
 baseFont='微软雅黑' baseFontSize='14' baseFontColor='#FF0000' outCnvBaseFont='宋体'
 outCnvBaseFontSize='20' outCnvBaseFontColor='#00FF00' legendShadow='1'
 legendAllowDrag='1' reverseLegend='1' interactiveLegend='1' legendNumColumns='2'
 minimiseWrappingInLegend='1' showLegend='1' legendPosition='BOTTOM' showZeroPlane='1'>
 <categories>
 <category label='星期一' />
 <category label='星期二' />
 <category label='星期三' />
 <category label='星期四' />
 <category label='星期五' />
 <category label='星期六' />
 <category label='星期日' />
 </categories>
 <dataset seriesName='2015'>
 <set value='656445' />
 <set value='412555'/>
 <set value='956566' />
 <set value='125645' />
 <set value='561124' />
 <set value='265655' />
 <set value='451212' />
 </dataset>
 <dataset seriesName='2016'>
 <set value='154512'/>
 <set value='598655'/>
 <set value='654544'/>
 <set value='956565'/>
 <set value='245454' />
 <set value='965565' />
 <set value='454545' />
 </dataset>
</chart>

(3)引入双折线图


<div id="doubleLineChart"></div> 

3、运行结果如下图:

4、源码


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>FusionCharts 2D双折线图</title>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="FusionCharts/FusionCharts.js"></script>
<script type="text/javascript">
$(function(){
 var doubleLine = new FusionCharts( "FusionCharts/MSLine.swf", "doubleLineId", "100%", "540", "0" );
 doubleLine.setXMLUrl("doubleLine.xml");
 doubleLine.render("doubleLineChart");
});
</script>
</head>
<body>
 <div id="doubleLineChart"></div>
</body>
</html>

附:完整实例代码点击此处本站下载

注:该源码需要放到服务器环境下运行!否则无法加载xml文件数据。

jQuery 插件 FusionCharts 绘制 2D 双折线图