Extension to the 2D chart that connects to a data store in a simple manner. Convenience methods have been added for connecting store item labels to the chart labels.
This code should be considered very experimental and the APIs subject to change. This is currently an alpha version and will need some testing and review.
The main reason for this extension is to create animated charts, generally available with scroll=true, and a property field that gets continually updated. The previous property settings are kept in memory and displayed until scrolled off the chart.
Although great effort was made to maintain the integrity of the current charting APIs, some things have been added or modified in order to get the store to connect and also to get the data to scroll/animate. "displayRange" in particular is used to force the xaxis to a specific size and keep the chart from stretching or squashing to fit the data.
Currently, plot lines can only be set at initialization. Setting a new store query will have no effect (although using setStore may work but its untested).
Parameter | Type | Description |
---|---|---|
node | DomNode | The node to attach the chart to. |
kwArgs | Object |
|
See the dojox/charting/DataChart reference documentation for more information.
var chart = new dojox.charting.DataChart("myNode", { displayRange:8, store:dataStore, query:{symbol:"*"}, fieldName:"price" type: dojox.charting.plot2d.Columns });
The theme to style the chart. Defaults to PlotKit.blue.
If false, all items are each their own series. If true, the items are combined into one series so that their charted properties can be compared.
The name field of the store item DO NOT SET: Set from store.labelAttribute
Whether live data updates and changes display, like columns moving up and down, or whether it scrolls to the left as data is added
Whether the chart is showing (default) on initialization or hidden.
If true, chart is sized to data. If false, chart is a fixed size. Note, is overridden by displayRange. TODO: Stretch for the y-axis?
Parameter | Type | Description |
---|---|---|
plotName | undefined | |
verticalAxis | Boolean |
Parameter | Type | Description |
---|---|---|
dim | undefined | |
offsets | undefined |
Parameter | Type | Description |
---|---|---|
dim | undefined | |
offsets | undefined | |
w | undefined | |
h | undefined |
Add an axis to the chart, for rendering.
Parameter | Type | Description |
---|---|---|
name | String | The name of the axis. |
kwArgs | Object |
Optional An optional keyword arguments object for use in defining details of an axis. |
A reference to the current chart for functional chaining.
Add a new plot to the chart, defined by name and using the optional keyword arguments object. Note that dojox.charting assumes the main plot to be called "default"; if you do not have a plot called "default" and attempt to add data series to the chart without specifying the plot to be rendered on, you WILL get errors.
Parameter | Type | Description |
---|---|---|
name | String | The name of the plot to be added to the chart. If you only plan on using one plot, call it "default". |
kwArgs | dojox.charting.plot2d.__PlotCtorArgs | An object with optional parameters for the plot in question. |
A reference to the current chart for functional chaining.
Add a data series to the chart for rendering.
Parameter | Type | Description |
---|---|---|
name | String | The name of the data series to be plotted. |
data | Array | Object | The array of data points (either numbers or objects) that represents the data to be drawn. Or it can be an object. In the latter case, it should have a property "data" (an array), destroy(), and setSeriesObject(). |
kwArgs | Object |
Optional An optional keyword arguments object that will be mixed into the resultant series object. |
A reference to the current chart for functional chaining.
Calculate the geometry of the chart based on the defined axes of a chart.
A reference to the current chart for functional chaining.
A convenience method to connect a function to a plot.
Parameter | Type | Description |
---|---|---|
name | String | The name of the plot as defined by addPlot. |
object | Object | The object to be connected. |
method | Function | The function to be executed. |
A handle to the connection, as defined by dojo.connect (see dojo.connect).
Convenience method to convert a label array of strings into an array of objects
Parameter | Type | Description |
---|---|---|
axis | undefined |
Delayed render, which is used to collect multiple updates within a delayInMs time window.
A reference to the current chart for functional chaining.
Fetches initial data. Subsequent changes are received via onSet in data store.
Fires a synthetic event for a series item.
Parameter | Type | Description |
---|---|---|
seriesName | String | Series name. |
eventName | String | Event name to simulate: onmouseover, onmouseout, onclick. |
index | Number | Valid data value index for the event. |
A reference to the current chart for functional chaining.
Parameter | Type | Description |
---|---|---|
element | undefined | |
label | undefined | |
labelType | undefined |
Calculate the full geometry of the chart. This includes passing over all major elements of a chart (plots, axes, series, container) in order to ensure proper rendering.
A reference to the current chart for functional chaining.
Force a full rendering of the chart, including full resets on the chart itself. You should not call this method directly unless absolutely necessary.
A reference to the current chart for functional chaining.
Get the given axis, by name.
Parameter | Type | Description |
---|---|---|
name | String | The name the axis was defined by. |
The axis as stored in the chart's axis map.
Get the coordinates and dimensions of the containing DOMNode, as returned by dojo.coords.
The resulting coordinates of the chart. See dojo.coords for details.
Returns a map of information about all axes in a chart and what they represent in terms of scaling (see dojox.charting.axis2d.Default.getScaler).
An map of geometry objects, a one-to-one mapping of axes.
Get the given plot, by name.
Parameter | Type | Description |
---|---|---|
name | String | The name the plot was defined by. |
The plot.
Returns an array of plot names in the current order (the top-most plot is the first).
The main use of this function is to determine between a single value and an array of values. Other property types included for convenience.
Parameter | Type | Description |
---|---|---|
item | storeObject | |
prop | undefined |
Get the given series, by name.
Parameter | Type | Description |
---|---|---|
name | String | The name the series was defined by. |
The series.
Returns an array of series names in the current order (the top-most series is the first) within a plot.
Parameter | Type | Description |
---|---|---|
plotName | String | Plot's name. |
If chart is showing, hide it Prevents rendering while hidden
Moves a given plot to back.
Parameter | Type | Description |
---|---|---|
name | String | Plot's name to move. |
A reference to the current chart for functional chaining.
Moves a given plot to front.
Parameter | Type | Description |
---|---|---|
name | String | Plot's name to move. |
A reference to the current chart for functional chaining.
Moves a given series to back of a plot.
Parameter | Type | Description |
---|---|---|
name | String | Series' name to move. |
A reference to the current chart for functional chaining.
Moves a given series to front of a plot.
Parameter | Type | Description |
---|---|---|
name | String | Series' name to move. |
A reference to the current chart for functional chaining.
Remove the axis that was defined using name.
Parameter | Type | Description |
---|---|---|
name | String | The axis name, as defined in addAxis. |
A reference to the current chart for functional chaining.
Remove the plot defined using name from the chart's plot stack.
Parameter | Type | Description |
---|---|---|
name | String | The name of the plot as defined using addPlot. |
A reference to the current chart for functional chaining.
Remove the series defined by name from the chart.
Parameter | Type | Description |
---|---|---|
name | String | The name of the series as defined by addSeries. |
A reference to the current chart for functional chaining.
Render the chart according to the current information defined. This should be the last call made when defining/creating a chart, or if data within the chart has been changed.
A reference to the current chart for functional chaining.
Resize the chart to the dimensions of width and height.
Resize the chart and its surface to the width and height dimensions. If a single argument of the form {w: value1, h: value2} is provided take that argument as the dimensions to use. Finally if no argument is provided, resize the surface to the marginBox of the chart.
Parameter | Type | Description |
---|---|---|
width | Number | Object |
Optional The new width of the chart or the box definition. |
height | Number |
Optional The new height of the chart. |
A reference to the current chart for functional chaining.
Call this function to change the chart size. Can be connected to a layout widget that calls resize.
Parameter | Type | Description |
---|---|---|
dim | Object |
Convenience method that sets series labels based on item labels.
Parameter | Type | Description |
---|---|---|
val | Number |
Zooms an axis and all dependent plots. Can be used to zoom in 1D.
Parameter | Type | Description |
---|---|---|
name | String | The name of the axis as defined by addAxis. |
scale | Number | The scale on the target axis. |
offset | Number | Any offest, as measured by axis tick |
zoom | Boolean | Object |
Optional The chart zooming animation trigger. This is null by default, e.g. {duration: 1200}, or just set true. |
A reference to the current chart for functional chaining.
Sets new order of plots. newOrder cannot add or remove plots. Wrong names, or dups are ignored.
Parameter | Type | Description |
---|---|---|
newOrder | Array | Array of plot names compatible with getPlotOrder(). |
A reference to the current chart for functional chaining.
Sets new order of series within a plot. newOrder cannot add or remove series. Wrong names, or dups are ignored.
Parameter | Type | Description |
---|---|---|
newOrder | Array | Array of series names compatible with getPlotOrder(). All series should belong to the same plot. |
A reference to the current chart for functional chaining.
Sets the chart store and query then does the first fetch and connects to subsequent changes.
Parameter | Type | Description |
---|---|---|
store | Object | |
query | ? String | |
fieldName | ? String | |
queryOptions | ? Object |
Set a theme of the chart.
Parameter | Type | Description |
---|---|---|
theme | dojox/charting/SimpleTheme | The theme to be used for visual rendering. |
A reference to the current chart for functional chaining.
Zooms in or out any plots in two dimensions.
Parameter | Type | Description |
---|---|---|
sx | Number | The scale for the x axis. |
sy | Number | The scale for the y axis. |
dx | Number | The pixel offset on the x axis. |
dy | Number | The pixel offset on the y axis. |
zoom | Boolean | Object |
Optional The chart zooming animation trigger. This is null by default, e.g. {duration: 1200}, or just set true. |
A reference to the current chart for functional chaining.
Update the given series with a new set of data points.
Parameter | Type | Description |
---|---|---|
name | String | The name of the series as defined in addSeries. |
data | Array | Object | The array of data points (either numbers or objects) that represents the data to be drawn. Or it can be an object. In the latter case, it should have a property "data" (an array), destroy(), and setSeriesObject(). |
offsets | Boolean |
Optional If true recomputes the offsets of the chart based on the new data. This is useful if the range of data is drastically changing and offsets need to be recomputed. |
A reference to the current chart for functional chaining.
Zoom the chart to a specific range on one axis. This calls render() directly as a convenience method.
Parameter | Type | Description |
---|---|---|
name | String | The name of the axis as defined by addAxis. |
range | Array | The end points of the zoom range, measured in axis ticks. |
delayed | undefined |
Called after a completed fetch or when store items change. On first run, sets the chart data, then updates chart and legends.
Parameter | Type | Description |
---|---|---|
items | Array |
var chart = new dojox.charting.DataChart("myNode", { displayRange:8, store:dataStore, query:{symbol:"*"}, fieldName:"price" type: dojox.charting.plot2d.Columns });
stub. Fires after data is received but before data is parsed and rendered
Parameter | Type | Description |
---|---|---|
items | Array |
var chart = new dojox.charting.DataChart("myNode", { displayRange:8, store:dataStore, query:{symbol:"*"}, fieldName:"price" type: dojox.charting.plot2d.Columns });
Parameter | Type | Description |
---|---|---|
err | Error |
var chart = new dojox.charting.DataChart("myNode", { displayRange:8, store:dataStore, query:{symbol:"*"}, fieldName:"price" type: dojox.charting.plot2d.Columns });
Fired when a store item changes. Collects the item calls and when done (after 200ms), sends item array to onData().
Parameter | Type | Description |
---|---|---|
item | storeObject |
var chart = new dojox.charting.DataChart("myNode", { displayRange:8, store:dataStore, query:{symbol:"*"}, fieldName:"price" type: dojox.charting.plot2d.Columns });