Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I create my as an extension method to convert my datatime to a javascript datetime. It looks like:</p> <pre><code>private static long ToJavascriptTimestamp( this DateTime input ) { TimeSpan span = new TimeSpan( new DateTime( 1970, 1, 1, 0, 0, 0 ).Ticks ); DateTime time = input.Subtract( span ); return ( long )( time.Ticks / 10000 ); } </code></pre> <p>Then I just passed it back as a Json result.</p> <p>If you want to make it a column chart then the bar width is also based on ticks so if you want it to be an hour the width would be: 60 * 60 * 1000 (ticks * seconds * min)</p> <p>Your object could be something like:</p> <pre><code>public class GraphData { public int Value {get; set;} public long Date {get; set;} } </code></pre> <p>Then just create a list of GraphData and in your controller use something like:</p> <pre><code>return Json(myGraphDataList, "application/json", Encoding.Default); </code></pre> <p>Then in your javascript on you might have some <code>$.Ajax</code> call to get the data and on the success response that where you set it like:</p> <pre><code>$.ajax({ url: "/someUrl", type: 'POST', dataType: 'json', success: function (result) { var graphData = [{ data: result.Data, lines: { show: true }, points: { radius: 3 } }]; var graphOptions = { grid: { hoverable: true, borderWidth: 1 }, yaxis: { axisLabel: "Title", axisLabelUseCanvas: true, axisLabelFontSizePixels: 12, min: 0 }, xaxis: { axisLabel: "Time", axisLabelUseCanvas: true, axisLabelFontSizePixels: 12, mode: "time", timeformat: "%H:%M", tickSize: 1000 * 60 * 60 } }; $.plot($("#tag"), data, options); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload