/*公募基金详情-头部的净值走势图*/ // 基于准备好的dom,初始化echarts实例 //折线图 function highcharts(divid,categoriesData,fundtotalnetval,fundnetval,date_condition,maxnav,minnav){ var worldMapContainer = document.getElementById(divid); //用于使chart自适应高度和宽度,通过窗体高宽计算容器高宽 var resizeWorldMapContainer = function () { worldMapContainer.style.width = window.innerWidth*0.85+'px'; //worldMapContainer.style.height = window.innerHeight*0.5+'px'; }; //设置容器高宽 resizeWorldMapContainer(); // 基于准备好的dom,初始化echarts实例 var myChart = echarts.init(worldMapContainer); //var myChart = echarts.init(document.getElementById(divid)); // 指定图表的配置项和数据 var option = { title: { text: ' ' }, tooltip: { trigger: 'axis', axisPointer:{ type:'line' } }, legend: { left:'auto', data:['单位净值','累计净值'] }, grid: { show: true, borderWidth: '0', left: '1%', right: '8%', bottom: 0, containLabel: true }, toolbox: { show : true, feature : { dataZoom : {show: true}, restore : {show: true} } }, xAxis:[{ boundaryGap: false, axisTick: { show: false }, data:categoriesData, splitNumber: 2, axisLabel: { interval: 'auto', // 强制显示X轴所有节点 margin: 12, textStyle: { color: '#666', fontSize: 12 } }, axisLine: { lineStyle: { color: '#ccc', width: 1 } }, splitLine: { show: true, lineStyle: { color: '#eee', width: 1 } } }], yAxis: [{ type : 'value', // min: 0.65, //y轴最小刻度 // max: 1.35, //interval: intervalvalue, //(max - min)/4 y轴刻度间隔 splitNumber: 2, scale: true, axisTick: { show: false }, axisLabel: { show: true, formatter: '{value}', margin: 12, textStyle: { color: '#666', fontSize: 12 } }, axisLine: { lineStyle: { color: '#ccc', width: 1 } }, splitLine: { show: true, lineStyle: { color: '#eee', width: 1 } } }], series: [ { name:'单位净值', type: 'line', symbolSize: 0, itemStyle: { normal: { color: 'red' } }, smooth: true, data: fundnetval }, { name:'累计净值', type: 'line', symbolSize: 0, itemStyle: { normal: { color: '#0068b7' } }, smooth: true, data:fundtotalnetval } ] }; myChart.setOption(option); //用于使chart自适应高度和宽度 window.onresize = function () { //重置容器高宽 resizeWorldMapContainer(); myChart.resize(); }; // 使用刚指定的配置项和数据显示图表。 } //货币基金折线图 function highchartsH(divid,categoriesData,f_incomeunit,f_incomeratio,date_condition,maxnav,minnav){ var worldMapContainer = document.getElementById(divid); //用于使chart自适应高度和宽度,通过窗体高宽计算容器高宽 var resizeWorldMapContainer = function () { worldMapContainer.style.width = window.innerWidth*0.85+'px'; //worldMapContainer.style.height = window.innerHeight*0.5+'px'; }; //设置容器高宽 resizeWorldMapContainer(); // 基于准备好的dom,初始化echarts实例 var myChart = echarts.init(worldMapContainer); //var myChart = echarts.init(document.getElementById(divid)); // 指定图表的配置项和数据 var option = { title: { text: ' ' }, tooltip: { trigger: 'axis', axisPointer:{ type:'line' } }, legend: { left:'auto', data:['万份收益(元)','七日年化收益率(%)' ] }, grid: { show: true, borderWidth: '0', left: '2%', right: '2%', bottom: 0, containLabel: true }, toolbox: { show : true, feature : { dataZoom : {show: true}, restore : {show: true} } }, xAxis:[{ boundaryGap: false, axisTick: { show: false }, data:categoriesData, splitNumber: 2, axisLabel: { interval: 'auto', // 强制显示X轴所有节点 margin: 12, textStyle: { color: '#666', fontSize: 12 } }, axisLine: { lineStyle: { color: '#ccc', width: 1 } }, splitLine: { show: true, lineStyle: { color: '#eee', width: 1 } } }], yAxis: [{ type : 'value', // min: 0.65, //y轴最小刻度 // max: 1.35, //interval: intervalvalue, //(max - min)/4 y轴刻度间隔 splitNumber: 2, scale: true, axisTick: { show: false }, axisLabel: { show: true, formatter: '{value}', margin: 12, textStyle: { color: '#666', fontSize: 12 } }, axisLine: { lineStyle: { color: '#ccc', width: 1 } }, splitLine: { show: true, lineStyle: { color: '#eee', width: 1 } } }], series: [ { name:'万份收益(元)', type: 'line', symbolSize: 0, itemStyle: { normal: { color: 'red' } }, smooth: true, data: f_incomeunit }, { name:'七日年化收益率(%)', type:'line', symbolSize: 0, itemStyle : { normal : { color: "#0068b7" } }, smooth: true, data:f_incomeratio } ] }; myChart.setOption(option); //用于使chart自适应高度和宽度 window.onresize = function () { //重置容器高宽 resizeWorldMapContainer(); myChart.resize(); }; // 使用刚指定的配置项和数据显示图表。 } //基金净值查询数据 function fundechart(hideid,divid,starttime,endtime,fundcode,url){ //$("#selectDate").find(".cjnyl").attr("class","cjnyl"); var procode = fundcode; $.ajax({ url :url, type : "POST", dataType:"json", data:{starttime:starttime,endtime:endtime,date_condition:"",fundcode:fundcode}, success : function(result) { if(result.code!="0000"){ alert(result.msg); }else{ //$("#selectDate").find(".cjnyl").eq(date_condition-1).attr("class","cjnyl on"); var categoriesData = [], fundtotalnetval=[],fundnetval=[]; var data = result.data; if(data.length==0){ $("#"+divid).hide(); $("#"+hideid).show(); }else{ $("#"+divid).show(); $("#"+hideid).hide(); $(data).each(function(i){ categoriesData.push(formatDate(data[i].d_date)); //日期 var ljjzdata = data[i].f_totalnetvalue;//累计净值 var dwjzdata = data[i].f_netvalue;//单位净值 fundtotalnetval.push(ljjzdata); fundnetval.push(dwjzdata); }); var maxnav=Math.max.apply(null, fundtotalnetval)+0.1; //alert(maxnav); var minnav=Math.min.apply(null, fundnetval)-0.1; //alert(minnav); highcharts(divid,categoriesData,fundtotalnetval,fundnetval,maxnav.toFixed(1),minnav.toFixed(1)); } } }, error:function(){ //$("#container").html("





显示错误!"); // Popbox.error("初始化走势图异常,请联系管理员"); } }); } //基金净值查询数据---货币基金 function fundechartH(hideid,divid,starttime,endtime,fundcode,url){ //$("#selectDate").find(".cjnyl").attr("class","cjnyl"); var procode = fundcode; $.ajax({ url :url, type : "POST", dataType:"json", data:{starttime:starttime,endtime:endtime,date_condition:"",fundcode:fundcode}, success : function(result) { if(result.code!="0000"){ alert(result.msg); }else{ //$("#selectDate").find(".cjnyl").eq(date_condition-1).attr("class","cjnyl on"); var categoriesData = [], f_incomeunit=[],f_incomeratio=[]; var data = result.data; if(data.length==0){ $("#"+divid).hide(); $("#"+hideid).show(); }else{ $("#"+divid).show(); $("#"+hideid).hide(); $(data).each(function(i){ categoriesData.push(formatDate(data[i].d_date)); //日期 var incomeunit = data[i].f_incomeunit;//万份收益 //alert(incomeunit); var incomeratio = data[i].f_incomeratio;//七日年化 f_incomeunit.push(incomeunit); f_incomeratio.push(incomeratio); }); //alert(f_incomeunit); //alert(f_incomeratio); var maxnav=Math.max.apply(null, f_incomeratio)+0.1; //alert(maxnav); var minnav=Math.min.apply(null, f_incomeunit)-0.1; //alert(minnav); highchartsH(divid,categoriesData,f_incomeunit,f_incomeratio,maxnav.toFixed(1),minnav.toFixed(1)); } } }, error:function(){ //$("#container").html("





显示错误!"); // Popbox.error("初始化走势图异常,请联系管理员"); } }); } //曲线图格式化时间 function formatDate(str){ var y = str.substring(2,4); var m = str.substring(5,7); var d = str.substring(8,10); //return y+"-"+m+"-"+d; return y+"-"+m+"-"+d; } function chartLineTest(){ //以下为图表测试 var myChart = echarts.init(document.getElementById('tabfundvalueid')); var option = { title: { text: '未来一周气温变化', subtext: '纯属虚构' }, tooltip: { trigger: 'axis' }, legend: { data:['最高气温','最低气温'] }, toolbox: { show: true, feature: { dataZoom: { yAxisIndex: 'none' }, dataView: {readOnly: false}, magicType: {type: ['line', 'bar']}, restore: {}, saveAsImage: {} } }, xAxis: { type: 'category', boundaryGap: false, data: ['周一','周二','周三','周四','周五','周六','周日'] }, yAxis: { type: 'value', axisLabel: { formatter: '{value} °C' } }, series: [ { name:'最高气温', type:'line', data:[11, 11, 15, 13, 12, 13, 10], markPoint: { data: [ {type: 'max', name: '最大值'}, {type: 'min', name: '最小值'} ] }, markLine: { data: [ {type: 'average', name: '平均值'} ] } }, { name:'最低气温', type:'line', data:[1, -2, 2, 5, 3, 2, 0], markPoint: { data: [ {name: '周最低', value: -2, xAxis: 1, yAxis: -1.5} ] }, markLine: { data: [ {type: 'average', name: '平均值'}, [{ symbol: 'none', x: '90%', yAxis: 'max' }, { symbol: 'circle', label: { normal: { position: 'start', formatter: '最大值' } }, type: 'max', name: '最高点' }] ] } } ] }; myChart.setOption(option); } function chart11(){ //以下为图表测试 var myChart = echarts.init(document.getElementById('tabfundvalueid')); var option = { title: { text: 'ECharts 入门示例' }, tooltip: {}, legend: { data:['销量'] }, xAxis: { data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"] }, yAxis: {}, series: [{ name: '销量', type: 'bar', data: [5, 20, 36, 10, 10, 20] }] }; myChart.setOption(option); } function chartPiecs(id){ var myChart = echarts.init(document.getElementById(id)); var option = { title : { text: '某站点用户访问来源', subtext: '纯属虚构', x:'center' }, tooltip : { trigger: 'item', formatter: "{a}
{b} : {c} ({d}%)" }, legend: { orient: 'vertical', top: '40px', orient:'horizontal', data: ['直接访问','邮件营销','联盟广告','视频广告','搜索引擎'] }, series : [ { name: '访问来源', type: 'pie', radius : '55%', center: ['50%', '60%'], data:[ {value:335, name:'直接访问'}, {value:310, name:'邮件营销'}, {value:234, name:'联盟广告'}, {value:135, name:'视频广告'}, {value:1548, name:'搜索引擎'} ], itemStyle: { emphasis: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)' } } } ] }; myChart.setOption(option); }