<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _create_chord_chart(self, data, works, output_dir):
 """Generates and writes to a file in `output_dir` the data used to display a chord chart. :param data: data to derive the chord data from :type data: `pandas.DataFrame` :param works: works to display :type works: `list` :param output_dir: directory to output data file to :type output_dir: `str` """

        matrix = []
        chord_data = data.unstack(BASE_WORK)[SHARED]
        for index, row_data in chord_data.fillna(value=0).iterrows():
            matrix.append([value / 100 for value in row_data])
        colours = generate_colours(len(works))
        colour_works = [{'work': work, 'colour': colour} for work, colour
                        in zip(chord_data, colours)]
        json_data = json.dumps({'works': colour_works, 'matrix': matrix})
        with open(os.path.join(output_dir, 'chord_data.js'), 'w') as fh:
            fh.write('var chordData = {}'.format(json_data))