Showing posts with label C# chart. Show all posts
Showing posts with label C# chart. Show all posts

Thursday, August 1, 2019

C# code for get SVG donut chart

   

  private string getSvgDonutCircle(int value)
        {
            int diff = 100 - value;
            string html = "<svg viewBox='-5 -5 30 30' class='donut'>" +
               "<circle class='donut-hole' cx='11' cy='11' r='10' fill='#fff'></circle>" +
               "<circle class='donut-ring' cx='11' cy='11' r='10' fill='transparent' " +
               "stroke='#E1E1E1' stroke-width='2'></circle>" +
               "<circle class='donut-segment' cx='11' cy='11' r='10' fill='transparent' " +
               "stroke='" + getColorCode(value) + "' stroke-width='2' stroke-dasharray='" + value + " " + diff + "' stroke-dashoffset='65'></circle>" +
               "<g class='chart-text'>" +
               "<text x='40%' y='44%' class='chart-number'>" + value + "</text>" +
               "</g></svg>";
            return html;
        }

        private string getColorCode(int value)
        {
            if (value < 70 && value > 31)
            {
                return "#F39000";
            }
            else if (value > 70)
            {
                return "#00A13A";
            }
            else if (value < 31)
            {
                return "#AF022B";
            }
            return "";
        }

Wednesday, September 26, 2018

How to change the series legend position in c# chart window application


1. Go to form design mode and select chart

2. goto the properties window click on the Legends collection


3. Choose the position from docking properties (Left,Right,Top,Bottom)

4. Then Click ok now your series legend position changed.

Wednesday, September 19, 2018

Chart Type In C# Window Form Application

In this article i will show how many type of chart available in c# charting tool with sample  example.

There  are many type of chart available in charting tool in c#

1. Area Chart 
     The Area chart shows the relationship of the parts to a whole area.
   Area chart Sample Example

2. Bar Chart
   The Bar Chart are used to comparisons among individual items.
 Bar Chart Sample Example

Bar Chart in C#

  The Bar Chart are used to comparisons among individual items.

The following c# code are used draw a bar chart in c# window application

            chart1.Titles.Add("Area Chart ");
            Series s1 = this.chart1.Series.Add("Population");
            s1.ChartType = SeriesChartType.Bar;
            s1.Points.AddXY("2001",57);
            s1.Points.AddXY("2002", 67);
            s1.Points.AddXY("2003", 97);
            s1.Points.AddXY("2004", 107);


Area Chart In C#

 The Area chart shows the relationship of the parts to a whole area.

The below c# code are used to draw the area chart in c#.
`

            chart1.Titles.Add("Area Chart ");
            Series s1 = this.chart1.Series.Add("Population");
            s1.ChartType = SeriesChartType.Area;
            s1.Points.AddXY("2001",57);
            s1.Points.AddXY("2002", 67);
            s1.Points.AddXY("2003", 97);

            s1.Points.AddXY("2004", 107);



Bsaic of chart tool in c#

1. Add Tilte in Chart 
chart1.Titles.Add("OverAll Experience By Zones");

2. Add Series Dynamically 
 Series series1 = this.chart1.Series.Add("Your Series");

3. Change ForeColor 
 series1.ForeColor = System.Drawing.Color.FromArgb(0, 176, 80);

4. Change BackColor
 series1.BackColor = System.Drawing.Color.FromArgb(0, 176, 80);

5. Chnage stackedColumn color dynamically
 series1.Color = System.Drawing.Color.FromArgb(0, 176, 80);

6. Change Width of StackedColumn 
series1["PixelPointWidth"] = "20";

7. Show Label value on stackedColumn chart 
series1.IsValueShownAsLabel = true;

8. Add Data point to series
series1.Points.AddXY("2001", 50);
series1.Points.AddXY("2002", 80);
series1.Points.AddXY("2003", 60);

9. Add Chart Type Dynamically
series1.ChartType = SeriesChartType.Area;

10. Set Marker style 
series1.MarkerStyle = MarkerStyle.Triangle;

Featured Post

What is JavaScript? What is the role of JavaScript engine?

  The JavaScript is a Programming language that is used for converting static web pages to interactive and dynamic web pages. A JavaScript e...