使用billboard.js和angular我需要更改动态数据的图形颜色。我如何实现我,因为我是广告牌的新手

时间:2018-01-11 06:08:26

标签: angular billboard.js

graphData(){         let columns = [];         columns.push([" x",... this.sensorData.map(t => Date.parse(t.messageTimeStamp))]);         columns.push([" Temperature",... this.sensorData.map(t => t.temperature)]);         // columns.push([" Class",... this.sensorData.map(t => t.temperature)]);

    this.temperatureAlarms.forEach(currentItem => {
        this.alarmMinName = `${currentItem.alarmName} Min`;
        this.alarmMaxName = `${currentItem.alarmName} Max`;


        columns.push([this.alarmMinName, ...this.sensorData.map(() => currentItem.minVal)])
        columns.push([this.alarmMaxName, ...this.sensorData.map(() => currentItem.maxVal)])

    });
    // console.log(this.MinName,"this.MinName")
    console.log('columns: ', columns);
    console.log('new columns', ...columns);
    let coc = [];
    this.custodyChanges.forEach(currentItem => {
        //   console.log(currentItem);
        coc.push({ value: Date.parse(currentItem.timestamp), text: currentItem.id, class: 'coc' })
    });

    let geo = [];
    this.geozones.forEach(currentItem => {
        geo.push({ value: Date.parse(currentItem.timestamp), text: currentItem.id, class: 'geofence' })
    });

    var ngChart = bb.generate({

        bindto: this.chart,
        data: {
            "x": "x",
            columns: [
                ...columns
            ],
            types: {
                data1: "line",
                COC: "bar",
                maxName: "bar",
                minName: "step",
                Temperature: "area"
            },
            //  colors: {
            //         Temperature:"green",
            //     } ,  
            color: function (color, d) {
                // console.log("devalue", d)
                // console.log("akshay", d.indexOf('Yellow'))
                debugger
                if (typeof d === "string") {
                    console.log("devalue inside", d)
                    if (d.indexOf('Yellow') == -1) {
                        return color = "red";
                    } else {
                        return color = "yellow";
                    }
                }
                 return color="green";
            },

0 个答案:

没有答案