Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.
Wed Dec 06, 2023 8:16 pm
I have created a line chart with markers. I am trying to figure out how to make the color of the markers the same color as the line. I am looping through the Series depicted below. How do I get a hold of the line color per series?
foreach (ChartSerie cs in chart.Series)
{
cs.DataFormat.MarkerBackgroundColor = Color of line??;
cs.DataFormat.MarkerSize = 6;
cs.DataFormat.MarkerStyle = ChartMarkerType.Circle;
}
-

jrobinsontx
-
- Posts: 2
- Joined: Wed Dec 06, 2023 8:04 pm
Thu Dec 07, 2023 2:23 am
Hello,
Thank you for your inquiry.
Please refer to the code below to implement your requirements.
- Code: Select all
...
//Traverse all series
foreach (ChartSerie cs in chart.Series)
{
//Gets the color of the line of the series
Color color = cs.DataPoints.DefaultDataPoint.DataFormat.LineProperties.Color;
//Sets the color of the markers
cs.DataFormat.MarkerBackgroundColor =color;
cs.DataFormat.MarkerSize = 6;
cs.DataFormat.MarkerStyle = ChartMarkerType.Circle;
}
...
If you have any further questions or need additional assistance, please feel free to let me know.
Sincerely,
Annika
E-iceblue support team
-


Annika.Zhou
-
- Posts: 1657
- Joined: Wed Apr 07, 2021 2:50 am