Hii,
I have index with data and I want to show the data as Gantt.
The data contains :
session_id - Unique Id for the session
date_created/time - When the session start (same for all the rows of the session)
Phase_type - Phase_type
name - phase name
start_time_ms - time as millisecond for date_created
end_time_ms - time as millisecond for date_created
duration_ms - phase duration as millisecond (end_time_ms - start_time_ms)
As you can see there is three Phase_type:
1.platform - its contains the time of all the phases
2. phase - its part of the platform and have start and end time
3. milestone - its Point in time of the platform and the start_time = end_time (duration is 0)
I need to build tow gantt:
1. show gantt of one session.
2. show gantt of average of all session (time of each phase will be the avg of start_time,end_tme from all sessions).
I tried to do it in Vega, But I did not succeed
I would love to get help on the subject
link to google sheet of the data
Code to create the Index:
import ssl
from elasticsearch import Elasticsearch, helpers
from elasticsearch.connection import create_ssl_context
jsn = [
{
"Time": "18/07/2021 11:34:56",
"session_id": 123,
"date_created": "Jul 18, 2021 @ 11:34:56.000",
"Phase_type": "platform",
"name": "platform",
"start_time_ms": 94,
"end_time_ms": 2660,
"duration_ms": 2565
},
{
"Time": "18/07/2021 11:34:56",
"session_id": 123,
"date_created": "Jul 18, 2021 @ 11:34:56.000",
"Phase_type": "phase",
"name": "dom_ready",
"start_time_ms": 689,
"end_time_ms": 1224,
"duration_ms": 540
},
{
"Time": "18/07/2021 11:34:56",
"session_id": 123,
"date_created": "Jul 18, 2021 @ 11:34:56.000",
"Phase_type": "phase",
"name": "component_loader",
"start_time_ms": 690,
"end_time_ms": 710,
"duration_ms": 19
},
{
"Time": "18/07/2021 11:34:56",
"session_id": 123,
"date_created": "Jul 18, 2021 @ 11:34:56.000",
"Phase_type": "phase",
"name": "load_environment",
"start_time_ms": 691,
"end_time_ms": 705,
"duration_ms": 14
},
{
"Time": "18/07/2021 11:34:56",
"session_id": 123,
"date_created": "Jul 18, 2021 @ 11:34:56.000",
"Phase_type": "phase",
"name": "load_renderer",
"start_time_ms": 706,
"end_time_ms": 1073,
"duration_ms": 367
},
{
"Time": "18/07/2021 11:34:56",
"session_id": 123,
"date_created": "Jul 18, 2021 @ 11:34:56.000",
"Phase_type": "phase",
"name": "client",
"start_time_ms": 1074,
"end_time_ms": 2451,
"duration_ms": 1376
},
{
"Time": "18/07/2021 11:34:56",
"session_id": 123,
"date_created": "Jul 18, 2021 @ 11:34:56.000",
"Phase_type": "phase",
"name": "init_page",
"start_time_ms": 1195,
"end_time_ms": 2441,
"duration_ms": 1246
},
{
"Time": "18/07/2021 11:34:56",
"session_id": 123,
"date_created": "Jul 18, 2021 @ 11:34:56.000",
"Phase_type": "phase",
"name": "client_render",
"start_time_ms": 2458,
"end_time_ms": 2617,
"duration_ms": 160
},
{
"Time": "18/07/2021 11:34:56",
"session_id": 123,
"date_created": "Jul 18, 2021 @ 11:34:56.000",
"Phase_type": "milestone",
"name": "hidden",
"start_time_ms": 3736,
"end_time_ms": 3736,
"duration_ms": 0
},
{
"Time": "18/07/2021 11:34:56",
"session_id": 123,
"date_created": "Jul 18, 2021 @ 11:34:56.000",
"Phase_type": "milestone",
"name": "visible",
"start_time_ms": 1578,
"end_time_ms": 1578,
"duration_ms": 0
},
{
"Time": "18/07/2021 11:35:42",
"session_id": 456,
"date_created": "Jul 18, 2021 @ 11:34:58.000",
"Phase_type": "platform",
"name": "platform",
"start_time_ms": 790,
"end_time_ms": 2009,
"duration_ms": 1221
},
{
"Time": "18/07/2021 11:35:42",
"session_id": 456,
"date_created": "Jul 18, 2021 @ 11:34:58.000",
"Phase_type": "phase",
"name": "dom_ready",
"start_time_ms": 1718,
"end_time_ms": 1864,
"duration_ms": 147
},
{
"Time": "18/07/2021 11:35:42",
"session_id": 456,
"date_created": "Jul 18, 2021 @ 11:34:58.000",
"Phase_type": "phase",
"name": "component_loader",
"start_time_ms": 1718,
"end_time_ms": 1724,
"duration_ms": 6
},
{
"Time": "18/07/2021 11:35:42",
"session_id": 456,
"date_created": "Jul 18, 2021 @ 11:34:58.000",
"Phase_type": "phase",
"name": "load_environment",
"start_time_ms": 1718,
"end_time_ms": 1723,
"duration_ms": 4
},
{
"Time": "18/07/2021 11:35:42",
"session_id": 456,
"date_created": "Jul 18, 2021 @ 11:34:58.000",
"Phase_type": "phase",
"name": "load_renderer",
"start_time_ms": 1723,
"end_time_ms": 1838,
"duration_ms": 115
},
{
"Time": "18/07/2021 11:35:42",
"session_id": 456,
"date_created": "Jul 18, 2021 @ 11:34:58.000",
"Phase_type": "phase",
"name": "client",
"start_time_ms": 1838,
"end_time_ms": 1982,
"duration_ms": 144
},
{
"Time": "18/07/2021 11:35:42",
"session_id": 456,
"date_created": "Jul 18, 2021 @ 11:34:58.000",
"Phase_type": "phase",
"name": "init_page",
"start_time_ms": 1859,
"end_time_ms": 1979,
"duration_ms": 119
},
{
"Time": "18/07/2021 11:35:42",
"session_id": 456,
"date_created": "Jul 18, 2021 @ 11:34:58.000",
"Phase_type": "phase",
"name": "client_render",
"start_time_ms": 1983,
"end_time_ms": 2005,
"duration_ms": 22
},
{
"Time": "18/07/2021 11:35:42",
"session_id": 456,
"date_created": "Jul 18, 2021 @ 11:34:58.000",
"Phase_type": "milestone",
"name": "hidden",
"start_time_ms": 2451,
"end_time_ms": 2451,
"duration_ms": 0
},
{
"Time": "18/07/2021 11:35:42",
"session_id": 456,
"date_created": "Jul 18, 2021 @ 11:34:58.000",
"Phase_type": "milestone",
"name": "visible",
"start_time_ms": 1480,
"end_time_ms": 1480,
"duration_ms": 0
}
]
# ElasticSearch configs and connection
ssl_context = create_ssl_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
ELASTICSEARCH_USER = "UserName"
ELASTICSEARCH_PASS = "Password"
es = Elasticsearch(['https://LinkToES'],
verify_certs=False,
ssl_context=ssl_context,
timeout=600)
print(es.cluster.health())
Gantt_Index = 'session_gantt_idx'
if es.indices.exists(index=Gantt_Index):
es.indices.delete(index=Gantt_Index)
if not es.indices.exists(index=Gantt_Index):
es.indices.create( index=Gantt_Index,
ignore=400, # ignore 400 already exists code
include_type_name=True
)
es.transport.close()
es = Elasticsearch(['https://LinkToES'],
verify_certs=False,
ssl_context=ssl_context,
timeout=600)
helpers.bulk(es, jsn, index=Gantt_Index)
es.indices.refresh(index=Gantt_Index)
es.transport.close()