Warning: Undefined variable $cat_id in /home/c8584124/public_html/namiten.jp/wp-content/themes/jinr/single.php on line 60

Warning: Undefined variable $cat_id in /home/c8584124/public_html/namiten.jp/wp-content/themes/jinr/single.php on line 60

Warning: Undefined variable $cat_id in /home/c8584124/public_html/namiten.jp/wp-content/themes/jinr/single.php on line 60

Warning: Undefined variable $cat_id in /home/c8584124/public_html/namiten.jp/wp-content/themes/jinr/single.php on line 60
PRあり

内閣寄与度推移

namiten

// There should not be negative values in rawData
const rawData = [
[14.1, 11.0, 17.4, 14.9],
[10.9, 10.9, 7.3, 9.1],
[9.5, 7.9, 6.9, 15.5],
[11.1, 15.0, 16.7, 12.4],
[9.4, 9.4, 13.4, 8.1],
[9.9, 6.6, 11.3, 8.1],
[16.6, 10.8, 11.4, 12.4],
[7.7, 8.2, 7.5, 9.8],
[10.7, 20.2, 8.2, 9.6]
];
const totalData = [];
for (let i = 0; i < rawData[0].length; ++i) {
let sum = 0;
for (let j = 0; j < rawData.length; ++j) {
sum += rawData[j][i];
}
totalData.push(sum);
}
const grid = {
left: 100,
right: 100,
top: 50,
bottom: 50
};
const gridWidth = myChart.getWidth() – grid.left – grid.right;
const gridHeight = myChart.getHeight() – grid.top – grid.bottom;
const categoryWidth = gridWidth / rawData[0].length;
const barWidth = categoryWidth * 0.6;
const barPadding = (categoryWidth – barWidth) / 2;
const series = [
‘NHK’,
‘NNN/読売’,
‘TXN/日経’,
‘FNN/産経’,
‘ANN’,
‘JNN’,
‘朝日’,
‘毎日’,
‘共同’
].map((name, sid) => {
return {
name,
type: ‘bar’,
stack: ‘total’,
barWidth: ‘60%’,
label: {
show: true,
formatter: (params) => Math.round(params.value * 1000) / 10 + ‘%’
},
data: rawData[sid].map((d, did) =>
totalData[did] <= 0 ? 0 : d / totalData[did]
)
};
});
const color = [
‘#5470c6’, ‘#91cc75’, ‘#fac858’, ‘#ee6666’, ‘#73c0de’,
‘#3ba272’, ‘#fc8452’, ‘#9a60b4’, ‘#ea7ccc’ // 新しい色を追加
];
const elements = [];
for (let j = 1, jlen = rawData[0].length; j < jlen; ++j) {
const leftX = grid.left + categoryWidth * j – barPadding;
const rightX = leftX + barPadding * 2;
let leftY = grid.top + gridHeight;
let rightY = leftY;
for (let i = 0, len = series.length; i < len; ++i) {
const points = [];
const leftBarHeight = (rawData[i][j – 1] / totalData[j – 1]) * gridHeight;
points.push([leftX, leftY]);
points.push([leftX, leftY – leftBarHeight]);
const rightBarHeight = (rawData[i][j] / totalData[j]) * gridHeight;
points.push([rightX, rightY – rightBarHeight]);
points.push([rightX, rightY]);
points.push([leftX, leftY]);
leftY -= leftBarHeight;
rightY -= rightBarHeight;
elements.push({
type: ‘polygon’,
shape: {
points
},
style: {
fill: color[i],
opacity: 0.25
}
});
}
}
option = {
legend: {
selectedMode: false
},
grid,
yAxis: {
type: ‘value’
},
xAxis: {
type: ‘category’,
data: [‘2022/2’, ‘2023/1’, ‘2023/2’, ‘2024/1’]
},
series,
graphic: {
elements
}
};

※SNSシェアの場合、必ず利用規約をご確認ください。
コンテンツの翻案、リンクを含まない引用・スクリーンショットの共有は法律・法令、当サイト利用規約で禁止されています。
サイト内PR

Google Newsでnamiten.jpをフォロー

namiten.jp
namiten.jp
広報
namiten.jp広報班にお問い合せがある場合、以下の通りお願いします。

当サイト掲載情報について、法的請求がある場合…お問い合わせへ
当サイト掲載情報について、不備や依頼等がある場合…メール、Twitter DM等
記事URLをコピーしました