Note that there are some explanatory texts on larger screens.

plurals
  1. POdojox.charting.Chart dataRange not restricting the chart x axis properly
    text
    copied!<p>I am building an application that monitors the number of services running on an application server. Information about the services running will be stored on a database, and I want to display some of that information on a webpage. At this point I just want to build a graphical representation of the number of services actively running, which updates dynamically as the database is updated. The goal is to create a simple chart that displays the most recent 10 (or so) values for the number of services running, similar to what an ekg readout looks like. I am using the dojox.charting.Chart widget, but I am having trouble updating the chart properly, so that it only displays the ten most recent values for numFailedAttempts:"0". As it is right now, the chart displays all the values, and the x axis values continuously get closer and closer together to accommidate everything. Based on the dojo api reference and documentation on dojotoolkit.org, I thought that the "displayRange" attribute for the dojox.charting.Chart was supposed to solve this problem. So my question is, what am I doing wrong? Here's the code: </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/resources/dojo.css"&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js" data-dojo-config="isDebug: true, parseOnLoad: true"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; dojo.require("dojox.charting.StoreSeries"); dojo.require("dojox.charting.Chart2D"); dojo.require("dojo.store.Memory"); dojo.require("dojo.store.Observable"); dojo.require("dojox.charting.Chart"); dojo.require("dojox.charting.plot2d.Areas"); dojo.ready(function(){renderDataChart()}); function renderDataChart(){ //data from a database var dataChartData = { itentifier: 'id', items: [ {id: 1, serviceName:"service1", startDate:"today", endDate:"today", numFailedAttempts:"1", errorTime:"null", errorMessage:"null", suppressError:"null"}, {id: 2, serviceName:"service2", startDate:"today", endDate:"today", numFailedAttempts:"1", errorTime:"now", errorMessage:"broken", suppressError:"click"}, {id: 3, serviceName:"service3", startDate:"today", endDate:"today", numFailedAttempts:"0", errorTime:"now", errorMessage:"broken", suppressError:"click"}, {id: 4, serviceName:"service4", startDate:"today", endDate:"today", numFailedAttempts:"1", errorTime:"now", errorMessage:"broken", suppressError:"click"}, {id: 5, serviceName:"service5", startDate:"today", endDate:"today", numFailedAttempts:"0", errorTime:"null", errorMessage:"null", suppressError:"null"} ] }; //data store var dataChartStore = dojo.store.Observable(new dojo.store.Memory({ data: { identifier: "id", label: "runningServices", items: dataChartData } })); var dataChart = new dojox.charting.Chart("myDataChart", { displayRange: 10, stretchToFit: false, scrolling: true, fieldName: "runningServices", type: dojox.charting.plot2d.Areas }); dataChart.addAxis("x", {microTickStep: 1, minorTickStep: 1}); dataChart.addAxis("y", {vertical: true, minorTickStep: 1, natural: true}); dataChart.addSeries("y", new dojox.charting.StoreSeries(dataChartStore, {query: {numFailedAttempts: 0}}, "value")); dataChart.render(); //update datastore to simulate new data var startNumber = dataChartData.length; var interval = setInterval(function(){ dataChartStore.notify({value: Math.ceil(Math.random()*29), id: ++startNumber, numFailedAttempts: 0}); }, 1000); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="myDataChart" style="width: 500px; height: 200px;"&gt;&lt;/div&gt; &lt;/body&gt; </code></pre> <p></p>
 

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