Как избежать перекрытия меток на круговой диаграмме?

Я хотел бы избежать этой ситуации перекрытия текстовых меток на круговой диаграмме, которую я рисую:

Круговая диаграмма с перекрывающимися метками

Есть ли «признанный» способ сделать это? т.е. определенный алгоритм размещения текста?

А если нет, то как это сделать эффективно?

РЕДАКТИРОВАТЬ: Так что это похоже на этот тип размещения метки:

Перекрывающиеся метки в круговой диаграмме


person Richard    schedule 24.05.2016    source источник


Ответы (1)


ОБНОВЛЕНО:

У меня есть лучшая система для организации меток, которая просто перечисляет метки на соответствующей стороне, а затем добавляет строки из каждой метки в соответствующий сегмент.

Вы можете увидеть пример здесь:

https://www.rgraph.net/demos/pie-basic.html

И код для создания этой диаграммы:

<script src="RGraph.common.core.js"></script>
<script src="RGraph.pie.js"></script>

<canvas id="cvs" width="350" height="250">
    [No canvas support]
</canvas>

<script>
    // A basic configuration for a Pie chart with just the labels
    // separated out into their own array. This is because the same
    // array is used for both the labels and the tooltips so
    // doing this makes for less upkeep when the time comes to
    // change things around.
    //
    // Also note that the stroke color has been set to transparent so
    // that there's no separation between the segments
    //
    labels = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];

    new RGraph.Pie({
        id: 'cvs',
        data: [20,1,1,1,1,1,1],
        options: {
            
            // This is the tooltip property using formatted tooltips
            tooltips: '%{property:myDaynames[%{index}]}<br /><span style="font-weight: bold; font-size:26pt">%{value_formatted}</span>',
            
            // The units that are appended to the %{value_formatted} value
            tooltipsFormattedUnitsPost: '%',
            
            // Some CSS values that are set on the tooltips so that you can customise them
            tooltipsCss: {
                backgroundColor: 'white',
                border: '3px solid black'
            },

            // A custom property - the formatted tooltips can then
            // access this to use the data inside the tooltip
            myDaynames: labels,

            shadow: false,
            colorsStroke: 'transparent',
            keyPositionGraphBoxed: false,
            
        }
    // Draw the chart
    }).draw();
</script>
person Richard    schedule 13.06.2016
comment
Пожалуйста, опубликуйте решение здесь, любая ссылка на решение снаружи может быть легко потеряна. - person Pavan Dittakavi; 09.04.2019
comment
Да, ответ теперь битая ссылка - person williaster; 21.08.2019