# flake8: noqa T001, E501
# -*- coding: utf-8 -*-
"""
Simple Plot Example - Voltage vs Time

This example demonstrates how to create a basic voltage plot.
It displays voltage over time for all loaded data sources.

Usage:
    1. Load a battery test file in BT-Analysis
    2. Run this script from the Script Tool menu
    3. View the voltage graph in the UI

Performance Note:
    For large datasets (>10,000 points), consider using:
    - source.get_column() with add_series() for better performance
    - source.to_dict() with pandas for complex data processing
"""

import BTAnalysisPyInterface as bta


def main():
    bta.print("Setting up voltage plot...")

    for source in bta.get_sources():
        # Create voltage graph
        voltage_graph = bta.add_graph(title="Voltage vs Time", xAxis="Time", y1Axis="U")

        # Add all voltage data points
        for point in source.data_points("Potentiostat measure", ["Time", "U"]):
            voltage_graph.add_point(point["Time"], point["U"])

        bta.print("Voltage plot complete!")
