|
| 1 | +# Data Vizualation Query |
| 2 | +Data Viz Queries are used whenever the SDK calls our Data Vizualation APIs. The functions you call via SDK do some work on the query for you so this Query will look slightly different from the one our API uses directly. We will break down each field in some more detail futher along in this doc but as an example a full Data Viz Query looks like the following: |
| 3 | +``` |
| 4 | +{ |
| 5 | + "asset_selection": { |
| 6 | + "machine_source": [ |
| 7 | + "JB_AB_Lasercut_1" |
| 8 | + ], |
| 9 | + "machine_type": [ |
| 10 | + "Lasercut" |
| 11 | + ] |
| 12 | + }, |
| 13 | + "d_vars": [ |
| 14 | + { |
| 15 | + "name": "quality", |
| 16 | + "aggregate": [ |
| 17 | + "avg" |
| 18 | + ] |
| 19 | + } |
| 20 | + ], |
| 21 | + "i_vars": [ |
| 22 | + { |
| 23 | + "name": "endtime", |
| 24 | + "time_resolution": "day", |
| 25 | + "query_tz": "America/Los_Angeles", |
| 26 | + "output_tz": "America/Los_Angeles", |
| 27 | + "bin_strategy": "user_defined2", |
| 28 | + "bin_count": 50 |
| 29 | + } |
| 30 | + ], |
| 31 | + "time_selection": { |
| 32 | + "time_type": "relative", |
| 33 | + "relative_start": 7, |
| 34 | + "relative_unit": "year", |
| 35 | + "ctime_tz": "America/Los_Angeles" |
| 36 | + }, |
| 37 | + "where": [], |
| 38 | + "db_mode": "sql" |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +## Asset_selection |
| 43 | +Used to select the asset(s) you want to recieve data from see the [asset_selection doc](/docs/commonly_used_data_types/asset_selection.md) for more information. |
| 44 | + |
| 45 | +## d_vars |
| 46 | +The Dependent variables. These will change depending on the entity you are trying to access. But will always be a list in the following form: |
| 47 | +``` |
| 48 | + { |
| 49 | + "name": "quality", |
| 50 | + "aggregate": [ |
| 51 | + "avg" |
| 52 | + ] |
| 53 | + } |
| 54 | +``` |
| 55 | +### name |
| 56 | +This is the name of dependent variable you wish to view. This typically the name of a value we store on a machine or the name of a KPI. |
| 57 | + |
| 58 | +### aggregate |
| 59 | +This is how you wish to aggregate the data of the named value in the time_resolution you have selected. The options for this are: |
| 60 | +* avg |
| 61 | +* sum |
| 62 | +* min |
| 63 | +* max |
| 64 | + |
| 65 | +## i_vars |
| 66 | +The indepent variables. These should typically be time based values that are stored on the machine_type you are using. They will always be a list in the following form: |
| 67 | +``` |
| 68 | +{ |
| 69 | + "name": "endtime", |
| 70 | + "time_resolution": "day", |
| 71 | + "query_tz": "America/Los_Angeles", |
| 72 | + "output_tz": "America/Los_Angeles", |
| 73 | + "bin_strategy": "user_defined2", |
| 74 | + "bin_count": 50 |
| 75 | + } |
| 76 | +``` |
| 77 | +### name |
| 78 | +This is the name of idependent varaible you are using. |
| 79 | + |
| 80 | +### time_resolution |
| 81 | +This is optional and is how detailed of a time breakdown you want in the variable the options for time_resolution are as follows: |
| 82 | +* year |
| 83 | +* month |
| 84 | +* week |
| 85 | +* day |
| 86 | +* hour |
| 87 | +* minute |
| 88 | +* second |
| 89 | + |
| 90 | +### query_tz |
| 91 | +This is optional and tells the system what time zone the query is in. |
| 92 | + |
| 93 | +### output_tz |
| 94 | +This is optional and tells the system what time zone to return the data in. |
| 95 | + |
| 96 | +### bin_strategy |
| 97 | +This is optional and tells the sytem how you wish to bin the data. You have the following options: |
| 98 | +* user_defined2 |
| 99 | +* none |
| 100 | +* categorical |
| 101 | + |
| 102 | +### bin_count |
| 103 | +This is optoinal and tels the system how many bins you wish to put the data into. |
| 104 | + |
| 105 | +## time_selection |
| 106 | +This is the time frame you want to grab data from there are two different ways to make this time selection, Relative and Absolute |
| 107 | + |
| 108 | +### Relative Time Selection |
| 109 | +Relative Time Selections goes back from now a certain amount of time based on what you tell it. The format for this time selection is the following: |
| 110 | +``` |
| 111 | +{ |
| 112 | + "time_type": "relative", |
| 113 | + "relative_start": 7, |
| 114 | + "relative_unit": "year", |
| 115 | + "ctime_tz": "America/Los_Angeles" |
| 116 | +} |
| 117 | +``` |
| 118 | +#### Time Type |
| 119 | +For a relative time selection this needs to be set to "relative". |
| 120 | + |
| 121 | +#### Relative Start |
| 122 | +The amount of units from now you wish to go back to start your time selection. |
| 123 | + |
| 124 | +#### Relative Unit |
| 125 | +The unit of time you wish to go back from now. Your options for this are as follows: |
| 126 | +* year |
| 127 | +* month |
| 128 | +* week |
| 129 | +* day |
| 130 | +* hour |
| 131 | +* minute |
| 132 | +* second |
| 133 | + |
| 134 | +#### ctime_tz |
| 135 | +The time zone for your time selection |
| 136 | + |
| 137 | +### Absolute Time Selection |
| 138 | +Absolute Time Selections have a start and end time and will gather data from between the two. The format for this time selection is as follows: |
| 139 | +``` |
| 140 | +{ |
| 141 | + "time_type": "absolute", |
| 142 | + "start_time": "2023-02-23T08:00:00.000Z", |
| 143 | + "end_time": "2023-03-01T21:35:35.499Z", |
| 144 | + "time_zone": "America/Los_Angeles" |
| 145 | +} |
| 146 | +``` |
| 147 | +#### Time Type |
| 148 | +For absolute time selecitons this must be set to absolute. |
| 149 | + |
| 150 | +#### Start Time |
| 151 | +The time you wish to start the time selection at. |
| 152 | + |
| 153 | +#### End Time |
| 154 | +The time you wish to end the time selection at. |
| 155 | + |
| 156 | +#### Time Zone |
| 157 | +The time zone for the time selection. |
| 158 | + |
| 159 | +## Where |
| 160 | +This is optional. It will narrow down the data return based on criteria given. The list will be anded together. This is a list in the following format: |
| 161 | +``` |
| 162 | +{ |
| 163 | + "name": "type__part_type", |
| 164 | + "op": "eq", |
| 165 | + "value": "EngineBlock" |
| 166 | +} |
| 167 | +``` |
| 168 | + |
| 169 | +### Name |
| 170 | +The name of the field you are using in this criteria. |
| 171 | + |
| 172 | +### Op |
| 173 | +The type of operation you are doing. |
| 174 | + |
| 175 | +### Value |
| 176 | +The value to compare with the operation. |
| 177 | + |
| 178 | +## db_mode |
| 179 | +This is optional. It will default to 'sql' and usually should be but we have a 'mongo' mode as well. You will likely ever need to set this. |
0 commit comments