+ {question.isMultipleChoice ? (
+
+ opt.text),
+ datasets: [{
+ label: '% выбравших',
+ data: question.options.map(opt => opt.percentage),
+ backgroundColor: colorsForBar,
+ borderColor: colorsForBar,
+ borderWidth: 2,
+ borderRadius: 8,
+ borderSkipped: false,
+ }]
+ }}
+ options={{
+ responsive: true,
+ plugins: {
+ legend: {
+ display: false
+ },
+ tooltip: { enabled: true },
+ datalabels: { display: false },
+ annotation: {
+ annotations: question.options.map((opt, i) => ({
+ type: 'label',
+ xValue: i,
+ yValue: opt.percentage + 5,
+ content: `${opt.percentage}%`,
+ font: { size: 16, weight: 400 },
+ color: '#000'
+ }))
+ }
+ },
+ scales: {
+ y: {
+ beginAtZero: true,
+ max: 100,
+ ticks: { callback: (val) => `${val}%` }
+ },
+ x: {
+ ticks: {
+ color: '#000000',
+ font: {
+ size: 16,
+ weight: 400
+ }
+ },
+ grid: { display: false }
+ }
+ }
+ }}
+ />
+
+ ) : (
+
+
opt.text),
+ datasets: [{
+ data: question.options.map(opt => opt.percentage),
+ backgroundColor: colorsForPie,
+ borderColor: '#fff',
+ borderWidth: 2
+ }]
+ }}
+ options={{
+ responsive: true,
+ plugins: {
+ legend: {
+ position: 'right',
+ labels: {
+ color: '#000000',
+ font: {
+ size: 18,
+ weight: 500
+ }
+ }
+ },
+ tooltip: {
+ callbacks: {
+ label: (ctx) => `${ctx.label}: ${ctx.raw}%`
+ }
+ },
+ datalabels: {
+ formatter: (value) => `${value}%`,
+ color: '#000',
+ font: { weight: 400, size: 16 }
+ }
+ },
+ animation: { animateRotate: true }
+ }}
+ />
+
+ )}
+