Use a different legend to dimension on VizFrame Chart - sapui5

I would like to show a concatenation fields as axis labels on a chart, is this possible?
So, for the given data:
{d: [ {
"Category": "Vendor",
"BusinessProcess": "Create Manufacture's Part",
"Scenario": "Create Vendor - General Data",
"Role": "General",
"Average_Duration_Days": 43,
"Row_ID": "4"
},
{
"Category": "Vendor",
"BusinessProcess": "Create Vendor - General Data",
"Scenario": "Create Vendor - General Data",
"Role": "General",
"Average_Duration_Days": 38,
"Row_ID": "5"
}
I would like to use Average_Duration_Days as the measure. I would also like to show both rows and the for the label for the row show something like BusinessProcess + Role.
Is it possible to use Row_ID as the dimension and then a concatenation of the other fields as the axis label?
Here's a simple code bin:
http://jsbin.com/yifejik/edit?js,output

You can use the attribute 'value' as the selector for your Bars and 'displayValue' as the label. I used a formatter to combine two values.
See jsbin:
http://jsbin.com/wumozevimi/edit?js,output
You could also add a second dimension and include it into your categoryAxis-Feed.

Related

how to determine x and y position for graph type in echart

From the given examples for graph series, I see the graph nodes are getting loaded from JSON files, where each node has corresponding x and y position hard-coded.
"nodes": [
{
"id": "0",
"name": "Myriel",
"symbolSize": 19.12381,
"x": -266.82776,
"y": 299.6904,
"value": 28.685715,
"category": 0
},
...
How do I get to determine the position for my given dataset? Do i need to iterate through all my nodes and do some logic to dynamically determine those position so that the node wont get overlapped?
You can set layout parameter. Echarts will calculate the postions for you. https://echarts.apache.org/examples/zh/editor.html?c=graph-force

For loop to add numbers and get Average inside Text Widget in Flutter

SCENARIO
I am getting the json data by using flutter_bloc library pattern what i want to achieve is that i want to count/add the star key numbers and divide by length of star means get the average number of stars. Below is the json data and dart code till now what i did.
JSON Data
"feedbacks": [
{
"id": 1,
"comment": "Corporate Brand Supervisor",
"star": 1,
"createdAt": "2021-09-07T11:35:15.954Z",
"updatedAt": "2021-09-07T11:35:15.954Z",
"customerId": 10,
"branchId": 3
},
{
"id": 9,
"comment": "Principal Implementation Liaison",
"star": 1,
"createdAt": "2021-09-07T11:35:15.954Z",
"updatedAt": "2021-09-07T11:35:15.954Z",
"customerId": 1,
"branchId": 3
}
],
HomePage.dart
Row(
children: [
for (var i in data[index].feedbacks!)
Text(i!.star!.toString()),],), //Here expecting an average number of stars 1+1/2 = 1.5
If you want to only display the result (average) value of stars in a Text widget, you can do this:
Text((data[index]['feedbacks']!.map<int>((feedback) => feedback['star'] as int).reduce((acc, curr) => acc + curr) / data[index]['feedbacks']!.length).toStringAsFixed(2))
This assumes that every entry in feedback actually has a star property since I'm dividing by the amount of entries in feedback
I also added toStringAsFixed(2) to ensure that there a 2 decimals after the decimal point (might want to adjust that) instead of having a very long value in cases like 1/3

How to plot horizontal bars / columns / lines on timeseries data with HighStock?

I'd like to plot horizontal bars and/or lines on timeseries data with highstock, however I'm not able to identify the corresponding series type and how to feed the data in?
Is possible? If yes, how?
A screenshot of what I may imagine as outcome:
Data could be something similar eg:
[
{
"start": 1610969882000, // epoche time in ms
"end": 1624016282000,
"text": "Bar on timeseries",
"style": "bar",
"level": 1 // y-Axis height where to show
},
{
"start": 1613648282000,
"end": 1618745882000,
"text": "Line on timeseries",
"style": "line",
"level": 8
}
]
I did find column-range charts which seem to work with line charts, however I struggled overlaying this on a highstock timeseries chart, adding a label on top or making it a line with tooltip. Adding to highstock always ends up throwing an error "Script error."
Thx a lot in advance, I really appreciate your expertise!
Use xrange series type:
series: [{
type: 'xrange',
...
}]
Live demo: https://jsfiddle.net/BlackLabel/o9ks1efd/
API Reference: https://api.highcharts.com/highstock/series.xrange

How can I split colors of the area under line chart after a certain threshold (beyond x-axis)

I'm using Baidu's echarts library
How can I split colors of the area under a line chart after a certain threshold (beyond x-axis) using the areastyle?
Thank you!
You can't.
The areastyle is applied to the series itself, and cannot be tied to individual datapoints. Because the area color actually marks the area between two datapoints.
But.., you can, however, create a workaround and create two linecharts, like so:
legend: {
data: ['myLine']
},
series : [
{
name: 'myLine',
type: 'line',
areaStyle: {
normal: {
color: 'red'
}
},
data: [400, 300, 101, 134, null, null, null]
},
{
name: 'myLine',
type: 'line',
areaStyle: {
normal: {
color: 'green'
}
},
data: [null, null, null, 134, 90, 230, 210]
},
]
By adding it manually to the legend, and by giving both series the same name. ECharts combines the two series to some degree, so both the legend and the animation are acting like it's a single series.
Also, make sure to connect the two lines, by adding a datapoint twice (see 134). And you can customize the lines a little more with lineStyle, etc, to make them look better.
You can create a little demo by checking the ECharts demo gallery and replace the series and legend data with the snippet above (you may have to click the blue run button).

which style is most preferred in Mongodb?

In mongodb, which style is better? 1) or 2)? Can I retrieve only line name from 1) despite of getting whole record on db.record.find("line":"east")?
1.
{
"line": "east",
"station":[
{ "name": "ABC", "_id": "1", },
{ "name": "DEF", "_id": "2" }
]
}
2.
{ "line": "east", "l_id":"1"},
{"station":"ABC", "_id":"1", "l_id":"1"},
{"station":"ABC", "_id":"2", "l_id":"1"}
Note: line and station has one to many relationship.
If you are most commonly getting stations by line and often need all stations of a line alt 1 is the best. If you are commonly retrieving single stations or a subset of stations 2 is the best. Alt 2 can lead to more queries since mongo doesn't really have any relations, alt 1 can lead to larger reads and make it more difficult to keep the working set in RAM because of larger objects. Alt 1 also has a minor drawback if you change values in a station on multiple lines - then you have to update its instance in each of the line documents containg it.
To get a partial object, i.e. not all stations in alt 1, you can do a projection to filter out what you don't want. It still means reading the whole object into memory first so you wouldn't gain a lot in performance from doing that.