简体   繁体   中英

Spreadsheetlight Pie-chart

How do i display percentage on my pie chart using spreadsheetlight?

This is my current code

        double fChartHeight = 15.0;
        double fChartWidth = 7.5;

        SLChart chart;

        chart = sl.CreateChart("N1", "R2");
        chart.SetChartType(SLPieChartType.Pie);
        chart.SetChartPosition(piechartRow, 0, piechartRow + fChartHeight, fChartWidth);
        chart.Title.Shadow.SetPreset(SpreadsheetLight.Drawing.SLShadowPresetValues.PerspectiveDiagonalUpperLeft);              
        sl.InsertChart(chart);

        sl.SaveAs(path);

Not sure exactly what you're looking for, but hope this gets you in the right direction.

    double fChartHeight = 15.0;
    double fChartWidth = 7.5;

    SLChart chart;

    chart = sl.CreateChart("N1", "R2");
    chart.SetChartType(SLPieChartType.Pie);
    chart.SetChartPosition(piechartRow, 0, piechartRow + fChartHeight, fChartWidth);
    chart.Title.Shadow.SetPreset(SpreadsheetLight.Drawing.SLShadowPresetValues.PerspectiveDiagonalUpperLeft);

    SLGroupDataLabelOptions grplabels = chart.CreateGroupDataLabelOptions();
    grplabels.ShowPercentage = true;
    grplabels.ShowValue = false;
    chart.SetGroupDataLabelOptions(grplabels);

    sl.InsertChart(chart);

    sl.SaveAs(path);

If you want to tweak individual data labels, then use the SLDataLabelOptions class. Basically, imagine how you'd do it in Excel. In fact, do make a pie chart in Excel. Format the pie chart to what you want it to look. Replicate the steps you did in Excel with SpreadsheetLight.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM