Forum Discussion
Deneb Matrix Visual - Working but with Warnings
- 1 year ago
Adding type to x2 is unnecessary and does nothing, as these share the same scale as x. The type in x dictates how x2 is scaled. Remove type from the channel and the warning should go away. (EDIT: example of using offset channels on a StackOverflow post from the other day that may help clarify)
bandPosition only spans from 0 to 1 and dictates percentage of the band to use for a mark's position (0.5 being the centre). Use xOffset or x2Offset if you want to adjust by a specific amount relative to encoded position.
One of the x2 sections is creating a shaded rectangle in color #004ABF where x describes the beginning x position and x2 describes the ending point to draw the rectangle:
"mark": {
"type": "rect",
"tooltip": true,
"color": "#004ABF",
"opacity": 0.5
},
"encoding": {
"x": {
"field": "MBRPVCTable",
"type": "nominal",
"bandPosition": -2 //WARNING: Value is below the minimum of 0.
},
"x2": {
"field": "MBRPVCTable", //WARNING: Property field is not allowed.
"type": "nominal",
"bandPosition": 3 //WARNING: Value is above the maximum of 1.
The other x2 sections where I have warnings are creating two different horizontal lines at specific points in the table. The below code section does the horizontal line that shows above 'Cost' in my sample image and "x" is the starting x position whereas "x2" is the ending position for the line/stroke.
"transform": [
{"filter": "datum.MBRPVCTable === 'COR'"}
],
"mark": {
"type": "rule",
"tooltip": true,
"strokeWidth": 1,
"color": "black"
},
"encoding": {
"x": {
"field": "MBRPVCTable",
"type": "nominal",
"bandPosition": 0
},
"x2": {
"field": "MBRPVCTable", //WARNING: Property field is not allowed.
"type": "nominal",
"bandPosition": 5 //WARNING: Value is above the maximum of 1.
},
"y": {
"value": -35 // Position the top horizontal line
},
"y2": {
"value": -35 // Ensure the line is horizontal
The code below here is the 2nd horizontal line that shows at the bottom of the visual in my sample picture.
"transform": [
{"filter": "datum.MBRPVCTable === 'Other'"}
],
"mark": {
"type": "rule",
"tooltip": true,
"strokeWidth": 1,
"color": "black"
},
"encoding": {
"x": {
"field": "MBRPVCTable",
"type": "nominal",
"bandPosition": -4 //WARNING: Value is below the minimum of 0.
},
"x2": {
"field": "MBRPVCTable", //WARNING: Property field is not allowed.
"type": "nominal",
"bandPosition": 1
},
"y": {
"value": {"expr": "height"} // Position the bottom horizontal line
},
"y2": {
"value": {"expr": "height"} // Ensure the line is horizontalI guess the line has the same x for both horizontal lines, I'm just using a different starting point and hence why one has a negative bandPosition of -4 going to 1 whereas the other goes from 0 to 5. Again, I am brand new to Deneb, so the different starting points for the lines comes from Copilot, but it worked so I didn't analyze and question why to not use the same starting x position 'COR'.