
有谁知道如何在Highcharts插件里设置对象的值
比如:varstr=chart.options.title.text;这个语句能获取到值,但是chart.options.title.text=“这是赋予一个值”,这样是...
比如:var str=chart.options.title.text;这个语句能获取到值,但是chart.options.title.text=“这是赋予一个值”,这样是赋不上值,有哪位兄弟知道如何赋值的告诉我,非常感谢!
展开
2个回答
展开全部
通过Highcharts提供的setTitle方法可以实现,
具体使用方法可以是添加一个按钮,并设置onclick方法,方法类容就是调用chart.setTitle({text:‘xxx’});,具体代码可以参考我做的效果
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
var chart;
$(function () {
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'spline',
},
credits : {
enabled:false//不显示highCharts版权信息
},
title:{
text:"sdsd"
},
xAxis: {
type:'datetime',
categories: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
},
series: [{
name: 'series1',
data: [2,4,5,9,2,7]
},{
name:'series2',
data:[3,5,7,2,1,4]
}]
});
});
$("button").click(function(){
chart.setTitle({text:'ssss'});
});
});
</script>
</head>
<body>
<script src="js/highcharts.js"></script>
<script src="js/exporting.js"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<button>Change Title</button>
</body>
</html>
展开全部
function doSetLenOption(){
var tmpChart =$('#container').highcharts(); //tmpCharts.charts[0];
alert(tmpChart.options.title.text);
alert(tmpChart.animation);
tmpChart.options.title.floating=true;
tmpChart.options.title.x=50;
tmpChart.options.title.y=50;
tmpChart.options.title.useHTML=true;
tmpChart.options.title.text = "aaaa";
tmpChart.options.title.style.color = "green";
tmpChart.options.title.style.fontSize="20px"; //区分大小写
tmpChart.setTitle("a");//这行代码无效,但可使上面的修改生效
tmpChart.redraw();
alert(tmpChart.options.title.text);
}
var tmpChart =$('#container').highcharts(); //tmpCharts.charts[0];
alert(tmpChart.options.title.text);
alert(tmpChart.animation);
tmpChart.options.title.floating=true;
tmpChart.options.title.x=50;
tmpChart.options.title.y=50;
tmpChart.options.title.useHTML=true;
tmpChart.options.title.text = "aaaa";
tmpChart.options.title.style.color = "green";
tmpChart.options.title.style.fontSize="20px"; //区分大小写
tmpChart.setTitle("a");//这行代码无效,但可使上面的修改生效
tmpChart.redraw();
alert(tmpChart.options.title.text);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询