SuneVav
October 25, 2024, 11:40am
1
Hi,
I’m trying to set the colors for my line charts but I can only do it for the actual line and not the marker symbol.
See the uploaded files. One image shows the default colors and the other where I try to set the color to green but get a mix of green and blue.
@SuneVav
Can you please provide the code you are using to set the colors for the line charts and specify which Aspose product you are using?
SuneVav
October 25, 2024, 11:43am
3
It’s Aspose Words for Python.
The code:
shape3 = builder.insert_chart(aw.drawing.charts.ChartType.LINE,180,142)
shape3.stroked = False
chart3 = shape3.chart
chart3.title.text = "Test"
chart3.title.font.size = 12
chart3.title.font.color = pydraw.Color.black
chart3.series.clear()
chart3.title.show = False
chart3.series.clear()
categories = [v2, v1, v]
chart3.series.add("Value1", categories, [int(var1_2), int(var1_1), int(var1)])
chart3.series.add("Value2", categories, [int(var2_2), int(var2_1), int(var2)])
chart3.series[0].marker.symbol = aw.drawing.charts.MarkerSymbol.CIRCLE
chart3.series[0].format.stroke.color = pydraw.Color.green
chart3.series[0].marker.symbol.color = pydraw.Color.green
chart3.series[0].marker.size = 3
chart3.series[0].format.stroke.weight = 1
#chart3.series[0].format.stroke.color = pydraw.Color.light_blue
chart3.series[1].marker.symbol = aw.drawing.charts.MarkerSymbol.CIRCLE
chart3.series[1].marker.size = 3
chart3.series[1].format.stroke.weight = 1
@SuneVav You should set marker fill and stroke color:
chart3.series[0].marker.format.fill.color = pydraw.Color.green
chart3.series[0].marker.format.stroke.color = pydraw.Color.green
SuneVav
October 25, 2024, 12:15pm
5
Wow, that must have been the only combination I didn’t try.
And I couldn’t find it in the documentation either.
It works perfectly. Thanks!
1 Like
@SuneVav It is perfect that you managed to achieve what you need. By the way, there is an example in the documentation here:
https://reference.aspose.com/words/python-net/aspose.words.drawing.charts/chartmarker/format/
Please feel free to ask in case of any issues, we are always glad to help you.
Great, thanks. I couldn’t find that when I searched and Googled but I will bookmark it for future reference.
1 Like