Как оформить метки серий на круговой диаграмме Highcharts? - PullRequest
1 голос
/ 13 мая 2019

Я пытаюсь изменить вес шрифта надписей серий на круговой диаграмме, поскольку шрифт, который мы используем, имеет довольно ужасную визуализацию шрифта: bold:

bad bold font rendering

Это то, что я пробовал до сих пор (основываясь на указаниях от https://api.highcharts.com/highcharts/plotOptions.pie.label):

plotOptions: {
    pie: {
        label: {
            style: {
                fontWeight: 500,
            }
        }
    }
},

Кажется, это не имеет никакого эффекта.

Я использую это для моей глобальной конфигурации Highcharts:

import * as Highcharts from "highcharts";
import * as HC_Series from 'highcharts/modules/series-label';

HC_Series(Highcharts);
Highcharts.setOptions({
    chart: {
        style: {
            fontFamily: '"Neue Helvetica W05", "M Hei HK W42", Arial, Helvetica, sans-serif',
        },
    },

});

Я использую Highcharts 6.2.0, highcharts-angular 2.4.0.

Ответы [ 2 ]

0 голосов
/ 13 мая 2019

это было под вариантами сюжета:

plotOptions: {
    pie: {
      allowPointSelect: true,
      cursor: 'pointer',
      dataLabels: {
        enabled: true,
        format: '{point.name}: {point.percentage:.1f} %',
        style: {
          fontWeight: '100',
          color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'blue'
        }
      }
    }
  },

Рабочий пример ниже :

Highcharts.chart('container', {
  chart: {
    plotBackgroundColor: null,
    plotBorderWidth: null,
    plotShadow: false,
    type: 'pie'
  },
  title: {
    text: 'Browser market shares in January, 2018'
  },
  tooltip: {
    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
  },
  plotOptions: {
    pie: {
      allowPointSelect: true,
      cursor: 'pointer',
      dataLabels: {
        enabled: true,
        format: '{point.name}: {point.percentage:.1f} %',
        style: {
          fontWeight: '100',
          color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'blue'
        }
      }
    }
  },

  series: [{
    name: 'Brands',
    colorByPoint: true,
    data: [{
      name: 'Chrome',
      y: 61.41,
      sliced: true,
      selected: true
    }, {
      name: 'Internet Explorer',
      y: 11.84
    }, {
      name: 'Firefox',
      y: 10.85
    }, {
      name: 'Edge',
      y: 4.67
    }, {
      name: 'Safari',
      y: 4.18
    }, {
      name: 'Sogou Explorer',
      y: 1.64
    }, {
      name: 'Opera',
      y: 1.6
    }, {
      name: 'QQ',
      y: 1.2
    }, {
      name: 'Other',
      y: 2.61
    }]
  }]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>

<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
0 голосов
/ 13 мая 2019

Вам нужно изменить dataLabels, а не labels. Документация сломана

plotOptions: {
  pie: {
    allowPointSelect: true,
    cursor: 'pointer',
    dataLabels: {
      enabled: true,
      style: {
        fontWeight: 500,
      }
    }
  }
},

Скрипка

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...