Closed jo-tham closed 8 years ago
I think the attributes of interest are defined in capabilities
https://github.com/Microsoft/PowerBI-visuals-docs/blob/master/Capabilities/Capabilities.md
dataRoles
is an array of dataViewRole objects which define fields (mapped
variables) that can be bound to data (columns)
"dataRoles": [
{
"displayName": "My Category Data",
"name": "myCategory",
"kind": 0
},
{
"displayName": "My Measure Data",
"name": "myMeasure",
"kind": 1
}
]
the data roles in the current LeafletMap are
dataRoles: [
{
name: "Category",
kind: VisualDataRoleKind.Grouping,
displayName: "Custom Geography"
},
//{
// name: "Description",
// kind: VisualDataRoleKind.Grouping,
// displayName: "Description"
//},
{
name: "Value",
kind: VisualDataRoleKind.Measure
}
],
on one hand, maybe i want the attributes like lat/long, occupancy status, etc
perhaps this leaflet powerbi base is relying on something else for the spatial attributes, i.e. WKT format
would that be a field in the data? if so, why not given an entry in dataRoles?
Another thing worth checking is the default powerBI visuals source here's the map source, and here are the capabilities. A good reference, but not immediately useful afaict. Quite involved…
coming back to getting the data on the map … the geometry is in fact a field in the data. I'm not sure why it's not given an entry in dataRoles.
var data = dataView.table.rows;
var dataPoints: GeoDatapoint[] = [];
for (var i in data) {
//console.log('initial WKT: ' + data[i]);
//console.log(data[i][0].substr(0, 3));
var wktTypeCheck = data[i][0].substr(0, 3);
switch (wktTypeCheck) {
case "POI":
//console.log('type check = point');
var pointData = parsePoint(data[i][0]);
dataPoints.push({
geoType: "POINT",
geoData: pointData,
//description: "Test",
dataValue: data[i][1],
lng: pointData.lng,
lat: pointData.lat
});
break;
case "LIN":
//console.log('type check = linestring');
var lineData = parseLineString(data[i][0]);
dataPoints.push({
geoType: "LINESTRING",
geoData: lineData,
//description: "",
dataValue: data[i][1],
lng: 0,
lat: 0
});
break;
case "POL":
//console.log('type check = polygon');
var polygonData = parseLineString(data[i][0]);
dataPoints.push({
geoType: "POLYGON",
geoData: polygonData,
//description: "",
dataValue: data[i][1],
lng: 0,
lat: 0
});
break;
}
}
//console.log(dataPoints);
return dataPoints;
so it looks like we need to parse the data and put spatial aspect into GeoDataPoints
the cartodata is given from dataView
var cartoData = LeafletMap.converter(this.dataView);
so it seems that the first data role, custom geography, is in fact WKT format geography
if i just took lat long and parsed them into the geodatapoint interface, that may be a sufficient modification to get the test data mapped. how to do this?
note that data which is parsed into geodatapoints is an array of arrays, for
example as [[60.1, 80, 'a'], [60, 80.1, 'b'] ]
. the first element is parsed
for WKT format geometic identifier. the second element is parsed as the value.
if i created some fake data with WKT format it should plot. or, again, parse the desired data from the dataview columns/roles. former is easy, latter sounds more correct.
coming back to dataroles, it may fix it to define them better and use the lat long roles as the points for the geodatapoint type. have another role for damange amount, and a panel for customizing its colors. and another role for tooltip which identifies fields that should be used in the onclick table.
the existing leaflet map is not very good example for this, and a closer look at the powerbi default visuals map source will didn't make an approach obvious either…
well, since dataView is the view on the data defined by the roles and selected fields, it should be pretty straight forward to change the capabilities/roles and get the coordinates from the dataview and parse them from there into the geodatapoint.
the dataviewmappings are somewhat confusing
https://github.com/Microsoft/PowerBI-visuals-docs/blob/master/Capabilities/DataViewMappings.md
it's probably best to go off of https://github.com/Microsoft/PowerBI-visuals/blob/master/src/Clients/Visuals/capabilities/map.capabilities.ts
for clarity in case someone picks this up while I'm away - the next thing to to is define capabilities
including data roles
and a dataview mapping
that allow us to identify lat, long, and a categorical variable by which to color the location markers.
https://github.com/Microsoft/PowerBI-visuals-docs/blob/master/Capabilities/Capabilities.md
the capabilities are define at https://github.com/woodbuffalo/powerbi-leaflet/blob/%233/display-data/src/visual.ts#L236
after that, the PointParser should be updated to pull lat and long off of the dataview. the categorical variable also probably needs to be extracted from the dataview here.
that should be enough to get the point locations on the leaflet base maps.
don't forget to follow the setup described in the readme, and here is some test data to use with powerbi: test_data.txt
That fixes up the data roles so that the proper roles are in the field editor
and so that the chart is customizable
but for some reason this has broken the visualization, though no errors are being raised AFAICT
anyway, @whyvez heads up that the data roles are almost working. need to fix the regression with the visualization and then parse the data from the dataview into the geodata points interface.
can't add the fields to the visualization
removing conditions from the dataview allows me to add them, but they all go under style as shown below
Data is not rendering
identify what's going on here and resolve it so that point data renders on map