How to apply color to only dot in chart

Hello Team,

i want to draw a multi series graph, in the second series i should show dot graph i have drawn but i want to show the colors for dots based on some condition, i am pasting my sample code here, could you help me in achieving it,

Thanks in advance

string[] colHeaders = new string[] { “A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”, “I”, “J”, “K”, “L”, “M”, “N”, “O”, “P”, “Q”, “R”, “S”, “T”, “U”, “V”, “W”, “X”, “Y”, “Z”,
“AA”,“AB”,“AC”,“AD”,“AE”,“AF”,“AG”,“AH”,“AI”,“AJ”,“AK”,“AL”,“AM”,“AN”,“AO”,“AP”,“AQ”,“AR”,“AS”,“AT”,“AU”,“AV”,“AW”,“AX”,“AY”,“AZ”
};
Aspose.Cells.License lic = new License();
lic.SetLicense(“Aspose.Cells.lic”);
Workbook wb = new Workbook();
Worksheet ws = wb.Worksheets[0];
Cells cells = ws.Cells;
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn(“Name”, typeof(string)));
dt.Columns.Add(new DataColumn(“Value1”, typeof(int)));
dt.Columns.Add(new DataColumn(“Value2”, typeof(int)));

        dt.Rows.Add("ABC", 40, 10);
        dt.Rows.Add("DEF", 20, 60);
        dt.Rows.Add("GHI", 60, 50);
        dt.Rows.Add("IJK", 80, 30);
        dt.Rows.Add("KLM", 100, 200);

        for (int colindex = 0; colindex < dt.Columns.Count - 1; colindex++)
        {
            Cell cel = cells[colHeaders[colindex] + "1"];
            cel.PutValue(dt.Columns[colindex].ColumnName);
        }
        int rowIndex = 2;
        foreach (DataRow dr in dt.Rows)
        {
            for (int colindex = 0; colindex < dt.Columns.Count; colindex++)
            {
                Cell cel = cells[colHeaders[colindex] + rowIndex.ToString()];
                cel.PutValue(dr[colindex]);
            }
            rowIndex++;
        }
        ws.Name = "ChartData";
        int chartSheetIndex = wb.Worksheets.Add();
        Worksheet chartsheet = wb.Worksheets[chartSheetIndex];
        Cells chartCells = chartsheet.Cells;
        int chartIndex = chartsheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 2, 0, 33, 17);
        Aspose.Cells.Charts.Chart chart = chartsheet.Charts[chartIndex];

        string categorySeries = "=ChartData!A2:A6";
        string dataSeries = "=ChartData!B2:B6";
        string growthSeries = "=ChartData!C2:C6";
        chart.NSeries.Add(dataSeries, true);
        chart.NSeries.Add(growthSeries, true);
        chart.NSeries[1].Type = Aspose.Cells.Charts.ChartType.Scatter;
        chart.NSeries[1].PlotOnSecondAxis = true;
        chart.NSeries.CategoryData = categorySeries;
        
        for (int pCount = 0; pCount < chart.NSeries[1].Points.Count - 1; pCount++)
        {
            var valueCell = cells.GetCell(pCount + 1, 2);
            var value = Convert.ToInt32(valueCell.Value);
            if (Convert.ToInt32(value) > 50)
                chart.NSeries[1].Points[pCount].Area.ForegroundColor = System.Drawing.Color.Green;
            else
                chart.NSeries[1].Points[pCount].Area.ForegroundColor = System.Drawing.Color.Green;

        }
        chartsheet.Name = "Dot chart";
        wb.Save(@"C:\ExportDirectory\DotChart.xlsx");

@Aspose.Slides_Dll,

Thanks for providing us sample code and details.

Please change the following code segment:
i.e.,

for (int pCount = 0; pCount < chart.NSeries[1].Points.Count - 1; pCount++)
{
	var valueCell = cells.GetCell(pCount + 1, 2);
	var value = Convert.ToInt32(valueCell.Value);
	if (Convert.ToInt32(value) > 50)
		chart.NSeries[1].Points[pCount].Area.ForegroundColor = System.Drawing.Color.Green;
	else
		chart.NSeries[1].Points[pCount].Area.ForegroundColor = System.Drawing.Color.Green;
}


to:

for (int pCount = 0; pCount < chart.NSeries[1].Points.Count - 1; pCount++)
{
		var valueCell = cells.GetCell(pCount + 1, 2);
		var value = Convert.ToInt32(valueCell.Value);
		if (Convert.ToInt32(value) > 50)
		{
		  
			chart.NSeries[1].Points[pCount].Marker.Area.ForegroundColor = System.Drawing.Color.Green;
			
			//Comment this line if you do not want to set the border color.            
			chart.NSeries[1].Points[pCount].Marker.Border.Color = Color.Yellow;
		}
		else
		{
			chart.NSeries[1].Points[pCount].Marker.Area.ForegroundColor = System.Drawing.Color.Green;

			//Comment this line if you do not want to set the border color.            
			chart.NSeries[1].Points[pCount].Marker.Border.Color = Color.Yellow;		 
}

Hope, this helps a bit.

Thank you.

Thanks Team,
it helped me :slight_smile: , thanks a lot

@Aspose.Slides_Dll,

Good to know that it figures out your issue now. Feel free to write us back if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.