Setting MarkerStyle

Hi

setting series line weight type and marker style does not have any effect.

regards

Rale

Try this code sample:

Workbook wb = new Workbook();

wb.Worksheets.Clear();

Worksheet ws = wb.Worksheets.Add("New");

Style style = wb.Styles[wb.Styles.Add()];

style.Name = "DateTimeStyle";

style.Custom = "dd-mm hh:mm:ss";

DateTime dt = DateTime.Now.Date;

ws.Cells[23, 2].PutValue(dt);

ws.Cells[23, 2].SetStyle(style);

ws.Cells[24, 2].PutValue(dt.AddHours(1));

ws.Cells[24, 2].SetStyle(style);

ws.Cells[25, 2].PutValue(dt.AddHours(2));

ws.Cells[25, 2].SetStyle(style);

ws.Cells[26, 2].PutValue(dt.AddHours(3));

ws.Cells[26, 2].SetStyle(style);

ws.Cells[27, 2].PutValue(dt.AddHours(4));

ws.Cells[27, 2].SetStyle(style);

ws.Cells[28, 2].PutValue(dt.AddHours(5));

ws.Cells[28, 2].SetStyle(style);

ws.Cells[29, 2].PutValue(dt.AddHours(6));

ws.Cells[29, 2].SetStyle(style);

ws.Cells[23, 3].PutValue(3);

ws.Cells[24, 3].PutValue(4);

ws.Cells[25, 3].PutValue(9);

ws.Cells[26, 3].PutValue(13);

ws.Cells[27, 3].PutValue(16);

ws.Cells[28, 3].PutValue(3);

ws.Cells[29, 3].PutValue(7);

Chart chart = ws.Charts[ws.Charts.Add(ChartType.ScatterConnectedByLinesWithoutDataMarker, 1, 1, 22, 12)];

chart.CategoryAxis.TickLabels.NumberFormat = "dd-mm hh:mm;@";

chart.CategoryAxis.TickLabels.Rotation = 45;

chart.CategoryAxis.TickLabels.Font.Size = 8;

chart.CategoryAxis.MinValue = dt;

chart.CategoryAxis.MaxValue = dt.AddHours(6);

double d = 1f / 24f;

chart.CategoryAxis.MajorUnit = 0.04166666;

chart.Legend.Position = LegendPositionType.Bottom;

chart.ValueAxis.TickLabels.NumberFormat = "0";

chart.ValueAxis.MinValue = 0;

chart.ValueAxis.MaxValue = 20;

chart.Placement = PlacementType.Move;

String chartSubTitle = DateTime.Now.ToString();

chart.Title.Text = "Data" + "\n" + chartSubTitle;

FontSetting chars = chart.Title.Characters(chart.Title.Text.Length - chartSubTitle.Length, chartSubTitle.Length);

chars.Font.Size = 10;

chars.Font.IsBold = false;

chart.ValueAxis.Title.Text = "unit";

Series aSerie = chart.NSeries[chart.NSeries.Add(String.Format("{0}!{1}{2}:{1}{3}", ws.Name, "D", 24, 30), true)];

aSerie.XValues = String.Format("{0}!{1}{2}:{1}{3}", ws.Name, "C", 24, 30);

aSerie.Name = "Date";

aSerie.Line.Color = Color.YellowGreen;

aSerie.Line.Weight = WeightType.HairLine;

aSerie.MarkerStyle = ChartMarkerType.Diamond;

aSerie.MarkerBackgroundColorSetType = FormattingType.Automatic;

aSerie.MarkerBackgroundColor = Color.YellowGreen;

aSerie.MarkerForegroundColorSetType = FormattingType.None;

aSerie.MarkerSize = 3;

wb.Save(@"Result.xlsx", FileFormatType.Excel2007Xlsx);

Hi Ranko,

Please use the following code. we have fixed the issue with the code. The issue was with FormattingType settings.

Workbook wb = new Workbook();
wb.Worksheets.Clear();
Worksheet ws = wb.Worksheets.Add("New");
Style style = wb.Styles[wb.Styles.Add()];
style.Name = "DateTimeStyle";
style.Custom = "dd-mm hh:mm:ss";
DateTime dt = DateTime.Now.Date;
ws.Cells[23, 2].PutValue(dt);
ws.Cells[23, 2].SetStyle(style);
ws.Cells[24, 2].PutValue(dt.AddHours(1));
ws.Cells[24, 2].SetStyle(style);
ws.Cells[25, 2].PutValue(dt.AddHours(2));
ws.Cells[25, 2].SetStyle(style);
ws.Cells[26, 2].PutValue(dt.AddHours(3));
ws.Cells[26, 2].SetStyle(style);
ws.Cells[27, 2].PutValue(dt.AddHours(4));
ws.Cells[27, 2].SetStyle(style);
ws.Cells[28, 2].PutValue(dt.AddHours(5));
ws.Cells[28, 2].SetStyle(style);
ws.Cells[29, 2].PutValue(dt.AddHours(6));
ws.Cells[29, 2].SetStyle(style);
ws.Cells[23, 3].PutValue(3);
ws.Cells[24, 3].PutValue(4);
ws.Cells[25, 3].PutValue(9);
ws.Cells[26, 3].PutValue(13);
ws.Cells[27, 3].PutValue(16);
ws.Cells[28, 3].PutValue(3);
ws.Cells[29, 3].PutValue(7);
int chartIndex = ws.Charts.Add(ChartType.ScatterConnectedByLinesWithoutDataMarker, 1, 1, 22, 12);
Chart chart = ws.Charts[chartIndex];
chart.CategoryAxis.TickLabels.NumberFormat = "dd-mm hh:mm;@";
chart.CategoryAxis.TickLabels.Rotation = 45;
chart.CategoryAxis.TickLabels.Font.Size = 8;
chart.CategoryAxis.MinValue = dt;
chart.CategoryAxis.MaxValue = dt.AddHours(6);
double d = 1f / 24f;
chart.CategoryAxis.MajorUnit = 0.04166666;
chart.Legend.Position = LegendPositionType.Bottom;
chart.ValueAxis.TickLabels.NumberFormat = "0";
chart.ValueAxis.MinValue = 0;
chart.ValueAxis.MaxValue = 20;
chart.Placement = Aspose.Cells.Drawing.PlacementType.Move;
String chartSubTitle = DateTime.Now.ToString();
chart.Title.Text = "Data" + "\n" + chartSubTitle;
FontSetting chars = chart.Title.Characters(chart.Title.Text.Length - chartSubTitle.Length, chartSubTitle.Length);
chars.Font.Size = 10;
chars.Font.IsBold = false;
chart.ValueAxis.Title.Text = "unit";
int iSeriesIndex = chart.NSeries.Add(String.Format("{0}!{1}{2}:{1}{3}", ws.Name, "D", 24, 30), true);
Series aSerie = chart.NSeries[iSeriesIndex];
aSerie.XValues = String.Format("{0}!{1}{2}:{1}{3}", ws.Name, "C", 24, 30);
//aSerie.Type = ChartType.Line;
aSerie.Name = "Date";
aSerie.Line.Color = Color.BlanchedAlmond;
aSerie.Line.Weight = Aspose.Cells.Drawing.WeightType.MediumLine;
aSerie.MarkerStyle = ChartMarkerType.Diamond;
aSerie.MarkerBackgroundColorSetType = FormattingType.Automatic;
aSerie.MarkerBackgroundColor = System.Drawing.Color.Black;
aSerie.MarkerForegroundColorSetType = FormattingType.Automatic;
aSerie.MarkerSize = 3;
wb.Save(sSavePath, SaveFormat.Xlsx);

Thanks,

Hi Salman


it helped with the markers, but the line is same as WeightType.MediumLine even though I am using HairLine. Please see my sample in first post.

regards
Rale

Hi Ranko,

We are able to reproduce the line issue. We are working on it. we will update you as soon as it is fixed.

Thanks,

Hi Ranko,

Please use the updated version of Aspose.Cells.dll v5.1.2.5. The issue regarding series line weight has been fixed.

Thanks,