I added a chart in docx, and I hope I can edit the data to change histogram bins length.
How can I do it?
@scanny This is the code I tried, and show me error is
chart.replace_data(chart_data) AttributeError: 'module' object has no attribute 'replace_data'
import docx
import os
import sys
import csv
import datetime
import time
import pptx
from pptx import chart
from pptx.chart import data
from pptx.chart.data import CategoryChartData
CURRENT_DIR = os.path.dirname(os.path.abspath(sys.argv[0]))
docxFilePath = os.path.join(CURRENT_DIR,'sample.docx')
chart_data = CategoryChartData()
chart_data.categories = ['East', 'West', 'Midwest']
chart_data.add_series('Series 1', (19.2, 21.4, 16.7))
chart.replace_data(chart_data)
filename ='test.docx'
filepath = os.path.join(r'C:\Users\Administrator\Desktop\python test\update_test', filename)
doc.save(filepath)