How to remove a single DataLabel from a Chart made with EPPlus and C#

How to remove a single DataLabel from a Chart made with EPPlus and C#

By : Cerosh James
Date : October 20 2020, 08:10 AM
wish helps you Is it possible in any way to remove a single DataLabel from a Chart made with EPPlus and C#? , I figured out a solution. This Extension method is doing the trick...
code :
public static void RemoveDataLabel(this ExcelBarChart chart, int serieNumber, int objectNumber)
    var chartXml = chart.ChartXml;

    var nsa = chart.WorkSheet.Drawings.NameSpaceManager.LookupNamespace("a");
    var nsuri = chartXml.DocumentElement.NamespaceURI;

    var nsm = new XmlNamespaceManager(chartXml.NameTable);
    nsm.AddNamespace("a", nsa);
    nsm.AddNamespace("c", nsuri);

    var dLbls = chart.ChartXml.SelectSingleNode(@"c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[c:idx[@val='" + serieNumber + "']]/c:dLbls", nsm);

    var dLbl = chartXml.CreateNode(XmlNodeType.Element, "dLbl", nsuri);

    var idx = chartXml.CreateNode(XmlNodeType.Element, "idx", nsuri);
    var valueIdx = chartXml.CreateAttribute("val", nsuri);
    valueIdx.Value = objectNumber.ToString();

    var delete = chartXml.CreateNode(XmlNodeType.Element, "delete", nsuri);
    var valueDelete = chartXml.CreateAttribute("val", nsuri);
    valueDelete.Value = "1";


Share : facebook icon twitter icon
EPPlus chart from list of single excel cells. How?

EPPlus chart from list of single excel cells. How?

By : piymis
Date : March 29 2020, 07:55 AM
wish of those help The line with cell names separated by commas is the format you want. Did you specify both the x and y axis range? Maybe show your code where you actually add the series.
You should be using ExcelRange not Address. Like this:
code :
public void Chart_From_Cells_Test()
    var existingFile = new FileInfo(@"c:\temp\temp.xlsx");
    if (existingFile.Exists)

    using (var pck = new ExcelPackage(existingFile))
        var myWorkSheet = pck.Workbook.Worksheets.Add("Content");
        var ExcelWorksheet = pck.Workbook.Worksheets.Add("Chart");

        //Some data
        myWorkSheet.Cells["A1"].Value = "A";
        myWorkSheet.Cells["A2"].Value = 100; myWorkSheet.Cells["A3"].Value = 400; myWorkSheet.Cells["A4"].Value = 200; myWorkSheet.Cells["A5"].Value = 300; myWorkSheet.Cells["A6"].Value = 600; myWorkSheet.Cells["A7"].Value = 500;
        myWorkSheet.Cells["B1"].Value = "B";
        myWorkSheet.Cells["B2"].Value = 300; myWorkSheet.Cells["B3"].Value = 200; myWorkSheet.Cells["B4"].Value = 1000; myWorkSheet.Cells["B5"].Value = 600; myWorkSheet.Cells["B6"].Value = 500; myWorkSheet.Cells["B7"].Value = 200;

        ExcelRange values = myWorkSheet.Cells["B2,B4,B6"];
        ExcelRange xvalues = myWorkSheet.Cells["A2,A4,A6"];

        const string myTitle = "Chart 1";
        ExcelChart chart1 = ExcelWorksheet.Drawings.AddChart(myTitle, eChartType.Pie);
        chart1.Series.Add(values, xvalues);

How do i redraw a pie Chart only once, instead of once for every datalabel it has?

How do i redraw a pie Chart only once, instead of once for every datalabel it has?

By : Tyset
Date : March 29 2020, 07:55 AM
Any of those help apparently I was still working with an old version of highcharts, updating to the newest version solved the problem.
Pie Chart VBA DataLabel Formatting

Pie Chart VBA DataLabel Formatting

By : P P
Date : March 29 2020, 07:55 AM
With these it helps Managed to create a loop using the following code that updates the DataLabels format to how I wanted it by going through each point.
code :
Sub FormatDataLabels()
Dim intPntCount As Integer

ActiveSheet.ChartObjects("Chart 4").Activate
With ActiveChart.SeriesCollection(1)
    For intPntCount = 1 To .Points.Count
        .Points(intPntCount).ApplyDataLabels _
            AutoText:=False, ShowSeriesName:=False, ShowCategoryName:=False, _
            ShowValue:=True, ShowPercentage:=True, Separator:="" & Chr(10) & ""
    Next intPntCount
End With
ActiveSheet.ChartObjects("Chart 1").Activate
    With ActiveChart.SeriesCollection(1)
    For intPntCount = 1 To .Points.Count
        .Points(intPntCount).ApplyDataLabels _
            AutoText:=False, ShowSeriesName:=False, ShowCategoryName:=False, _
            ShowValue:=False, ShowPercentage:=True, Separator:="" & Chr(10) & ""
    Next intPntCount
End With
End Sub
Chart js custom datalabel from array

Chart js custom datalabel from array

By : user2861201
Date : March 29 2020, 07:55 AM
it should still fix some issue you where so close to the solution.
So first things first you don't need that var percentage, we will change your function calculate a bit, and also finalize that plugin...formatter.
code :
function calculate(i){
    return (data1[i] / data2[i] * 100)
formatter: function(context, chart_obj) {
    return calculate(chart_obj.dataIndex); //pass the current data index to calculate
more above ...
data: data2,
//  xAxisID: "bar-x-axis1",
datalabels: {
  display: true,
... more bellow
data: data2,
//  xAxisID: "bar-x-axis1",
datalabels: {
  display: true,
  formatter: function(context, chart_obj) {
    return calculate(chart_obj.dataIndex)
Remove axis markings on EPPlus scatter chart

Remove axis markings on EPPlus scatter chart

By : Dream-ear
Date : March 29 2020, 07:55 AM
help you fix your problem The method RemoveGridLines() will not do it as it was designed to remove the horizontal and vertical lines of the chart (I know, I wrote it :) ).
You are looking to remove the Tick Marks. You only circled some of them on each axis but I assume you actually want to remove ALL of them. To do that:
code :
scatterChart.XAxis.MajorTickMark = eAxisTickMark.None;
scatterChart.XAxis.MinorTickMark = eAxisTickMark.None;
scatterChart.YAxis.MajorTickMark = eAxisTickMark.None;
scatterChart.YAxis.MinorTickMark = eAxisTickMark.None;
Related Posts Related Posts :
  • How do request a correct access token in ASP.NET Core for Azure AD to access Microsoft Graph
  • How to run a .NET Core console application on Linux
  • UI not updating for bound element
  • C# Odata v4 open type raw values
  • DocumentFormat.OpenXml Modify Creator Propery of Document
  • How to SetBasePath in ConfigurationBuilder in Core 2.0
  • ASP MVC5 public readonly variable changes value when it should not
  • How to conditionally select item from hashset with queryable linq?
  • Progress Bar C# not showing the real progress
  • Correct logic to reconnect in SignalR with HubConnection
  • ComboBox with two or more sections
  • .NET listbox to SQLite DB
  • C# Ninject binding from Dictionary<Type, Type>
  • asp.net mvc -view displaying real-time progress status
  • Getting reference to dependent in service with generic type
  • Implementing EqualityCompare vs overriding GetHashCode and Equals
  • C# Linq Find all indexes of item in List<int> within another List<int>
  • XML image how to display at data grid columns in c#.net
  • How to override Equals and GetHash of HashSet
  • Creating Windows authentication and SQL Server authentication in login form
  • How to interop with Azure Service Bus topics created by MassTransit using Rebus?
  • MVC 5 Google Calendar Integration
  • C# - Use parallel arrays to calculate cost of a phone call in GUI
  • Use a int in entire code
  • How to display newly added element at the top of StackPanel in WPF?
  • T4MVC is generating T4MVC.cs and T4MVC1.cs
  • Remove blur effect on certain controls inside UserControl
  • Sql Transcation Query to Linq Query in Wcf Rest Service
  • Setting AWS S3 credentials in C# app
  • does not contain in an ObservableCollection
  • App doesn't run it crashed directly after I started it
  • Is it possible in Entity Framework MVC application to run .sql scripts on a different database
  • Type Inference with Deconstruct tuple assignment extension methods
  • Setting up mock objects for EF dbcontext to test repository methods
  • Using C# in XSLT with MSXSL 6.0
  • Absolute positioning of UIElement in FlowDocument in WPF
  • Display debuggers not showing up in Visual Studio 2017
  • Discord.NET Users playing the same game
  • Azure function output API call to 3rd party service
  • Unable to determine the relationship represented by navigation property ASP.NET core 2.0 Entity Framework
  • Regex to find group of Regex inside a word
  • When calling a method, when to reference the class, and when to reference the object?
  • AmazonCloudWatchLogsClient async methods failing with no error
  • Create FileStream in memory instead of saving a physical file on disk
  • ViewBag data coming from ActionFilter is persisting in session even after database
  • ERROR: the name 'lvSubCategories' does not exist in the current context
  • Why datetime can't recognise the string?
  • Getting 500 error while requesting to webservice using Ajax AutoCompleteExtender
  • The property 'x' is not a navigation property of entity type 'y'
  • ASP.NET MVC - How to generate empty input boxes in loop when model is empty?
  • Need help writing regular expression
  • Add/remove buttons to a panel with an arraylist c#
  • Linq .Where(type = typeof(xxx)) comparison is always false
  • Using EF6 Code First without migrations to an existing db how do I specify column names of the many to many join table?
  • C# - Using Thread.Sleep precisely in a console application
  • Add item to a List<Tuple> inside another list
  • Double[,], inversion C#
  • Counting a string to ensure the input is within a min/max boundary
  • Assign invalidValue to Enum variable (why is this not throwing an Exception?)
  • Namespace or type specified in the project-level Imports 'System.Threading.Tasks' doesn't contain any public member or c
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org