Flexchart ItemFormatter

Posted by: andy on 15 November 2017, 8:33 am EST

    • Post Options:
    • Link

    Posted 15 November 2017, 8:33 am EST

    Is there a way to format the flexchart (type bar) to different colors per bar. There is going to be criteria that will dictate which color it will be.

    Currently I have this set up for item formatter and what it does is it doesn’t make a bar. It has the label on the screen but no bar

    itemFormatter = (engine, hitTestInfo, defaultFormat) => {
            console.log(engine, hitTestInfo, defaultFormat);
            console.log('x', hitTestInfo.x);
            console.log('series', hitTestInfo.series);
            if (hitTestInfo.chartElement == wjcChart.ChartElement.Series) {
                let item = hitTestInfo.item;
                let series = hitTestInfo.series;
                let pi = hitTestInfo.pointIndex;
                console.log('pi', pi);
                if( pi > 0) {
                    let xvals = series.getValues(1);
                    // previous data point
                    let prevX = xvals ? xvals[pi - 1] : pi - 1;
                    let prevY = series.getValues(0)[pi - 1];
                    // convert to pixel coordinates
                    let pt1 = this.chart.dataToPoint( hitTestInfo.x, hitTestInfo.y);
                    // let pt2 = this.chart.dataToPoint( prevX, prevY);
                    // draw lines
                    // console.log()
                    engine.drawLine( hitTestInfo.point.x, hitTestInfo.point.y, pt1.x, pt1.y);
                    // engine.drawLine( pt1.x, pt1.y, pt2.x, pt2.y);
                    // engine.drawLine( pt1.x, pt1.y);
                }
                // draw default symbol\
                console.log('defaultFormat',defaultFormat);
                defaultFormat();
            }
        };
    

  • Posted 15 November 2017, 8:58 pm EST

    Hi,

    You need to use engine.fill property to change bar color. Please refer to the attached sample for the same.

    ~Manish

    FlexChart_itemFormatter.zip

  • Posted 16 November 2017, 2:23 am EST

    Manish,

    Thank you I could not find good documentation to figure this out.

    Thank You

    Andy

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels