- Download
bixel.jsor install with bower
- Create html file (index.html)
- Attach bixel.js as script or through require.js
- add event handlers (
loading,load,no-data, etc) - execute
bixel.init()with options described below
- include
<script src="https://cdn.jsdelivr.net/gh/luxms/bixel@master/bixel.js"></script>in your html file
- run
bower install git://github.com/luxms/bixel - include
<script src="bower_components/bixel/bixel.js"></script>in your html file
TODO
bixel.init({optional config})
Must execute this function when frame is ready to receive message
Config (optional):
locationsCount: string- number of requested locationsmetricsCount: string- number of requested metricsperiodsCount: string- number of requested periodsxsCount: stringnumber of entities of x-axis (e.g. periods, locations, metrics - one projected on x-axis)ysCount: stringnumber of entities of y-axiszsCount: stringnumber of entities of z-axissaveAbilities: string[]- array of file extensions that vizel can be saved to
If none expliced then all selected will be provided
bixel.init returns promise object to ensure that everything is working
bixel.init({periodsCount:1})
.then(function() {
// succeeded
}, function() {
// error
});subscribe on event (receive event from client)
bixel.on(eventName, callbackFunction)
eventName is string and can be one of:
loading- will receive this event when data is loading. A callback will haveAxisobject as the only argumentload- will receive this event when data is loading. A callback will haveDataandAxisobject as two argumentsno-data- will receive this event when the data is empty if either there is no selection in ui panes or no data on server side. A callback will haveAxisobject as the only argumentsave- when user click on save buttonurl- will receive this event when url changed. It provides callback argument as current model of UrlState service
trigger the event manually (send event to client).
Available keys for event:
LOAD- default event for receiving dataLOADING- event for loading state of dashletNO_DATA- event for state of no data from serverLOAD_DATA- get raw data from serverCLICK_DATA_POINT- click on data point
Examples:
bixel.invoke('LOAD_DATA', {
metrics: [34, 56, 61],
locations: [19001],
periods: [202001010000004]
}).then(function(data) {
console.log(data);
}
$(document).on('click', '[data-yId]', function(event){
bixel.invoke('CLICK_DATA_POINT', { x_id: X.id, y_id: event.target.getAttribute('data-yId'), z_id: Z.id, event: {pageX: event.pageX, pageY: event.pageY } });
});
provides methods:
-
axis.getMetrics()- returns javascript array ofMetricobjects. This array will be maximum ofmetricsCountlength if specified inbixel.initmethod -
axis.getLocations()- returns javascript array ofLocationobjects. This array will be maximum oflocationsCountlength if specified inbixel.initmethod -
axis.getPeriods()- returns javascript array ofPeriodobjects. This array will be maximum ofperiodsCountlength if specified inbixel.initmethod -
axis.getUnits()returns javascript array ofUnitobjects. It will contain all the units linked with metrics -
axis.getXs()- returns javascript array of entities of x-axis. This array will be maximum ofxsCountlength if specified inbixel.initmethod -
axis.getYs()- returns javascript array of entities of y-axis. This array will be maximum ofysCountlength if specified inbixel.initmethod -
axis.getZs()- returns javascript array of entities of z-axis. This array will be maximum ofzsCountlength if specified inbixel.initmethod
provides methods:
data.getValue(z, y, x)- returnsDataItemobject. Argumentsz,yandxareMetric,LocationandPeriodobjects from Axis in any order (or elements of zs, ys, xs).
Generally a javascript Number object with overridden toString method.
toString will return formatted value according to measure unit.
example:
bixel.on('load', function(data, axis) {
var metric = axis.getMetrics()[0]; // only the first metric of provided
var location = axis.getLocations()[0]; // and first location
var period = axis.getPeriods()[0]; // and first period
var x = axis.getXs()[0]; // first element of X axis
var y = axis.getYs()[0]; // and first element of Y axis
var z = axis.getZs()[0]; // and first element on Z axis (can be undefined)
var dataValue = data.getValue(metric, location, period);
// dataValue = data.getValue(z, y, x)
var numValue = dataValue.valueOf(); // ex: number, 1000000
var strValue = dataValue.toString() // ex: string, '$ 1 000 000 us dollars'
});javascript object, has fields:
id:string - unique id of metrictitle:string - title of metriccolor:string - color for this metric according to dash configurationunit_id: string - the id of unit linked to the metric
javascript object, has fields:
id:string - unique id of locationtitle:string - title of locationcolor:string - color for this location according to dash configuration
javascript object, has fields:
id:string - unique id of periodtitle:string - title of periodcolor:string - color for this period according to dash configuration
javascript object of IEntity type, has fields:
id:string - unique id of entitytitle:string - title of entitycolor:string - color for this entity according to dash configurationaxisId?: string - id of elements on axis ("measures", "locations", "age" (some dimension id));ids?: Array<string | number> - array of ids of elements on axis ;titles?: string[] - array of titles of elements on axis ;axisIds?: string[] - array of axisIds of elements on axis ;config?: any - usual js object to hold any info you might need;