# flake8: noqa T001, E501
# -*- coding: utf-8 -*-
"""
Voltage & Current Example - Dual-Axis Graph

This example shows how to display both voltage and current
on a single graph with two Y-axes.

Features:
    - Voltage on left Y-axis
    - Current on right Y-axis
    - Synchronized time axis
"""

import BTAnalysisPyInterface as bta


def main():
    bta.print("Setting up voltage & current graph...")

    for source in bta.get_sources():
        # Create dual-axis graph
        vc_graph = bta.add_graph(
            title="Voltage & Current vs Time",
            xAxis="Time",
            y1Axis="U",
            y2Axis="I",  # Second Y-axis for current
        )

        # Add voltage and current data
        for point in source.data_points("Potentiostat measure", ["Time", "U", "I"]):
            time = point["Time"]
            voltage = point["U"]
            current = point["I"]

            # Add voltage to Y1 axis
            vc_graph.add_point(time, voltage, bta.GraphAxis.Y1)

            # Add current to Y2 axis
            vc_graph.add_point(time, current, bta.GraphAxis.Y2)

        bta.print("Voltage & current graph complete!")
