当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Chart.Chart类代码示例

本文整理汇总了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 }
})
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:7,代码来源:api.ts

示例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()
         }
     }
 }
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:9,代码来源:1546730871436-CoreEconRemoveLogos.ts

示例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()
         }
     }
 }
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:10,代码来源:1546720280923-MultipleComparisonLines.ts

示例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()
}
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:54,代码来源:exportSDGTrackerData.ts

示例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()
}
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:18,代码来源:resaveChartData.ts


注:本文中的db/model/Chart.Chart类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。