' . esc_html__( 'Not enough data yet for a trend chart.', 'ael-42a' ) . '

'; return; } $width = 600; $height = 160; $pad = 6; $max = $y_max > 0 ? (float) $y_max : max( $series ) * 1.1; $max = $max > 0 ? $max : 1; $step = ( $width - 2 * $pad ) / ( $count - 1 ); $points = array(); foreach ( $series as $i => $value ) { $x = $pad + $i * $step; $y = $height - $pad - ( min( (float) $value, $max ) / $max ) * ( $height - 2 * $pad ); $points[] = round( $x, 1 ) . ',' . round( $y, 1 ); } $line = implode( ' ', $points ); $area = $pad . ',' . ( $height - $pad ) . ' ' . $line . ' ' . round( $pad + ( $count - 1 ) * $step, 1 ) . ',' . ( $height - $pad ); list( $last_x, $last_y ) = explode( ',', $points[ $count - 1 ] ); echo ''; } } if ( ! function_exists( 'ael42a_trend_html' ) ) { /** * Render a small up/down trend line, e.g. "▲ 4.2 vs previous period". * * @param float|null $change Trend delta (positive = up). * @param string $suffix Unit suffix appended to the number. */ function ael42a_trend_html( $change, $suffix = '' ) { if ( null === $change || ! is_numeric( $change ) || 0.0 === round( (float) $change, 1 ) ) { return; } $up = $change > 0; $abs = abs( (float) $change ); $label = number_format_i18n( $abs, $abs >= 10 ? 0 : 1 ) . $suffix; echo '

'; echo esc_html( ( $up ? "\xE2\x96\xB2 " : "\xE2\x96\xBC " ) . $label . ' ' ); esc_html_e( 'vs previous period', 'ael-42a' ); echo '

'; } } ?>

20 ? __( 'Positive', 'ael-42a' ) : ( $sentiment < -20 ? __( 'Negative', 'ael-42a' ) : __( 'Neutral', 'ael-42a' ) ); } ?>

%

-

%

-

%

-