This commit is contained in:
MuslemRahimi 2024-09-23 12:33:42 +02:00
parent 580375132a
commit 2b1b04f59c
2 changed files with 34 additions and 52 deletions

View File

@ -21,17 +21,6 @@ use([BarChart, GridComponent, TooltipComponent, CanvasRenderer])
let displayMaxLobbying = 0;
let displayYear = 'n/a';
function normalizer(value) {
if (Math?.abs(value) >= 1e9) {
return { unit: 'B', denominator: 1e9 };
} else if (Math?.abs(value) >= 1e6) {
return { unit: 'M', denominator: 1e6 };
} else if (Math?.abs(value) >= 1e5) {
return { unit: 'K', denominator: 1e3 };
} else {
return { unit: '', denominator: 1 };
}
}
function getPlotOptions() {
@ -48,8 +37,6 @@ function getPlotOptions() {
});
const {unit, denominator } = normalizer(Math.max(...valueList) ?? 0)
const option = {
silent: true,
animation: false,
@ -71,26 +58,25 @@ function getPlotOptions() {
}
},
yAxis: [
{
type: 'value',
splitLine: {
show: false, // Disable x-axis grid lines
},
axisLabel: {
color: '#fff', // Change label color to white
formatter: function (value) {
return '$'+(value / denominator)?.toFixed(1) + unit; // Format value in millions
},
},
{
type: 'value',
splitLine: {
show: false, // Disable x-axis grid lines
},
axisLabel: {
show: false // Hide y-axis labels
}
},
],
series: [
{
data: valueList,
type: 'bar',
itemStyle: {
name: 'Spending [$]',
data: valueList,
type: 'bar',
itemStyle: {
color: '#F8901E' // Change bar color to white
}
}
}
]
};

View File

@ -96,31 +96,27 @@ use([BarChart, GridComponent, CanvasRenderer])
},
yAxis: [
{
type: 'value',
splitLine: {
show: false, // Disable x-axis grid lines
},
axisLabel: {
color: '#fff', // Change label color to white
formatter: function (value, index) {
if(index % 2) {
return '$'+(value / denominator)?.toFixed(1) + unit; // Format value in millions
} else {
return ''
}
},
},
},
{
type: 'value',
show: false,
splitLine: {
show: false, // Disable x-axis grid lines
},
position: 'right',
{
type: 'value',
splitLine: {
show: false, // Disable x-axis grid lines
},
axisLabel: {
show: false // Hide y-axis labels
}
},
{
type: 'value',
splitLine: {
show: false, // Disable x-axis grid lines
},
axisLabel: {
show: false // Hide y-axis labels
},
position: 'right',
},
],
series: [
{