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.

Fri Sep 25, 2015 2:57 pm

Hi
Does this support Gauge chart? If so please provide a sample.

thanks

muthu.ramakrishnan@gs1ca.org
 
Posts: 2
Joined: Fri Sep 25, 2015 2:53 pm

Mon Sep 28, 2015 4:00 am

Hello,

Thanks for your inquiry.
Our Spire.Xls supports it, please refer to the following sample code:

Code: Select all
 Workbook book = new Workbook();
            Worksheet sheet = book.Worksheets[0];
            sheet.Range["A1"].Value = "Donut";
            sheet.Range["A2"].Value = "25";
            sheet.Range["A3"].Value = "50";
            sheet.Range["A4"].Value = "25";
            sheet.Range["A5"].Value = "100";
            sheet.Range["B1"].Value = "Pie";
            sheet.Range["B2"].Value = "75";
            sheet.Range["B3"].Value = "1";
            sheet.Range["B4"].Value = "124";

            Chart chart = sheet.Charts.Add(ExcelChartType.Doughnut);
            chart.DataRange = sheet.Range["A1:B5"];
            chart.SeriesDataFromRange = false;
            chart.HasLegend = false;
            chart.LeftColumn = 1;
            chart.TopRow = 7;
            chart.RightColumn = 10;
            chart.BottomRow = 25;

            var cs1 = (ChartSerie)chart.Series["Donut"];
            cs1.Values = sheet.Range["A2:A5"];
            cs1.Format.Options.IsVaryColor = true;
            cs1.DataPoints[3].DataFormat.Fill.FillType = ShapeFillType.SolidColor;
            cs1.DataPoints[3].DataFormat.Fill.ForeColor = Color.White;
            cs1.DataFormat.Options.FirstSliceAngle = 270;

            var cs2 = (ChartSerie)chart.Series["Pie"];
            cs2.Values = sheet.Range["B2:B5"];
            cs2.SerieType = ExcelChartType.Pie;
            cs2.DataFormat.Options.FirstSliceAngle = 270;
            cs2.DataPoints[0].DataFormat.Fill.Visible = false;
            cs2.DataPoints[1].DataFormat.Fill.FillType = ShapeFillType.SolidColor;
            cs2.DataPoints[1].DataFormat.Fill.ForeColor = Color.Black;
            cs2.DataPoints[2].DataFormat.Fill.Visible = false;
            cs2.DataPoints[3].DataFormat.Fill.Visible = false;
            string fn = "AddGaugeChart.xlsx";
            book.SaveToFile(fn, FileFormat.Version2010);


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Tue Sep 29, 2015 8:54 am

Hello,

Has your issue been solved?
Thanks for your feedback.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Wed Sep 30, 2015 3:58 pm

Thanks. That works.

Due to our specific request around needle shape and color ranges we took a workaround(there are only 4 possible values so we use 4 images)

muthu.ramakrishnan@gs1ca.org
 
Posts: 2
Joined: Fri Sep 25, 2015 2:53 pm

Thu Oct 01, 2015 1:49 am

Hello,

Thanks for your feedback.
Please feel free to contact us if you have any question.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Return to Spire.XLS