Code files :
app.component.ts
import { Component } from '@angular/core';
import * as wjcCore from 'wijmo/wijmo';
import * as wjcChart from 'wijmo/wijmo.chart';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
public tooltipContent: any;
public barChartData = {
"Id": 1,
"Condition": "User Count",
"List": [
{
"Value": 138,
"CreatedDate": "12-13-2019",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 129,
"CreatedDate": "12-14-2019",
"Color": "Green",
"ColorCode": "#66FF66"
},
{
"Value": 137,
"CreatedDate": "12-15-2019",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 158,
"CreatedDate": "12-16-2019",
"Color": "Gray",
"ColorCode": "#C0C0C0"
},
{
"Value": 138,
"CreatedDate": "01-06-2020",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 138,
"CreatedDate": "01-07-2020",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 136,
"CreatedDate": "01-08-2020",
"Color": "Green",
"ColorCode": "#66FF66"
},
{
"Value": 125,
"CreatedDate": "01-11-2020",
"Color": "Blue",
"ColorCode": "#66B2FF"
},
{
"Value": 138,
"CreatedDate": "01-12-2020",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 129,
"CreatedDate": "01-13-2020",
"Color": "Green",
"ColorCode": "#66FF66"
},
{
"Value": 137,
"CreatedDate": "01-14-2020",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 158,
"CreatedDate": "01-15-2020",
"Color": "Gray",
"ColorCode": "#C0C0C0"
},
{
"Value": 138,
"CreatedDate": "02-06-2020",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 138,
"CreatedDate": "02-07-2020",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 136,
"CreatedDate": "02-08-2020",
"Color": "Green",
"ColorCode": "#66FF66"
},
{
"Value": 125,
"CreatedDate": "02-11-2020",
"Color": "Blue",
"ColorCode": "#66B2FF"
},
{
"Value": 138,
"CreatedDate": "03-13-2020",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 129,
"CreatedDate": "03-14-2020",
"Color": "Green",
"ColorCode": "#66FF66"
},
{
"Value": 137,
"CreatedDate": "03-15-2020",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 158,
"CreatedDate": "03-16-2020",
"Color": "Gray",
"ColorCode": "#C0C0C0"
},
{
"Value": 138,
"CreatedDate": "04-06-2020",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 138,
"CreatedDate": "04-07-2020",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 136,
"CreatedDate": "04-08-2020",
"Color": "Green",
"ColorCode": "#66FF66"
},
{
"Value": 125,
"CreatedDate": "04-11-2020",
"Color": "Blue",
"ColorCode": "#66B2FF"
}
],
"Graph": "Bar",
"Xaxis": "No. of users",
"Yaxis": "Date",
"Header": "Many Data"
}
public barChartData_2 = {
"Id": 2,
"Condition": "User Count 2",
"List": [
{
"Value": 135,
"CreatedDate": "12-12-2019",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 138,
"CreatedDate": "12-13-2019",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 129,
"CreatedDate": "12-14-2019",
"Color": "Green",
"ColorCode": "#66FF66"
},
{
"Value": 137,
"CreatedDate": "12-15-2019",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 158,
"CreatedDate": "12-16-2019",
"Color": "Gray",
"ColorCode": "#C0C0C0"
},
{
"Value": 138,
"CreatedDate": "01-06-2020",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 138,
"CreatedDate": "01-07-2020",
"Color": "Orange",
"ColorCode": "#FFCC99"
},
{
"Value": 136,
"CreatedDate": "01-08-2020",
"Color": "Green",
"ColorCode": "#66FF66"
},
{
"Value": 125,
"CreatedDate": "01-11-2020",
"Color": "Blue",
"ColorCode": "#66B2FF"
}
],
"Graph": "Bar",
"Xaxis": "No. of users",
"Yaxis": "Date",
"Header": "Less Data"
};
constructor(){}
ngOnInit() {
this.tooltipContent = '{seriesName} on {x} : <b>{y}</b>';
}
itemFormatter = function (engine, hitTestInfo, defaultFormat) {
if (hitTestInfo.chartElement === wjcChart.ChartElement.SeriesSymbol) {
// set the SVG fill and stroke based on the category's bgColor property
engine.fill = hitTestInfo.item.ColorCode;
engine.stroke = hitTestInfo.item.ColorCode;
// engine.fill = this.colorGradient;
// engine.stroke = this.colorGradient;
defaultFormat();
}
};
}
app.component.html
<div class="custom-bar-chart">
<wj-flex-chart
[itemsSource]="barChartData.List"
[chartType]="barChartData.Graph"
[bindingX]="'CreatedDate'"
[tooltipContent]="tooltipContent"
[itemFormatter]="itemFormatter"
[header]="barChartData.Header">
<wj-flex-chart-legend [position]="'None'"></wj-flex-chart-legend>
<wj-flex-chart-axis wjProperty="axisX" [title]="barChartData.Xaxis"></wj-flex-chart-axis>
<wj-flex-chart-axis wjProperty="axisY" [title]="barChartData.Yaxis"></wj-flex-chart-axis>
<wj-flex-chart-series [name]="barChartData.Condition" [binding]="'Value'">
</wj-flex-chart-series>
<wj-flex-chart-plot-area [height]="'140px'" [width]="'500px'"></wj-flex-chart-plot-area>
</wj-flex-chart>
</div>
<div class="custom-bar-chart">
<wj-flex-chart
[itemsSource]="barChartData_2.List"
[chartType]="barChartData_2.Graph"
[bindingX]="'CreatedDate'"
[tooltipContent]="tooltipContent"
[itemFormatter]="itemFormatter"
[header]="barChartData_2.Header">
<wj-flex-chart-legend [position]="'None'"></wj-flex-chart-legend>
<wj-flex-chart-axis [wjProperty]="'axisX'" [title]="barChartData_2.Xaxis"></wj-flex-chart-axis>
<wj-flex-chart-axis [wjProperty]="'axisY'" [title]="barChartData_2.Yaxis"></wj-flex-chart-axis>
<wj-flex-chart-series [name]="barChartData_2.Condition" [binding]="'Value'">
</wj-flex-chart-series>
<wj-flex-chart-plot-area [height]="'140px'" [width]="'500px'"></wj-flex-chart-plot-area>
</wj-flex-chart>
</div>
app.component.css
.wj-tooltip{
background-color:white;
color:black;
}
.custom-bar-chart .wj-flexchart{
height: 300px;
}