Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7639373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:24:08+00:00 2026-05-31T08:24:08+00:00

So I was trying out the Chart helpers in the System.Web.Helpers namespace. according to

  • 0

So I was trying out the Chart helpers in the System.Web.Helpers namespace.

according to http://www.asp.net/web-pages/tutorials/data/7-displaying-data-in-a-chart

I make the chart in a .cshtml view but I wanted to keep it in the ViewModel instead.

No problem except for when I’m trying to render it as a smaller image in the website.

I thought the cleanest solution would be to create one shared partial view to render graphs from models

_graph.cshtml

@model System.Web.Helpers.Chart

@Model.Write()

And then render this partial view somehow in the proper websites. I tried a few versions but can’t seem to get it to work.

Website.cshtml

<div>
    <h2>Some header above a graph</h2>
    <img src="@Html.Partial("_graph", Model.TheChart)" />
</div>

This doesn’t work and I’m not certain how to do this. Only think I can think of now is making all models with charts inherit an Interface that exposes Chart and let that be the model for _graph.cshtml.

<img src="_graph.cshtml" />

But not sure if the this uses the Model.

Any opinions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:24:10+00:00Added an answer on May 31, 2026 at 8:24 am
    <div>
        <h2>Some header above a graph</h2>
        <img src="@Url.Action("DrawChart")" />
    </div>
    

    and then you could have a controller action:

    public ActionResult DrawChart()
    {
        MyViewModel model = ...
        return View(model);
    }
    

    and a corresponding view that will draw the chart (DrawChart.cshtml):

    @model MyViewModel
    
    @{
        // TODO: use the data from the model to draw a chart
    
        var myChart = new Chart(width: 600, height: 400)
            .AddTitle("Chart Title")
            .AddSeries(
                name: "Employee",
                xValue: new[] {  "Peter", "Andrew", "Julie", "Mary", "Dave" },
                yValues: new[] { "2", "6", "4", "5", "3" })
            .Write();
    }
    

    and the rendered result:


    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying out THIS .NET MS Chart control. Could someone who knows about
I am trying to generate a chart using the MS Chart Control in ASP.NET
I'm trying out the HighStock library for creating stock charts. To fill the chart
I am trying to figure out how to generate a colored chart on a
I've been trying to figure out how to use google chart-wrapper with my django
I'm trying to make a level-of-detail line chart, where the user can zoom in/out
Trying out the examples found on pleac.sf.net , I'm not able to get an
I am trying to build out a google chart in an mvc app. Here
i am trying to figure out how to input data values into highcharts. Firstly
I am trying to create a scatter chart on my web page with CSS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.