.NET Framework Developer Center > .NET Development Forums > Chart Controls for .NET Framework > How can I change the resolution of the rendered chart? (using the ASP.net controls)
Ask a questionAsk a question
 

AnswerHow can I change the resolution of the rendered chart? (using the ASP.net controls)

  • Tuesday, November 03, 2009 11:04 PMDavid Seng Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I was looking through the objects with reflector and it appears that it is hardcoded at 96dpi. I was thinking about decompiling the library and adding the attribute as a property on the chart control. I just wanted to check to see if maybe there was a less intrusive method.

Answers

  • Wednesday, November 04, 2009 11:58 AMDhruv Patel Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    There are two ways for changing your chart's resolution, but both will be through code:

    1) Your Chart resolution is definable in Pixels :

    for this you need to write like :
    SemeChart.Height = IntegralHeight; // Only integers allowed for assigning height here
    SemeChart.Width = IntegralWidth; // Only integers allowed for assigning width here

    2) If you need to make your chart flexible in all resolutions, you need to go for this option.

    You will need to store the chart image and then you can change image's resolution in form : pixel/percentage.

    // Your code for preparing chart here
    
    SomeChart.SaveImage(ImageUrl);
    
    SomeImageControl.ImageUrl=ImageUrl;
    
    SomeImageControl.Height = "HeightInPercentage";
    SomeImageControl.Width = "WidthInPercentage";

    Dhruv Patel
    [ Email : mail2dhruv@rocketmail.com ]
    Please Mark As Answer if you think the answer was correct.

All Replies

  • Wednesday, November 04, 2009 11:58 AMDhruv Patel Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    There are two ways for changing your chart's resolution, but both will be through code:

    1) Your Chart resolution is definable in Pixels :

    for this you need to write like :
    SemeChart.Height = IntegralHeight; // Only integers allowed for assigning height here
    SemeChart.Width = IntegralWidth; // Only integers allowed for assigning width here

    2) If you need to make your chart flexible in all resolutions, you need to go for this option.

    You will need to store the chart image and then you can change image's resolution in form : pixel/percentage.

    // Your code for preparing chart here
    
    SomeChart.SaveImage(ImageUrl);
    
    SomeImageControl.ImageUrl=ImageUrl;
    
    SomeImageControl.Height = "HeightInPercentage";
    SomeImageControl.Width = "WidthInPercentage";

    Dhruv Patel
    [ Email : mail2dhruv@rocketmail.com ]
    Please Mark As Answer if you think the answer was correct.
  • Wednesday, November 04, 2009 9:11 PMDavid Seng Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    To clarify, are you saying make an image that is really large and then just scale it down to the desired size by setting the image's width and height attributes? I don't think this will look very nice.
  • Thursday, November 05, 2009 9:56 AMDhruv Patel Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    What I suggested is the path you can decide to walk on.

    But, if you are sure your image is looking choppy, you can also give an option to see it in full resolution - on which you can set your image to actual resolution.
    Dhruv Patel
    [ Email : mail2dhruv@rocketmail.com ]
    Please Mark As Answer if you think the answer was correct.