[Python] openpyxl cant make chart in right way

Discussão em 'Python' iniciado por Stack, Março 6, 2025.

  1. Stack

    Stack Membro Participativo

    The data i work with looks like this: data

    ref_dates = Reference(chart_data, min_col=1, min_row=2, max_row=61)
    ref_sediment = Reference(chart_data, min_col=3, min_row=1, max_row=61)


    def create_chart_sediment(self, wb: Workbook, ref_dates, ref_sediment):
    chart = LineChart()
    chart.title = "CHART"
    chart.style = 13
    chart.y_axis.title = "SEDIMENT"
    chart.x_axis.title = "DATE"
    chart.y_axis.scaling.min = 0
    chart.y_axis.scaling.max = 900_000_000
    chart.x_axis.delete = False
    chart.y_axis.delete = False
    chart.x_axis.tickLblSkip = 1
    chart.add_data(ref_sediment, titles_from_data=True)
    chart.set_categories(ref_dates)

    chart_sheet = wb.create_chartsheet("CHART_SEDIMENT")
    chart_sheet.add_chart(chart)


    The chart i get: chart

    I want to have one line named "sediment".

    I tryed to change Reference: min_row=1 to min_row=2, titles_from_data=True/False

    Continue reading...

Compartilhe esta Página