/*公募基金详情-头部的净值走势图*/
// 基于准备好的dom,初始化echarts实例
//折线图
function highcharts(divid,categoriesData,fundtotalnetval,fundnetval,date_condition,maxnav,minnav){
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: '3%',
right: '7%',
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);
window.onresize = myChart.resize;
// 使用刚指定的配置项和数据显示图表。
}
//货币基金折线图
function highchartsH(divid,categoriesData,f_incomeunit,f_incomeratio,date_condition,maxnav,minnav){
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: '3%',
right: '7%',
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);
window.onresize = myChart.resize;
// 使用刚指定的配置项和数据显示图表。
}
//查询资产组合数据
function getZczhData(divid,fundcode,url_post){
$.ajax({
url :url_post,
type : "POST",
dataType:"json",
data:{fundcode:fundcode},
success : function(result) {
if(result.code!="0000"){
alert(result.msg);
}else{
var legendData = [];
var seriesData=[];
var data = result.data;
if(data.length==0){
$("#"+divid).html("
暂无相关数据
");
}else{
$(data).each(function(i){
legendData.push(data[i].vc_xm); //项目
var series = {};
series["name"] = data[i].vc_xm;//项目
series["value"] = data[i].i_bl;//比例
seriesData.push(series);
});
//alert(legendData);
//alert(seriesData);
chartPie(divid,legendData,seriesData);
}
}
},
error:function(){
}
});
}
//查询行业分布数据
function getHyfbData(divid,fundcode,url_post){
$.ajax({
url :url_post,
type : "POST",
dataType:"json",
data:{fundcode:fundcode},
success : function(result) {
if(result.code!="0000"){
alert(result.msg);
}else{
var legendData = [];
var seriesData=[];
var data = result.data;
if(data.length==0){
$("#"+divid).html("
暂无相关数据
");
}else{
$(data).each(function(i){
legendData.push(data[i].vc_hylb); //项目
var series = {};
series["name"] = data[i].vc_hylb;//项目
series["value"] = data[i].i_bl;//比例
seriesData.push(series);
});
//alert(legendData);
//alert(seriesData);
chartPie(divid,legendData,seriesData);
}
}
},
error:function(){
}
});
}
//查询十大股票数据(柱状图)
function getGoZData(divid,fundcode,url_post,color){
$.ajax({
url :url_post,
type : "POST",
dataType:"json",
data:{fundcode:fundcode},
success : function(result) {
if(result.code!="0000"){
alert(result.msg);
}else{
var legendData = [];
var seriesData=[];
var data = result.data;
if(data.length==0){
$("#"+divid).html("
暂无相关数据
");
}else{
$(data).each(function(i){
legendData.push(data[i].vc_gpmc); //股票名称
seriesData.push(data[i].i_bl);//比例
});
//alert(legendData);
//alert(seriesData);
chartBar(divid,legendData,seriesData,color);
}
}
},
error:function(){
}
});
}
//饼图初始化 初始化的dom的id、小标签、数据
function chartPie(divid,legendData,seriesData){
var myChart = echarts.init(document.getElementById(divid));
var option = {
title : {
text: ' ',
subtext: ' ',
x:'center'
},
tooltip : {
trigger: 'item',
formatter: "{a}
{b} : {c} %"
},
legend: {
orient: 'vertical',
top: '40px',
orient:'horizontal',
//data: ['直接访问','邮件营销','联盟广告','视频广告','搜索引擎']
data:legendData
},
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:'搜索引擎'}
],*/
data: seriesData,
itemStyle: {
normal:{
label:{
show:true,
formatter:function(val){ //让series 中的文字进行换行
return val.name.split("-").join("\n");
},
},
labelLine:{
show:true
}
},
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
myChart.setOption(option);
}
//柱状图
function chartBar(divid,xData,seriesData,color){
var myChart = echarts.init(document.getElementById(divid));
var option = {
color: [color],
tooltip : {
trigger: 'axis',
axisPointer : { // 坐标轴指示器,坐标轴触发有效
type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category',
/* data : ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],*/
data: xData,
axisTick: {
alignWithLabel: true
}
}
],
yAxis : [
{
type : 'value',
name:'占净值比例(%)',
nameLocation:'middle',
nameGap:'40'
}
],
series : [
{
name:'比例',
type:'bar',
barWidth: '60%',
/*data:[10, 52, 200, 334, 390, 330, 220]*/
data: seriesData
}
]
};
myChart.setOption(option);
}
//基金净值查询数据
function fundechart(hideid,divid,date_condition,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: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(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,date_condition,maxnav.toFixed(1),minnav.toFixed(1));
}
}
},
error:function(){
//$("#container").html("
显示错误!");
// Popbox.error("初始化走势图异常,请联系管理员");
}
});
}
//基金净值查询数据---货币基金
function fundechartH(hideid,divid,date_condition,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: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(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,date_condition,maxnav.toFixed(1),minnav.toFixed(1));
}
}
},
error:function(){
//$("#container").html("
显示错误!");
// Popbox.error("初始化走势图异常,请联系管理员");
}
});
}
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);
}