Текст в центре кольцевой диаграммы highcharts перекрывается всплывающей подсказкой

Я показываю текст в центре кольцевой/круговой диаграммы Highcharts. Но моя проблема в том, что центральный текст перекрывается с текстом всплывающей подсказки, и всплывающая подсказка становится нечитаемой.

Я попытался изменить zIndex всплывающей подсказки, чтобы вывести ее на передний план, но это не сработало. Я хочу, чтобы всплывающая подсказка находилась поверх текста в центре пончика.

См. полную диаграмму здесь: http://jsfiddle.net/SufianRashid/88q5uke1



//==================== HIGH CHARTS =========================//
function RenderPieChart(chartId, chartData, donutCenterText) {
    $('#' + chartId).highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: 0,
            plotShadow: false,
            height: 270
        },
        credits: {
            enabled: false
        },
        exporting: {
            enabled: false
        },
        title: {
            text: '',
            align: 'center',
            verticalAlign: 'middle',
            y: 0,
            useHTML: true
        },
        tooltip: {
            backgroundColor: 'white',
            useHtml: true,
            //zIndex: 99, //on top of everything
            headerFormat: '',
            pointFormat: '{point.actualCounts} {point.name}'
        },
        plotOptions: {
            pie: {
                dataLabels: {
                    formatter: function () { if (this.y != 0) return this.y + '%'; },    //don't show 0% values
                    enabled: true,
                    distance: -25,  //change this value to show label inside/outside the pie chart (negative means towards inside)
                    style: {
                        fontWeight: 'bold',
                        color: 'white',
                        textShadow: '0px 1px 2px black'
                    }
                },
                //showInLegend: true,
                startAngle: 0,
                endAngle: 360,
                center: ['50%', '50%']
            },
            //-------- On click open drill down url --------//
            series: {
                cursor: 'pointer',
                point: {
                    events: {
                        click: function () {
                            location.href = this.options.url;   //same window
                        }
                    }
                }
            }//End adding link
            //--------------------------------//
        },
        series: [{
            type: 'pie',
            innerSize: '140px',
            //--------------------//
            data: chartData
            //--------------------//
        }]
    },
        //-------- Show Center Text ------//
        function (chart) {

            var xpos = chart.plotLeft + (chart.plotWidth * 0.43);
            var ypos = chart.plotTop + (chart.plotHeight * 0.4);


            // Render the text 
            chart.innerText = chart.renderer.html(donutCenterText, xpos, ypos).add();

        }
    );  //EOF: HighChart
}

person SufianRashid    schedule 28.04.2015    source источник


Ответы (1)


Попробуйте следующее, чтобы решить вашу проблему:

CSS:

.highcharts-tooltip span {
    background-color:white;
    border:1px solid;
    opacity:1;
    z-index:9999 !important;
}

JQuery:

tooltip: {
           borderWidth: 0,
           backgroundColor: "rgba(255,255,255,0)",
           shadow: false,
           useHTML: true,
           //zIndex: 99, //on top of everything
           headerFormat: '',
           pointFormat: '{point.actualCounts} {point.name}'
         },

Проверять:

RenderPieChart(
'PieChartContainer', 
[
{ name: 'tickets opened within 24 hrs', y: 76.5, actualCounts: 54, url:'../dummyUrl.html' },
{ name: 'tickets opened within 25 to 48 hrs', y: 6.9, actualCounts: 77, url:'../dummyUrl.html' },
{ name: 'tickets opened in 49 to 72+ hrs', y: 93.1, actualCounts: 1032, url:'../dummyUrl.html' }
],
"<span id='DonutCenterText' style='text-align:center;' class='donutValuesOpen'><span>Total Open <br/>Tickets: <a href='../dummyUrl.html'> 1109 </a> <br/> </span><span class='Avg'>Average Days <br/>Open: 8 </span> </span>"
);

//==================== HIGH CHARTS =========================//
        function RenderPieChart(chartId, chartData, donutCenterText) {
            $('#' + chartId).highcharts({
                chart: {
                    plotBackgroundColor: null,
                    plotBorderWidth: 0,
                    plotShadow: false,
                    height: 270
                },
                credits: {
                    enabled: false
                },
                exporting: {
                    enabled: false
                },
                title: {
                    text: '',
                    align: 'center',
                    verticalAlign: 'middle',
                    y: 0,
                    useHTML: true
                },
                tooltip: {
                    borderWidth: 0,
                    backgroundColor: "rgba(255,255,255,0)",
                    shadow: false,
                    useHTML: true,
                    //zIndex: 99, //on top of everything
                    headerFormat: '',
                    pointFormat: '{point.actualCounts} {point.name}'
                },

                plotOptions: {
                    pie: {
                        dataLabels: {
                            formatter: function () { if (this.y != 0) return this.y + '%'; },    //don't show 0% values
                            enabled: true,
                            distance: -25,  //change this value to show label inside/outside the pie chart (negative means towards inside)
                            style: {
                                fontWeight: 'bold',
                                color: 'white',
                                textShadow: '0px 1px 2px black'
                            }
                        },
                        //showInLegend: true,
                        startAngle: 0,
                        endAngle: 360,
                        center: ['50%', '50%']
                    },
                    //-------- On click open drill down url --------//
                    series: {
                        cursor: 'pointer',
                        point: {
                            events: {
                                click: function () {
                                    location.href = this.options.url;   //same window
                                }
                            }
                        }
                    }//End adding link
                    //--------------------------------//
                },
                series: [{
                    type: 'pie',
                    innerSize: '140px',
                    //--------------------//
                    data: chartData
                    //--------------------//
                }]
            },


//------- Show Donut center text ------------------//
            function (chart) {

                var xpos = chart.plotLeft + (chart.plotWidth * 0.43);
                var ypos = chart.plotTop + (chart.plotHeight * 0.4);

            
                // Render the text 
                chart.innerText = chart.renderer.html(donutCenterText, xpos, ypos).add();

            }
            );  //EOF: HighChart
        }
    .highcharts-tooltip span {
        background-color:white;
        border:1px solid;
        opacity:1;
        z-index:9999 !important;
    }

   
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>

<div id="PieChartContainer" style="height: 400px"></div>

person ketan    schedule 28.04.2015
comment
Это работает. Спасибо. Итак, вы удалили стили для всплывающей подсказки при создании highchart, а затем применили их из CSS. Могу ли я использовать свойство 'style:' внутри всплывающей подсказки? - person SufianRashid; 28.04.2015
comment
@SufianRashid Да. Я больше не работаю в хайчарте, но, насколько мне известно, нет. Но вы можете попробовать. Но вы можете дать дан стиль. проверьте api.highcharts.com/highcharts#tooltip - person ketan; 28.04.2015
comment
Надеюсь, что ссылка выше поможет. и вы отмечаете это как ответ, если это решило вашу проблему. - person ketan; 28.04.2015