Published unlisted
Edited
Feb 14, 2022
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// 以下をchart-template.component.ts の createPlot() に貼りつける
Plot.plot({
marks: [
Plot.rectY(data.measurements, Plot.binX({y: "count"}, {x: "c8y_Temperature_T_value", fill: "source_id"}))
]
});
Insert cell
// 取得したデータを使い、グラフの形状や色を変えることで Observable 上で様々な可視化を試すことができます
Plot.plot({
marks: [
Plot.line(data.measurements, {x: "time", y: "c8y_Temperature_T_value", stroke: "lightblue"})
]
});
Insert cell
Insert cell
Insert cell
data = {
let chartTemplateService = new ChartTemplateService();
await chartTemplateService.init(baseUrl, user, password);

// 取得したいデータに応じてフィルターを設定してください
// Measurements
const measurementFilter = ({
fragmentType: 'c8y_Temperature',
dateFrom: "2022-01-01T00:00:00+09:00",
dateTo: "2030-01-01T23:59:59+09:00",
pageSize: 50,
})

// Alarms
const alarmFilter = ({
dateFrom: "2022-01-01T00:00:00+09:00",
dateTo: "2030-01-01T23:59:59+09:00",
pageSize: 50,
type: 'com_MaintenanceAlarm'
})
// Events
const eventFilter = ({
dateFrom: "2022-01-01T00:00:00+09:00",
dateTo: "2030-01-01T23:59:59+09:00",
pageSize: 50,
})

// 第一引数: デバイス/グループの Managed Object ID、第二引数: フィルタ
const measurements = await chartTemplateService.getMeasurementsArray("18176088", measurementFilter);
const alarms = await chartTemplateService.getAlarmsArray("16657146", alarmFilter);
const events = await chartTemplateService.getEventsArray("11527119", eventFilter);
return {measurements, alarms, events};
}
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more