Following discussion in chat, this is an adaption of Alan's answer which implements the syntax he was trying to realise.
% addaswyd o ateb Alan Munn: https://tex.stackexchange.com/questions/364944/expand-a-gantt-chart-automatically-to-textwidth-of-a-page/364969#364969 a chwestiwn buhtz: https://tex.stackexchange.com/questions/364944/expand-a-gantt-chart-automatically-to-textwidth-of-a-page
\documentclass[a4paper]{article}
\usepackage[showframe]{geometry} % show page borders
\parindent=0pt
\usepackage{pgfgantt}
\makeatletter
\tikzset{%
/pgfgantt/time slots/.code={%
\tikzset{%
/pgfgantt/time slots/.cd,
#1,
/pgfgantt/.cd,
}%
},
/pgfgantt/time slots/.search also={/pgfgantt},
/pgfgantt/time slots/.cd,
width/.store in=\ts@width,
width=\textwidth,
slots/.store in=\totaltimeslots,
slots=20,
label width/.store in=\ts@labelwidth,
label width=25mm,
calc x unit/.code n args=3{%
\pgfmathsetmacro\ts@xunit{(#1-#2-0.6667em-2*\pgflinewidth)/#3}%
\tikzset{%
/pgfgantt/x unit=\ts@xunit pt,
}%
},
widest/.code={%
\pgfmathsetmacro\ts@wdlabel{width("#1")}%
\tikzset{/pgfgantt/time slots/label width=\ts@wdlabel pt}%
},
calc x unit aux width/.style={/pgfgantt/time slots/calc x unit={#1}{\ts@labelwidth}{\totaltimeslots}},
calc x unit aux label width/.style={/pgfgantt/time slots/calc x unit={\ts@width}{#1}{\totaltimeslots}},
calc x unit aux slots/.style={/pgfgantt/time slots/calc x unit={\ts@width}{\ts@labelwidth}{#1}},
width/.forward to=/pgfgantt/time slots/calc x unit aux width,
slots/.forward to=/pgfgantt/time slots/calc x unit aux slots,
label width/.forward to=/pgfgantt/time slots/calc x unit aux label width,
}
\makeatother
\begin{document}
\begin{ganttchart}
[
time slots={slots=122, widest=Long Long},
time slot format=isodate,
]
{2017-04-01}{2017-07-31} % from-to (122 days)
\gantttitle{Gantt-Chart with 122 timeslots}{\totaltimeslots}\\
\ganttbar{Short}{2017-05-01}{2017-06-01}\\
\ganttbar{Long Long}{2017-05-25}{2017-06-04}\\
\end{ganttchart}
\begin{ganttchart}
[
time slots/slots=15,
time slots/widest=Foo,
time slots/width=.9\linewidth,
time slot format=isodate,
]
{2017-04-01}{2017-04-15} % from-to (122 days)
\gantttitle{Gantt-Chart with 15 timeslots}{15}\\
\ganttbar{Foo}{2017-05-25}{2017-06-04}
\end{ganttchart}
\end{document}