本文整理汇总了TypeScript中db/model/Chart.Chart类的典型用法代码示例。如果您正苦于以下问题:TypeScript Chart类的具体用法?TypeScript Chart怎么用?TypeScript Chart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Chart类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
api.post('/charts/:chartId/setTags', async (req: Request, res: Response) => {
const chartId = expectInt(req.params.chartId)
await Chart.setTags(chartId, req.body.tagIds)
return { success: true }
})
示例2: up
public async up(queryRunner: QueryRunner): Promise<any> {
const charts = await Chart.find()
for (let chart of charts) {
if (chart.config.internalNotes === "core-econ.org") {
chart.config.hideLogo = true
await chart.save()
}
}
}
示例3: up
public async up(queryRunner: QueryRunner): Promise<any> {
const charts = await Chart.find()
for (let chart of charts) {
if (chart.config.comparisonLine) {
chart.config.comparisonLines = [chart.config.comparisonLine]
delete chart.config.comparisonLine
await chart.save()
}
}
}
示例4: dataExport
async function dataExport() {
await db.connect()
const slugs = (await fs.readFile("/Users/mispy/tmp/urls.txt", "utf8")).split("\n").filter(s => s.trim())
const slugToId = await Chart.mapSlugsToIds()
const idsToGet = slugs.map(slug => slugToId[slug])
const variables = await db.query("SELECT v.name, v.id FROM variables v JOIN chart_dimensions cd ON cd.variableId=v.id WHERE cd.chartId IN (?)", [idsToGet])
const variableIds = variables.map((v: any) => v.id)
const stream = fs.createWriteStream("/Users/mispy/tmp/sdgs.csv")
// From dataset CSV export
const csvHeader = ["Entity", "Year"]
for (const variable of variables) {
csvHeader.push(variable.name)
}
const columnIndexByVariableId: {[key: number]: number} = {}
for (const variable of variables) {
columnIndexByVariableId[variable.id] = csvHeader.indexOf(variable.name)
}
stream.write(csvRow(csvHeader))
const data = await db.query(`
SELECT e.name AS entity, dv.year, dv.value, dv.variableId FROM data_values dv
JOIN variables v ON v.id=dv.variableId
JOIN entities e ON dv.entityId=e.id
WHERE v.id IN (?)
ORDER BY e.name ASC, dv.year ASC, dv.variableId ASC`, [variableIds])
let row: string[] = []
for (const datum of data) {
if (datum.entity !== row[0] || datum.year !== row[1]) {
// New row
if (row.length) {
stream.write(csvRow(row))
}
row = [datum.entity, datum.year]
for (const variable of variables) {
row.push("")
}
}
row[columnIndexByVariableId[datum.variableId]] = datum.value
}
// Final row
stream.write(csvRow(row))
stream.end()
await db.end()
}
示例5: main
async function main() {
(global as any).window = {};
(global as any).App = {}
const chartRows = await Chart.all()
for (const c of chartRows) {
const chart = new ChartConfig(c.config)
chart.isLocalExport = true
const variableIds = _.uniq(chart.dimensions.map(d => d.variableId))
const vardata = await getVariableData(variableIds)
chart.vardata.receiveData(vardata)
c.config.data = chart.data.json
console.log(c.id)
await db.table("charts").where({ id: c.id }).update({ config: JSON.stringify(c.config) })
}
await db.end()
}