Python Forum
Pygal: Displaying information for each data point - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Pygal: Displaying information for each data point (/thread-20136.html)



Pygal: Displaying information for each data point - KirkmanJ - Jul-29-2019

I have been playing around with Pygal, creating some line graphs for a project I am working on. I currently have my y axis set to be the value recorded and the x axis being the date / time the test was conducted. However I would also like to link the serial number to each data point. At the moment when you hover on a data point you get the y value in bold and underneith that you get the date it was recorded.

Does anyone know if it is possible to link information to data points without them being an axis label?

For reference I currently have the serial numbers being added to the list: 'sn_list'.

for row in line_graph_query:
            if str(row.date_time) >= start_date and str(row.date_time) <= end_date :
                min_values.append(float(row.minimum_value))
                max_values.append(float(row.maximum_value))
                recorded_values.append(float(row.recorded_value))
                sn_list.append(row.product_serial_number)
                date_list.append(row.date_time)
                number_of_records = number_of_records + 1
        print(min_values)
        print(max_values)
        print(recorded_values)
        distance_x_axis = math.floor(number_of_records/6)
        line_chart = pygal.Line(no_data_text='No result found', style=custom_style,x_labels_major_every=distance_x_axis, x_label_rotation=20, show_minor_x_labels=False )
        line_chart.title = 'Detailed Results of '+test_name+' tests of '+board_pn
        line_chart.x_labels = map(str,date_list)
        line_chart.add('Minimum', min_values)
        line_chart.add('Maximum', max_values)
        line_chart.add('Recorded', recorded_values)
        graph_render.append(line_chart.render_data_uri())
        graphs_to_render[test_name] = graph_render[-1]