Sign In  Sign Up Live-Chat

y axis has string values

Last post 06-30-2008, 8:51 AM by onurkizilyel. 12 replies.
Sort Posts: Previous Next
  •  06-27-2008, 7:27 AM 133441

    y axis has string values

    i draw a bar chart

    the y axis value can be a string val and x axis value will be an integer value, how can i manage this


     
  •  06-27-2008, 7:52 AM 133444 in reply to 133441

    Re: y axis has string values

    Hi,

    Thanks for considering Aspose.

    Yes, you can do it quite easily, you may utilize IsBarHorizontal property of CustomAttributes to true. Check the following code:

       Chart c = new Chart();
       c.Titles.Add(new Title());
       c.Titles[0].Text = "Bar Chart";
       c.ChartArea.LegendBox.IsVisible = false;
       c.ChartArea.AxisY.IsMajorGridVisible = false;
       c.ChartArea.AxisY.AxisLabels.IsDataPointNameVisible = true;
       
       Series s0 = new Series();
       s0.ChartType = ChartType.Bar;
       s0.Name = "Values";
       
       DataPoint dp = new DataPoint("finance", 1, 10);
       dp.IsLabelVisible = true;
       s0.DataPoints.Add(dp);
       
       dp = new DataPoint("energy", 2, 40);
       dp.IsLabelVisible = true;
       s0.DataPoints.Add(dp);
       
       dp = new DataPoint("material", 3, 20);
       dp.IsLabelVisible = true;
       s0.DataPoints.Add(dp);
       
       dp = new DataPoint("technology", 4, 30);
       dp.IsLabelVisible = true;
       s0.DataPoints.Add(dp);
       
       s0.CustomAttributes.IsBarHorizontal = true;
       s0.CustomAttributes.BarWidth = 18;
       c.SeriesCollection.Add(s0);
       
       //Save the chart image into a memory stream.
       MemoryStream ms = new MemoryStream();
       c.Save(ms, ImageFormat.Png);

       //Save the chart image from the memory stream to the response.
       Response.Clear();
       Response.ContentType = "image/png";
       Response.OutputStream.Write(ms.ToArray(), 0, (int)ms.Length);

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Nanjing Team
    Contact Us
     
  •  06-27-2008, 8:03 AM 133445 in reply to 133444

    Re: y axis has string values

    Thank you for response but i wan't to see labels in y axis but in y axis  has integer values still. For example I wan't to see the "finance" text rather than the integer value "1"
     
  •  06-27-2008, 8:18 AM 133446 in reply to 133445

    Re: y axis has string values

    c.ChartArea.AxisX.AxisLabels.IsDataPointNameVisible = true;
    when i use the code above, ican see the text on x axis but when i use the code below ican't see the string values on y axis
    c.ChartArea.AxisY.AxisLabels.IsDataPointNameVisible = true;
     
  •  06-27-2008, 9:07 AM 133452 in reply to 133446

    Re: y axis has string values

    Hi,

    Well, my code works fine and y-axis will show the string labels. Could you post your sample code with output chart image here. We will check it soon.

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Nanjing Team
    Contact Us
     
  •  06-27-2008, 9:13 AM 133453 in reply to 133452

    Re: y axis has string values

     Chart c = new Chart();
            c.Titles.Add(new Title());
            c.Titles[0].Text = "Bar Chart";
            c.ChartArea.LegendBox.IsVisible = false;
            c.ChartArea.AxisY.IsMajorGridVisible = false;
            c.ChartArea.AxisY.AxisLabels.IsDataPointNameVisible = true;

            Series s0 = new Series();
            s0.ChartType = ChartType.;
            s0.Name = "Values";

            DataPoint dp = new DataPoint("finance", 1, 10);
            dp.IsLabelVisible = true;
            s0.DataPoints.Add(dp);

            dp = new DataPoint("energy", 2, 40);
            dp.IsLabelVisible = true;
            s0.DataPoints.Add(dp);

            dp = new DataPoint("material", 3, 20);
            dp.IsLabelVisible = true;
            s0.DataPoints.Add(dp);

            dp = new DataPoint("technology", 4, 30);
            dp.IsLabelVisible = true;
            s0.DataPoints.Add(dp);

            s0.CustomAttributes.IsBarHorizontal = true;
            s0.CustomAttributes.BarWidth = 18;
            c.SeriesCollection.Add(s0);

            //Save the chart image into a memory stream.
            MemoryStream ms = new MemoryStream();
            c.Save(ms, ImageFormat.Png);

            //Save the chart image from the memory stream to the response.
            Response.Clear();
            Response.ContentType = "image/png";
            Response.OutputStream.Write(ms.ToArray(), 0, (int)ms.Length);

    Free Image Hosting at www.ImageShack.us

    QuickPost
     
  •  06-27-2008, 9:15 AM 133455 in reply to 133452

    Re: y axis has string values

    Attachment: Present (inaccessible)

    And attached is the image when I run my code.

    And by the way which version of Aspose.Chart you are using?

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Nanjing Team
    Contact Us
     
  •  06-27-2008, 9:18 AM 133456 in reply to 133455

    Re: y axis has string values

    The aspose.chart.dll version is 3.4.7.0
     
  •  06-27-2008, 9:23 AM 133457 in reply to 133455

    Re: y axis has string values

    Attachment: Present (inaccessible)

    Could you try the attached version

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Nanjing Team
    Contact Us
     
  •  06-27-2008, 9:27 AM 133458 in reply to 133457

    Re: y axis has string values

    It work with 3.4.6
    But we use aspose total last version in our company, i hink there is a bug on the last version,when it will be fixed?
     
  •  06-27-2008, 12:46 PM 133476 in reply to 133458

    Re: y axis has string values

    Hi,

    Well, you may use this fix (3.4.6.1) as long as you wish, it will work just like our official release.

    Yes, we found the problem with the latest version 3.4.7 and will figure it out soon.

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Nanjing Team
    Contact Us
     
  •  06-30-2008, 12:07 AM 133577 in reply to 133476

    Re: y axis has string values

    Hi,

    Sorry for the inconvenience.

    Before the end of this week, we release new version to solve the bug.


    Roger Mo
    Developer
    Aspose Nanjing Team
    Contact Us
     
  •  06-30-2008, 8:51 AM 133657 in reply to 133577

    Re: y axis has string values

    Thank you for your interest.
     
View as RSS news feed in XML