Highcharts donut - Center text -


i got donut chart want output text inside when hovering different parts in chart. i'm done, can't seem text center correctly. jsfiddle: http://jsfiddle.net/k5dhu/

code:

$(function() {       var colors = ['#8d62a0', '#ceb3d8', '#d5dddd']; var chart = new highcharts.chart({ chart: {     renderto: 'divgraphcategories',     type: 'pie',     height: 250,     width: 250,     borderradius: 0 }, credits: {     enabled: false }, title: false,  plotoptions: {     pie: {         borderwidth: 0,         startangle: 90,         innersize: '70%',         size: '100%',         shadow: false,         // {         //     color: '#000000',         //     offsetx: 0,         //     offsety: 2,         //     opacity: 0.7,         //     width: 3         // },         datalabels: false,         stickytracking: false,         states: {             hover: {                 enabled: false             }         },         point: {         events: {             mouseover: function(){                 this.series.chart.innertext.attr({text: this.y});             },              mouseout: function(){                 this.series.chart.innertext.attr({text: "mouseout value"});             }         }         }     } },  series: [{     data: [         {y: 6926, name: 'hopp1'},         {y: 1370, name: 'hopp2'},         {y: 1250, name: 'hopp3'},         {y: 10000, name: 'hopp4'},         {y: 1062, name: 'hopp5'},         {y: 6376, name: 'hopp6'},         {y: 2514, name: 'hopp7'},         {y: 349, name: 'hopp8'}     ]     // data: [     //     ['firefox',   44.2],     //     ['ie7',       26.6],     //     ['ie6',       20],     //     ['chrome',    3.1],     //     ['other',    5.4]     // ] }] }, function(chart) { // on complete  var xpos = '50%'; var ypos = '53%'; var circleradius = 102;  // render text      chart.innertext = chart.renderer.text('start value', 112, 125).css({     width: circleradius*2,     color: '#4572a7',     fontsize: '16px',     textalign: 'center' }).attr({     // why doesn't zindex text in front of chart?     zindex: 999 }).add(); }); }); 

as can see, text aligned left , positioned @ 112, 125 @ start. there way set position each time based on how long text is? or property sets text center, no matter whats in there.. text set on hover within mouseover function.

well, might not perfect definition of answer question. it's way of solving problem in way, gives far more customizability.

create div or outside graph area , position css @ center of donut chart appear.

example:

<div class="graph_center">      <h5 id="graphcentername"></h5>      <h3 id="graphcentervalue"></h3 </div> 

then use mouseover , mouseout events this:

point: {     events: {         mouseover: function(){            $('#graphcentername').text(this.name);            $('#graphcentervalue').text(this.y);         },         mouseout: function(){            $('#graphcentername').text('whatever default text want');            $('#graphcentervalue').text('whatever default value want"');        }    } } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -