Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Eric Herlitz 97 posts 129 karma points
    Sep 19, 2011 @ 20:43
    Eric Herlitz
    0

    MSChart not working with Umbraco 4.7?

    Hi

    Is there something one should know when using the mschart libraries with Umbraco 4.7?

    I'm used working with mschart in other projects but anyway here is what ive done so far

    Implementation in web.config...

    <configuration>
        <system.web>
            <pages>
                <controls>
                    <!-- MSChart -->
                    <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
                </controls>
            </pages>
            <httpHandlers>
                <add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
            </httpHandlers>
        </system.web>
        <system.webServer>
            <handlers>
                <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            </handlers>
        </system.webServer>
    </configuration>

    ...and registered the assemblies

    <assemblies>
        <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.DataVisualization.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </assemblies>

    Now, thats not so difficult

    Added the chart to a c# usercontrol

    <asp:Chart ID="Chart1" runat="server" Width="565" Height="300">
        <Series>
            <asp:Series Name="Series1">
            </asp:Series>
        </Series>
        <ChartAreas>
            <asp:ChartArea Name="ChartArea1">
            </asp:ChartArea>
        </ChartAreas>
    </asp:Chart>

    And for the fun of it I've added some data

    protected void Page_Load(object sender, EventArgs e)
    {
        Chart1.Series["Series1"].ChartType = SeriesChartType.Line;
     
        var q = _db.tblPROUserWeights.Where(x => x.UserId.Equals(7)).OrderBy(x => x.Week).Take(10);
     
        ChartArea chartArea1 = Chart1.ChartAreas["ChartArea1"];
        Series series1 = Chart1.Series["Series1"];
     
        chartArea1.AxisX.Interval = 1;
        chartArea1.AxisY.MajorGrid.Enabled = false;
        chartArea1.AxisX.MajorGrid.Enabled = false;
        chartArea1.BackGradientStyle = GradientStyle.TopBottom;
        chartArea1.BackColor = Color.BurlyWood;
        chartArea1.BackSecondaryColor = Color.BlanchedAlmond; 
     
        series1.XValueType = ChartValueType.Int32;
        series1.YValueType = ChartValueType.Int32;
     
        Chart1.DataSource = q;
        series1.XValueMember = "Week";
        series1.YValueMembers = "Weight";
        Chart1.DataBind();
    }

    When running this usercontrol in an external site, like an empty .NET Web Application it renders flawlessly, I'll attach an image so you can see.

    Now, what on earth could be wrong and what is Umbracos problem with MSCharting?

    Thanks

  • jaygreasley 416 posts 403 karma points
    Sep 19, 2011 @ 21:21
    jaygreasley
    0

    Hi Eric,

    You don't say what happens when you run it in Umbraco, so it's hard to say ;-)

    Does it run at all?

    j

  • Eric Herlitz 97 posts 129 karma points
    Sep 19, 2011 @ 21:31
    Eric Herlitz
    0

    true.dat

    If I put an <hr /> before the <asp:chart and a <hr /> after the closing tag both rules renders but nothing in between. Not even a trace of it!

  • Richard 146 posts 168 karma points
    Sep 21, 2011 @ 17:35
    Richard
    0

    I have not done this with Umbraco, but with another CMS. I made the notes:

    The image created needs to be written by the web server somewhere, either to a temporary directory, in which case add:

    <add key="ChartImageHandler" value="storage=file;timeout=20;dir=D:\data\Chart-Temp;"/>

    and create and make writable by the web server this directory, or use ImageLocation="~/images/chart#NOGUIDPARAM" ImageStorageMode="UseImageLocation" attributes on the ASP:Chart tag, then similarly create and make writable the ImageLocation directory.

    Richard


  • Eric Herlitz 97 posts 129 karma points
    Sep 21, 2011 @ 17:48
    Eric Herlitz
    0

    Thanks Richard, that solved my issue

    I ended up using

    <add key="ChartImageHandler" value="storage=session;timeout=20;"/>
Please Sign in or register to post replies

Write your reply to:

Draft