Skip to content

Commit

Permalink
Merge pull request #213 from seidler2547/add-auto-label-color
Browse files Browse the repository at this point in the history
add 'auto' as chart_text_color value
  • Loading branch information
mlamberts78 committed Aug 21, 2024
2 parents d36e91a + bc5ea24 commit c65b401
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,8 @@ drawChart({ config, language, weather, forecastItems } = this) {
},
];

const chart_text_color = (config.forecast.chart_text_color === 'auto') ? textColor : config.forecast.chart_text_color;

if (config.forecast.style === 'style2') {
datasets[0].datalabels = {
display: function (context) {
Expand All @@ -580,7 +582,7 @@ drawChart({ config, language, weather, forecastItems } = this) {
anchor: 'center',
backgroundColor: 'transparent',
borderColor: 'transparent',
color: config.forecast.chart_text_color || config.forecast.temperature1_color,
color: chart_text_color || config.forecast.temperature1_color,
font: {
size: parseInt(config.forecast.labels_font_size) + 1,
lineHeight: 0.7,
Expand All @@ -598,7 +600,7 @@ drawChart({ config, language, weather, forecastItems } = this) {
anchor: 'center',
backgroundColor: 'transparent',
borderColor: 'transparent',
color: config.forecast.chart_text_color || config.forecast.temperature2_color,
color: chart_text_color || config.forecast.temperature2_color,
font: {
size: parseInt(config.forecast.labels_font_size) + 1,
lineHeight: 0.7,
Expand Down Expand Up @@ -701,7 +703,7 @@ drawChart({ config, language, weather, forecastItems } = this) {
borderRadius: 0,
borderWidth: 1.5,
padding: config.forecast.precipitation_type === 'rainfall' && config.forecast.show_probability && config.forecast.type !== 'hourly' ? 3 : 4,
color: config.forecast.chart_text_color || textColor,
color: chart_text_color || textColor,
font: {
size: config.forecast.labels_font_size,
lineHeight: 0.7,
Expand Down

0 comments on commit c65b401

Please sign in to comment.