Partially colored report service cells

How can I create a partially colored cell in a report services table or in a matrix? For example: hava value 45 & I want to fill only 45% of the cell with red, and the remaining 55% remain white?

+3
source share
1 answer

The only way to see that the job is to have a background image full of x% red for each percentage group you want to show. Then you can set the expression to fill the background with the correct image depending on the value of a particular field.

Not exactly the best solution, since you will need 20 images to get 5% of the ranges.

- webservice/asp.net, . aspx. , asp.net

, .

 protected void Page_Load(object sender, EventArgs e)
    {
        int percent = 0;
        int height = 20;

        if (Request.QueryString.AllKeys.Contains("percent"))
        {
            int.TryParse(Request.QueryString["percent"], out percent);
        }

        if (Request.QueryString.AllKeys.Contains("height"))
        {
            int.TryParse(Request.QueryString["height"], out height);
        }

        Bitmap respBitmap = new Bitmap(100, height, PixelFormat.Format32bppRgb);
        Graphics graphics = Graphics.FromImage(respBitmap);
        Brush brsh = new SolidBrush(Color.White);
        graphics.FillRectangle(brsh, new Rectangle(0, 0, respBitmap.Width, respBitmap.Height));

        brsh = new SolidBrush(Color.Red);
        graphics.FillRectangle(brsh, new Rectangle(0, 0, respBitmap.Width * percent / 100, respBitmap.Height));

        Response.ContentType = "image/jpeg";
        Response.Charset = "";
        respBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);

    }

, BackGroundImage . ,

= "http://mysite/chartimage.aspx?percentage=" & Fields!MyField.Value
+3

Source: https://habr.com/ru/post/1777750/


All Articles