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 9316773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:42:25+00:00 2026-06-19T02:42:25+00:00

I am trying to use jq plot to plot a bar graph off car

  • 0

I am trying to use jq plot to plot a bar graph off car rentals per day so – the x-axis will contain Dates and then two bars – Rented/Not Rented. I currently get this back to a List in my controller. If I set a breakpoint I can see the data is returned and at the minute there is a count of 4 in the list (the max will be 10 ever as a Take(10) is done to on my Linq query to the DB.

So I can see the below as an example of a row in my List

Date         Rented   Not Rented
18/02/2013   100      200

The javascript for jq plot is below just with hard coded values to see if it displays which it does so what I want to try and get now is the values in S1 Replaced with each of my Rented Value from my list and the values in s2 replaced with my not rented and then the Ticks replaced with the corresponding date for that row

//s1 = Rented Values
//s2 = Not Rented Values
var s1 = [200, 600, 700, 1000];
var s2 = [460, 210, 690, 820];
// Can specify a custom tick Array.
// Ticks should match up one for each y value (category) in the series.
var ticks = ['Date', 'Date', 'Date', 'Date'];

I was looking for ideally something like a Hidden For on my cshtml page that would contain the List of results and somehow get access to this in JS? is that possible?

  • 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-06-19T02:42:27+00:00Added an answer on June 19, 2026 at 2:42 am

    As always start by defining a view model:

    public class MyViewModel
    {
        public int Rented { get; set; }
        public int NotRented { get; set; }
        public DateTime Date { get; set; }
    }
    

    and then have your controller action query your backend and populate this view model:

    public ActionResult SomeAction()
    {
        IEnumerable<MyViewModel> model = ... go query your backend
        return View(model);
    }
    

    and finally in your strongly typed view:

    @model IEnumerable<MyViewModel>
    ...
    <script type="text/javascript">
        var s1 = @Html.Raw(Json.Encode(Model.Select(x => x.Rented)));
        var s2 = @Html.Raw(Json.Encode(Model.Select(x => x.NotRented)));
        var ticks = @Html.Raw(Json.Encode(Model.Select(x => x.Date.ToString("dd/MM/yyyy"))));
    
        // Now that you have the 3 arrays plot them up.
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use Flot to plot a graph with dates. I've followed the
I'm trying to use Jenkins' Plot plugin to generate a graph of how many
I am trying to use jqPlot for a bar graph and I can't get
I'm trying to use hexbin to plot some data on a square axis. I
I'm currently trying to use the core-plot library to graph some data I get
I am trying to use the Bing Maps Ajax Control to plot pins of
I am trying to use R within a script that will act as a
I am trying to use the function fortify in R to plot the map.
I am trying to plot mathematical functions and use the CoreGraphics framework. I am
I've been trying to recreate this post on a combination of stacked bar/area plot.

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.