我怎样才能把自定义颜色在高图表PIE数据| 切片并希望改变切片文本(How can I put

2019-10-23 01:11发布

任何人都可以提出我关于着色为高图表数据的每一片。

下面也有像我的代码中给出。 我希望把我的自定义色彩数据的每片(用于数据如Firefox,歌剧,铬,IE等)

也希望在这个例子中删除系列名称(“浏览器份额”),如果我把它假“名称:假”则展示系列之一,我想表明它就像“火狐:45%”关于火狐鼠标悬停切片

 $(function () { $('#graph').highcharts({ chart: { plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false }, title: { text: 'Browser market shares at a specific website, 2014' }, tooltip: { pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true, format: '<b>{point.name}</b>: {point.percentage:.1f} %', style: { color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black' } } } }, series: [{ type: 'pie', name: 'Browser share', data: [ ['Firefox', 45.0], ['IE', 26.8], { name: 'Chrome', y: 12.8, sliced: true, selected: true }, ['Safari', 8.5], ['Opera', 6.2], ['Others', 0.7] ] }] }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highcharts/4.1.5/highcharts.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highcharts/4.1.5/highcharts-more.src.js"></script> <div id="graph" style="height: 300px; width:100%;"></div> 

Answer 1:

我们可以接收报告如下指定默认的颜色设置:

 Highcharts.getOptions().plotOptions.pie.colors=['#2f7ed8', '#0d233a',
   '#8bbc21', '#910000', '#1aadce', '#492970', '#f28f43', '#77a1e5',
    '#c42525', '#a6c96a'];

 $(function () { //Specify color set as follows Highcharts.getOptions().plotOptions.pie.colors=['#2f7ed8', '#0d233a', '#8bbc21', '#910000', '#1aadce', '#492970', '#f28f43', '#77a1e5', '#c42525', '#a6c96a']; $('#graph').highcharts({ chart: { plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false }, title: { text: 'Browser market shares at a specific website, 2014' }, tooltip: { pointFormat: '<b>{point.percentage:.1f}%</b>' // updated tool tip }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true, format: '<b>{point.name}</b>: {point.percentage:.1f} %', style: { color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black' } } } }, series: [{ type: 'pie', name: 'Browser share', data: [ ['Firefox', 45.0], ['IE', 26.8], { name: 'Chrome', y: 12.8, sliced: true, selected: true }, ['Safari', 8.5], ['Opera', 6.2], ['Others', 0.7] ] }] }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highcharts/4.1.5/highcharts.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highcharts/4.1.5/highcharts-more.src.js"></script> <div id="graph" style="height: 300px; width:100%;"></div> 



Answer 2:

要在提示更改系列的名称可以更改pointFormat和删除参考series.name

例:

 tooltip: {
            pointFormat: '<b>{point.percentage:.1f}%</b>'
        },

小提琴: http://jsfiddle.net/avsdgek8/

对于颜色看回答内容:

highcharts:动态地定义在饼图颜色

我怎样才能改变我的highcharts饼图的颜色?

另外:颜色可以为每个数据点设置- http://jsfiddle.net/avsdgek8/1/或每系列- http://api.highcharts.com/highcharts#plotOptions.pie.colors



文章来源: How can I put custom color in High Charts PIE data | Slice and want to change slice text