简体   繁体   中英

Range bar chart in ng2-charts

I need to implement bar graph for weekly data something like below image. x-axis label will be week1, week2, week3 etc and bar for each day. I just want simple bar graph with weekly seperation no need of fancy colors or anything like below graph.

在此处输入图像描述

In ng2-charts bar chart docu.netation I saw 2 bars for each year. So how can I achieve multiple bars for each week

在此处输入图像描述

Somehow I am able to achieve the functionality by updating the example mentioned in documentation.

I wanted same color for all bars so repeating the same color. Not sure how to pass once for all

  public barChartColors2: Color[] = [
    { backgroundColor: '#35A4E8' },
    { backgroundColor: '#35A4E8' },
    { backgroundColor: '#35A4E8' },
    { backgroundColor: '#35A4E8' },
    { backgroundColor: '#35A4E8' },
    { backgroundColor: '#35A4E8' },
    { backgroundColor: '#35A4E8' }
    ];  

    public barChartData: ChartDataSets[] = [
    { data: [23, 42, 23, 54], label: 'Sunday', stack:'a' },
    { data: [91, 22, 53, 84], label: 'Monday' },
    { data: [51, 62, 23, 47], label: 'Tuesday' },
    { data: [71, 26, 53, 24], label: 'Wednesday' },
    { data: [51, 72, 33, 94], label: 'Thursday' },
    { data: [11, 32, 43, 54], label: 'Friday' },
    { data: [21, 42, 43, 44], label: 'Saturday' } 
    ];

Stackbliz working demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM