-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathES Dash V2 Main Board
44 lines (35 loc) · 2.03 KB
/
ES Dash V2 Main Board
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from elasticsearch import Elasticsearch
import numpy as np
import plotly.express as px
import seaborn as sns
import pandas as pd
from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource
# Elasticsearch query
es = Elasticsearch(['http://elasticsearch-master-headless.elastic.svc.cluster.local:9200'], bearer_auth=('elastic_admin', 'C!m3tR1x5@'))
resp = es.search(index="kohyoung_continuousline1_bluesky_f8a9643b-5939-44d6-bd1b-16d92a0c6fed-000005", query={'match_all' : {}}, sort={'equipmentTimeStamp' : 'desc'}, size=100)
elastic_docs = resp["hits"]["hits"]
fields = {}
for num, doc in enumerate(elastic_docs):
source_data = doc["_source"]
for key, val in source_data.items():
try:
fields[key] = np.append(fields[key], val)
except KeyError:
fields[key] = np.array([val])
elastic_df = pd.DataFrame.from_dict(fields, orient='index').transpose().sort_values(by='equipmentTimeStamp', ascending=False)
# Create a Bokeh figure
TOOLS = "hover,pan,wheel_zoom,box_zoom,reset,save"
p = figure(title="Component Scatter Plot", tools=TOOLS)
# Create ColumnDataSource for the entire dataset
source = ColumnDataSource(elastic_df)
# Add scatter glyphs to the figure for each result type
p.circle(x='parameter_60007_posx(mm)', y='parameter_60007_posy(mm)', source=source, size=10, legend_label='W.Insuffi.', color='red', alpha=0.5, line_color=None, muted_alpha=0.2)
p.circle(x='parameter_60007_posx(mm)', y='parameter_60007_posy(mm)', source=source, size=10, legend_label='GOOD', color='green', alpha=0.5, line_color=None, muted_alpha=0.2)
p.circle(x='parameter_60007_posx(mm)', y='parameter_60007_posy(mm)', source=source, size=10, legend_label='E.Insuffi.', color='blue', alpha=0.5, line_color=None, muted_alpha=0.2)
# Add legend
p.legend.click_policy="mute"
# Show the plot
show(p)
###############################
Hello Aersi! No errors, but also nothing displayed either! Could this be because we can only display visuals in the same tab as the kernel? On Jupyter, this code opens the visual in a new tab.