Ask a questionAsk a question
 

Answerline chart with CSS

  • Tuesday, November 03, 2009 11:38 AMcrinch Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

      I am using .net chart conroller and have copied the code from websample of the msdn for line chart but my chart is not like as the output of websamples line chart.
    Here is my code.

    linechart.aspx :

    <code><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="linechart.aspx.cs" Inherits="mychartproject.linechart" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
        <head>
            <title>Line Chart</title>
            <meta content="Microsoft Visual Studio 7.0" name="GENERATOR"/>
            <meta content="C#" name="CODE_LANGUAGE"/>
            <meta content="JavaScript" name="vs_defaultClientScript"/>
            <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"/>
            <link media="all" href="../../samples.css" type="text/css" rel="stylesheet" />
        </head>
    <body>
        <form id="form1" runat="server">
        <div>
       
        </div>
        </form>
    </body>
    </html></code>

    and
    linechart.aspx.cs :
    <code>
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.DataVisualization.Charting;

    namespace mychartproject
    {
        public partial class linechart : System.Web.UI.Page
        {
            private void Page_Load(object sender, EventArgs e)
            {

                //create chart object
                System.Web.UI.DataVisualization.Charting.Chart lineChart = new System.Web.UI.DataVisualization.Charting.Chart();

                //lineChart.RenderType = RenderType.ImageTag;   // not working

                //lineChart.ImageLocation = "~/TempImages/ChartPic_#SEQ(300,3)";   //Note working          

                lineChart.Width = 400;
                lineChart.Palette = ChartColorPalette.BrightPastel;
                lineChart.ImageType = ChartImageType.Png;
                lineChart.BorderlineDashStyle = ChartDashStyle.Solid;           
               
                lineChart.Legends.Add("Legend1");

                //Change the title to " Dynamic Legend SharePoint Web Part with ASP .net Chart Control"
                Title t = new Title("Code Behind Page", Docking.Top, new System.Drawing.Font("Trebuchet MS", 14, System.Drawing.FontStyle.Bold), System.Drawing.Color.FromArgb(26, 59, 105));
                lineChart.Titles.Add(t);
               

               
                //create serires
                lineChart.Series.Add("Series1");
                lineChart.Series.Add("Series2");  
            
                //create chartArea
                lineChart.ChartAreas.Add("ChartArea1");


                // Populate series with random data
                Random random = new Random();
                for (int pointIndex = 0; pointIndex < 10; pointIndex++)
                {
                    lineChart.Series["Series1"].Points.AddY(random.Next(45, 95));
                    lineChart.Series["Series2"].Points.AddY(random.Next(5, 75));
                }

                // Set series chart type           
                lineChart.Series["Series1"].ChartType = SeriesChartType.Line;
                lineChart.Series["Series2"].ChartType = SeriesChartType.Spline;           


                // Set point labels
                lineChart.Series["Series1"].IsValueShownAsLabel = true;
                lineChart.Series["Series2"].IsValueShownAsLabel = true;

                // Enable X axis margin
                lineChart.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = true;

                // Enable 3D, and show data point marker lines
                //lineChart.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
                lineChart.Series["Series1"]["ShowMarkerLines"] = "True";
                lineChart.Series["Series2"]["ShowMarkerLines"] = "True";


                lineChart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
                lineChart.BorderColor = System.Drawing.Color.FromArgb(26, 59, 105);
                lineChart.BorderlineDashStyle = ChartDashStyle.Solid;
                lineChart.BorderWidth = 2;
                //lineChart.BackColor = "D3DFF0";



                Page.Controls.Add(lineChart);
            }

        }
    }

    How I can impletment the css on my line chart in code file.

    Thanks in advance.
    CRINHC
    </code>

Answers

  • Thursday, November 05, 2009 5:56 PMCole Brand Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    This might be a stupid question, but you are aware that the chart is returned from the server as an image, so the only CSS you would be applying would be sizing and scaling...

    What styling exactly are you hoping to apply?
    Please don't forget (and feel free to remind me) to post if you got the answer you wanted, and select who really answered your post when you do so future visitors will know too! Remember, this is .NET 4.0 in a .NET 3.5 world, you're a pioneer right now.

All Replies

  • Thursday, November 05, 2009 5:56 PMCole Brand Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    This might be a stupid question, but you are aware that the chart is returned from the server as an image, so the only CSS you would be applying would be sizing and scaling...

    What styling exactly are you hoping to apply?
    Please don't forget (and feel free to remind me) to post if you got the answer you wanted, and select who really answered your post when you do so future visitors will know too! Remember, this is .NET 4.0 in a .NET 3.5 world, you're a pioneer right now.