scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.35k stars 510 forks source link

Bubble size in XY Scatter chart #794

Open bagasna opened 2 years ago

bagasna commented 2 years ago

Does anyone know how to scale size bubble in XL_CHART_TYPE.BUBBLE ?? I've change the properties of size chart but it doesn't work.

def scatter(self, slide, x, y, cx, cy, line, datas):
    try:
        chart_data = BubbleChartData()

        series_1 = chart_data.add_series('power_scale')
        i = 0
        for data in datas:
            series_1.add_data_point(round(data["interest"], 2), round(data["power_scale"], 1), 10)
            i += 1
            print(i)
        chart = slide.shapes.add_chart(
            XL_CHART_TYPE.BUBBLE, Inches(x), Inches(y), Inches(cx), Inches(cy), chart_data
        ).chart

        if line == False:
            chart.value_axis.format.line.color.rgb = RGBColor(200, 200, 200)
            chart.category_axis.format.line.color.rgb = RGBColor(200, 200, 200)
            chart.value_axis.major_gridlines.format.line.color.rgb = RGBColor(255, 255, 255)
    except:
        traceback.print_exc()