def _create_chart(worksheet): """Create the f*****g chart""" chart = ScatterChart() chart.varyColors = True chart.title = "Financial Analysis" chart.style = 1 chart.height = 10 chart.width = 20 chart.x_axis.title = "Financial Quarter" chart.y_axis.title = "Cost" chart.legend = None chart.x_axis.majorUnit = 0.5 chart.x_axis.minorGridlines = None # chart.y_axis.majorUnit = 200 xvalues = Reference(worksheet, min_col=1, min_row=3, max_row=6) picker = _color_gen() for i in range(2, 7): values = Reference(worksheet, min_col=i, min_row=2, max_row=6) series = Series(values, xvalues, title_from_data=True) series.smooth = True series.marker.symbol = "circle" line_prop = LineProperties(solidFill=next(picker)) series.graphicalProperties.line = line_prop chart.series.append(series) worksheet.add_chart(chart, "G1") return worksheet
datax = Reference(sheet1, min_col=4, min_row=2, max_col=4, max_row=11) categs = Reference(sheet1, min_col=2, min_row=2, max_row=11) chart1 = BarChart() chart1.add_data(datax) chart1.set_categories(categs) chart1.legend = None # 범례 chart1.varyColors = True chart1.title = "상위 10위 좋아요수" sheet3.add_chart(chart1, "A8") # Trythis 3-2번 chart2 = ScatterChart() chart2.style = 13 datax = Reference(sheet1, min_col=1, min_row=2, max_row=11) value = Reference(sheet1, min_col=5, min_row=1, max_row=11) series = Series(value, datax, title_from_data=True) chart2.series.append(series) categs = Reference(sheet1, min_col=2, min_row=2, max_row=11) # chart1.add_data(datax) chart2.set_categories(categs) chart2.legend = None # 범례 chart2.varyColors = True chart2.title = "상위 10위 좋아요차이수" sheet3.add_chart(chart2, "K8") book.save("./data/meltop100.xlsx")