vega not plotting the data - kibana

I am brand new to Vega and I was trying to plot some charts on Vega (plugin ElasticSearch and Kibana). Below is the simple visulization I am trying to plot. I am following through the documentation to connect the existing data, however I am unable to get the visuals. It just shows Y and X axis labeled from the code below with blank plots. What am I doing wrong?
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json"
"data": {
url: {
%context%: true
index: test-data
}
format: {property: "hits.hits"}
},
"mark": {"type":"bar"}
"encoding": {
"x": {"field": "DEPT", "type": "ordinal"},
"y": {"field": "SALES", "type": "quantitative"}
}
}

The specification needs to be valid JSON. There are numerous things in your specification that make it invalid; for example:
all strings need to be enclosed in quotes (e.g. url and format)
all items need to be separated by commas (applies to nearly every line of your specification)
Finally, even if you change those syntax errors, the content of your specification doesn't follow the schema: for example, the "url" and the "format" properties of "data" both should be strings.
I would suggest beginning with the vega-lite tutorials, and go from there, modifying what you learn to work with your own data.

Related

Grafana: a line graph without date-time on x-axis

This is probably more complicated as it sounds, at least with Grafana.
I have an experiment, where for every location (1-100) a value is changed over time. I want to show this with a line graph (or a bar graph), where x-axis correspond to the locations (1-100) and y-axis correspond to the average value for this location for the time interval that is set in Grafana in the upper right corner. Data comes from database. Please, suggest me, which type of graph (dashboard) should I choose in Grafana to achieve the goal. I can only see two kinds of them, those with time on x-axis and those of type histogram but none seems to be applicable.
seems Grafana builtin panels only support
time series, which mean x-axis must be 'time' type.
bilibala-echarts-panel
I use this third-part panel bilibala-echarts-panel
https://grafana.com/grafana/plugins/bilibala-echarts-panel/
achieved the goal: x-axis not use time value.
It can use a custom callback function, to handle data and render
setting
in grafana query setting:
format as time series
// time series need 3 column:
time // time or number (can be parse as time)
metric // string: series name
value // number (otherwise got value error)
assign the value to time column.
// it may rander as 1970-01 in table view, but in echart we can read it as number
in echart panel option:
 data.series got the grafana data
 // convert/adapte it to echart data here.
maybe format as table can have more flexible data,
 and parse them in the callback js.
summary
grafana and echart have different theory,
 have to understand both of them ,
 and do the convert in js.
// bilibala-echarts-panel using echart v4 #2022-07
We have implemented the graph using natel-plotly-panel plugin.
"panels": [
{
"pconfig": {
"traces": [
{
"mapping": {
"color": "64",
"size": null,
"text": "metriccat",
"x": "loccat",
"y": "valuecat",
"z": null
},
"name": "My value",
"show": {
"line": true,
"lines": true,
"markers": false
}
},
...
]
},
"pluginVersion": "7.5.5",
"targets": [
{
"format": "table",
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT\n avg(column_with_values) AS valuecat,\n loc loccat,\n avg(column_with_values) as metriccat\nFROM ... \nWHERE\n $__timeFilter(timestamp)\nGROUP BY loc\n\n",
"select": [
[
{
"params": [
"value"
],
"type": "column"
}
]
],
"timeColumn": "time",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
},
...
],
"title": "Average Values Along the Locations",
"type": "natel-plotly-panel",
"version": 1
}
]

Google Schema.org Math solvers structured data for multiple fields

Trying to setup schema markup for a simple math solver action with two fields. Let's say addition.
1+1=2
Here is Google's doc and example:
{
"#context": "https://schema.org",
"#type": ["MathSolver", "LearningResource"],
"name": "An awesome math solver",
"url": "https://www.mathdomain.com/",
"usageInfo": "https://www.mathdomain.com/privacy",
"inLanguage": "en",
"potentialAction": [{
"#type": "SolveMathAction",
"target": "https://mathdomain.com/solve?q={math_expression_string}",
"mathExpression-input": "required name=math_expression_string",
"eduQuestionType": ["Polynomial Equation","Derivative"]
}],
"learningResourceType": "Math solver"
}
How do we add multiple variables for two numbers?
return {
'#context': 'https://schema.org',
'#type': ['MathSolver', 'LearningResource'],
...
potentialAction: [
{
'#type': 'SolveMathAction',
target: `domain.com/?num1={num1}&num2={num2}`,
'mathExpression-input': 'required name=num1 name=num2',
eduQuestionType: ['addition', 'sum']
},
],
learningResourceType: 'Math solver'
};
Schema.org says about mathExpression (note: mathExpression-input doesnt seem to exist) but does fall under Thing > Intangible EntryPoint
A mathematical expression (e.g. 'x^2-3x=0') that may be solved for > a specific variable, simplified, or transformed. This can take many > formats, e.g. LaTeX, Ascii-Math, or math as you would write with a > keyboard.
But can this be setup for URL params to accept multiple fields within the mathExpression-input instead of a single math expression?

Swagger with swag gem - response of an array of multiple complex types

Swagger docs say that we can use a complex type object specified as array type as follows:
"type": "array",
"items": {
"$ref": "#/components/schemas/VeryComplexType"
}
But what if you have an array of different complex types (e.g. country, address, etc.) ? When trying to pass multiple $ref as follows:
"type": "array",
"items": {
"$ref": "#/components/schemas/VeryComplexType-1"
"$ref": "#/components/schemas/VeryComplexType-2"
"$ref": "#/components/schemas/VeryComplexType-3"
}
raises an error:
warning: key :$ref is duplicated and overwritten on line 245
warning: key :$ref is duplicated and overwritten on line 246
and it keeps the last one only. How is ti possible to fix that (if it is) ?
Thank you.
It is available starting from Open API 3.0 and it was discussed at this issue.
As rswag supports Swagger 2.0 only, it is not possible.

Vega / Kibana Custom Visualization with multiple X axis parameters

I'm trying to archieve something like this :
example, using kibana and/or Vega/Vega-lite.
The csv file I used to add the index to kibana was:
student1,90,80,85,95
student2,50,60,55,100
student3,40,70,50,60
At the moment I have this:
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"data": {
"url": {
%context%: true,
"index":"grades",
"body":{
"size":5
"_source":["StudentName","test1","test2","test3","test4"]
}
},
"format":{"property":"hits.hits"}
},
"mark": "line",
"encoding": {
"x": {"field": "_source.test1", "type": "quantitative"},
"y": {"field": "_source.StudentName", "type": "nominal"}
}
}
So my problem is trying to archieve what is on the picture. I know the "encoding" section of my Vega code isn't correct but I'm having problem finding a way of having multiple parameters in X-axis.
I think this : vega example
would do the trick if i managed to replace the hardcoded values in data with the data from the kibana index. Is there any way I can use the "_source.fields" inside the "values" or is any option in encoding that I can use in order to archieve my result?
Thanks in advance.
Note: My end result most likely only have 1 student. But I want that the visualization to be updated in real-time, therefore the need to use the field.
You posed your question here and answers have been posted - https://github.com/vega/vega/issues/1229#issuecomment-379593878

"Reverse formatting" Riak search results

Let's say I have an object in the test bucket in my Riak installation with the following structure:
{
"animals": {
"dog": "woof",
"cat: "miaow",
"cow": "moo"
}
}
When performing a search request for this object, the structure of the search results is as follows:
{
"responseHeader": {
"status": 0,
"QTime": 3,
"params": {
"q": "animals_cow:moo",
"q.op": "or",
"filter":"",
"wt": "json"
}
},
"response": {
"numFound": 1,
"start": 0,
"maxScore": "0.353553",
"docs": [
{
"id": "test",
"index": "test",
"fields": {
"animals_cat": "miaow",
"animals_cow": "moo",
"animals_dog": "woof"
},
"props": {}
}
]
}
}
As you can see, the way the object is stored, the cat, cow and dog keys are nested within animals. However, when the search results come back, none of the keys are nested, and are simply separated by _.
My question is this: Is there any way provided by Riak to "reverse format" the search, and return the fields of the object in the correct (nested) format? This becomes a problem when storing and returning user data that might possibly contain _.
I do see that the latest version of Riak (beta release) provides a search schema, but I can't seem to see whether my question would be answered by this.
What you receive back in the search result is what the object looked like after passing through the json analyzer. If you need the data formatted differently, you can use a custom analyzer. However, this will only affect newly put data.
For existing data, you can use the id field and issue a get request for the original object, or use the solr query as input to a MapReduce job.

Resources