SasqChart
Home
Home
Chart Gallery
Thumbs
Bar Charts
Stacked Bar
Line Charts
Area Charts
Stacked Area
Pie Charts
Mixed Charts
Chart Styles
Axis Options
Layout Options
ASP.Net Tutorials
Base Example
DataSet Bind
WinForm Tutorials
Base Example
DataSet Bind
  Forums Login
Username:
Password:
 
Create account
Forget password?
 Who is Online

There are currently:
64 anonymous users online.

0 of 204 registered users online.

There have been 10517 Page Hits by 8065 users

 Search Forums

More search options


Custom BarChart Example

C# Example Code

{
    int width = (int)chart.Width.Value;        // Hack. Assuming type = Pixel
    int height = (int)chart.Height.Value;        // Hack. Assuming type = Pixel

    System.Random r= new System.Random();

    string []lables = {"Mon", "Tue", "Wed", "Thur", "Fri"};
    chart.Series[0].Type = ChartType.Bar;
    chart.Series[1].Type = ChartType.Bar;
    chart.Series[2].Type = ChartType.Bar;
    chart.Series[0].Name = "Orange";
    chart.Series[1].Name = "Apple";
    chart.Series[2].Name = "Plum";

    // Set the theme
    chart.Theme = Theme.Blues;

    // Setup the Header
    chart.Header.CustomRectangle = new Rectangle(0, 0, width, 50);
    chart.Header.Text = "Fruit eaten this week";
    chart.Header.Style.Font = new Font(FontFamily.GenericSansSerif, 25);
    
    // Position the chart
    chart.ChartStyle.Type = SasqChart.Style.FillType.None;
    chart.CustomRectangle = new Rectangle(0, 50, width, height-50);

    // Position the legend
    chart.Legend.Visible = true;
    chart.Legend.CustomRectangle = new Rectangle(65, 65, 100, 100);
    chart.Legend.Style.FillColor = Color.FromArgb(0xC0, Color.SkyBlue);
                
    // Turn on data labels
    chart.DataLabelFormat = "#";    
    chart.ShowDataLabel = true;

    // Set the chart axis
    chart.YAxis.MajorTickStep = 10;
    chart.YAxis.MinorTickStep = 5;
    chart.YAxis.Min = 0;
    chart.YAxis.Max = 30;
    chart.SecondaryYAxis.Visible = false;

    // Add random data
    for (int i=0;i<3;i++)
    {
        for (int j=0;j<5;j++)
        {
            chart.Series[i].Data.Add(new DataPoint(10 + j + r.Next((j+1)*3), lables[j]));
        }
    }         
}

ASP.Net C# Example

<%@ Register tagPrefix="SasqChart" Namespace="SasqChart" Assembly="SasqChart" %>
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<HTML>
    <HEAD>
        <title>Simple C# SasqChart Example</title>
        <script runat="server">
            private void Page_Load(object sender, System.EventArgs e)		
            {
                int width = (int)chart.Width.Value;        // Hack. Assuming type = Pixel
                int height = (int)chart.Height.Value;        // Hack. Assuming type = Pixel
            
                System.Random r= new System.Random();
            
                string []lables = {"Mon", "Tue", "Wed", "Thur", "Fri"};
                chart.Series[0].Type = ChartType.Bar;
                chart.Series[1].Type = ChartType.Bar;
                chart.Series[2].Type = ChartType.Bar;
                chart.Series[0].Name = "Orange";
                chart.Series[1].Name = "Apple";
                chart.Series[2].Name = "Plum";
            
                // Set the theme
                chart.Theme = Theme.Blues;
            
                // Setup the Header
                chart.Header.CustomRectangle = new Rectangle(0, 0, width, 50);
                chart.Header.Text = "Fruit eaten this week";
                chart.Header.Style.Font = new Font(FontFamily.GenericSansSerif, 25);
                
                // Position the chart
                chart.ChartStyle.Type = SasqChart.Style.FillType.None;
                chart.CustomRectangle = new Rectangle(0, 50, width, height-50);
            
                // Position the legend
                chart.Legend.Visible = true;
                chart.Legend.CustomRectangle = new Rectangle(65, 65, 100, 100);
                chart.Legend.Style.FillColor = Color.FromArgb(0xC0, Color.SkyBlue);
                            
                // Turn on data labels
                chart.DataLabelFormat = "#";    
                chart.ShowDataLabel = true;
            
                // Set the chart axis
                chart.YAxis.MajorTickStep = 10;
                chart.YAxis.MinorTickStep = 5;
                chart.YAxis.Min = 0;
                chart.YAxis.Max = 30;
                chart.SecondaryYAxis.Visible = false;
            
                // Add random data
                for (int i=0;i<3;i++)
                {
                    for (int j=0;j<5;j++)
                    {
                        chart.Series[i].Data.Add(new DataPoint(10 + j + r.Next((j+1)*3), lables[j]));
                    }
                }         
            }

        </script>
    </HEAD>
    <body>
        <SasqChart:WebChartControl id="chart" runat="server" width="600" height="400" />
    </body>
</HTML>