Skip to content

Commit 1a6ed8e

Browse files
savvinsergeyignatvilesov
authored andcommitted
Added Hours,Minutes,Seconds date types for axis (#37)
1 parent ff018dd commit 1a6ed8e

File tree

8 files changed

+86
-24
lines changed

8 files changed

+86
-24
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## 1.4.0
2+
* Added new date types for x-axis(Quarter, Hours, Minutes, Seconds)
13
## 1.3.0
24
* Added colour settings for: Today Bar Color, Axis Color, Axis Text Color
35
* Added ability to set colour of Tasks if there is no legend specified.

capabilities.json

+29-9
Original file line numberDiff line numberDiff line change
@@ -456,40 +456,60 @@
456456
}
457457
},
458458
"dateType": {
459-
"displayName": "Gantt Date type",
460-
"displayNameKey": "Visual_GanttDateType",
459+
"displayName": "Date type",
460+
"displayNameKey": "Visual_DateType",
461461
"properties": {
462462
"type": {
463463
"displayName": "Type",
464464
"displayNameKey": "Visual_Type",
465465
"type": {
466466
"enumeration": [
467+
{
468+
"value": "Second",
469+
"displayName": "Second",
470+
"displayNameKey": "Visual_DateType_Second"
471+
},
472+
{
473+
"value": "Minute",
474+
"displayName": "Minute",
475+
"displayNameKey": "Visual_DateType_Minute"
476+
},
477+
{
478+
"value": "Hour",
479+
"displayName": "Hour",
480+
"displayNameKey": "Visual_DateType_Hour"
481+
},
467482
{
468483
"value": "Day",
469484
"displayName": "Day",
470-
"displayNameKey": "Visual_GanttDateType_Day"
485+
"displayNameKey": "Visual_DateType_Day"
471486
},
472487
{
473488
"value": "Week",
474489
"displayName": "Week",
475-
"displayNameKey": "Visual_GanttDateType_Week"
490+
"displayNameKey": "Visual_DateType_Week"
476491
},
477492
{
478493
"value": "Month",
479494
"displayName": "Month",
480-
"displayNameKey": "Visual_GanttDateType_Month"
495+
"displayNameKey": "Visual_DateType_Month"
496+
},
497+
{
498+
"value": "Quarter",
499+
"displayName": "Quarter",
500+
"displayNameKey": "Visual_DateType_Quarter"
481501
},
482502
{
483503
"value": "Year",
484504
"displayName": "Year",
485-
"displayNameKey": "Visual_GanttDateType_Year"
505+
"displayNameKey": "Visual_DateType_Year"
486506
}
487507
]
488508
}
489509
},
490510
"todayColor": {
491511
"displayName": "Today Color",
492-
"displayNameKey": "Visual_GanttDateType_TodayColor",
512+
"displayNameKey": "Visual_DateType_TodayColor",
493513
"type": {
494514
"fill": {
495515
"solid": {
@@ -500,7 +520,7 @@
500520
},
501521
"axisColor": {
502522
"displayName": "Axis Color",
503-
"displayNameKey": "Visual_GanttDateType_AxisColor",
523+
"displayNameKey": "Visual_DateType_AxisColor",
504524
"type": {
505525
"fill": {
506526
"solid": {
@@ -511,7 +531,7 @@
511531
},
512532
"axisTextColor": {
513533
"displayName": "Axis Text Color",
514-
"displayNameKey": "Visual_GanttDateType_AxisTextColor",
534+
"displayNameKey": "Visual_DateType_AxisTextColor",
515535
"type": {
516536
"fill": {
517537
"solid": {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "powerbi-visuals-gantt",
3-
"version": "1.3.0",
3+
"version": "1.4.0",
44
"description": "A Gantt chart is a type of bar chart which illustrates a project timeline or schedule. The Gantt Chart visual shows the Tasks, Start Dates, Durations, % Complete, and Resources for a project. The Gantt Chart visual can be used to show current schedule status using percent-complete shadings and a vertical \"TODAY\" line. The Legend may be used to group or filter tasks based upon data values.",
55
"repository": {
66
"type": "git",

pbiviz.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"displayName": "Gantt",
55
"guid": "Gantt1448688115699",
66
"visualClassName": "Gantt",
7-
"version": "1.3.0",
7+
"version": "1.4.0",
88
"description": "A Gantt chart is a type of bar chart which illustrates a project timeline or schedule. The Gantt Chart visual shows the Tasks, Start Dates, Durations, % Complete, and Resources for a project. The Gantt Chart visual can be used to show current schedule status using percent-complete shadings and a vertical \"TODAY\" line. The Legend may be used to group or filter tasks based upon data values.",
99
"supportUrl": "http://community.powerbi.com",
1010
"gitHubUrl": "https://github.com/Microsoft/powerbi-visuals-gantt"

src/gantt.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,14 @@ module powerbi.extensibility.visual {
100100
import timeScale = d3.time.Scale;
101101

102102
const PercentFormat: string = "0.00 %;-0.00 %;0.00 %";
103-
const MillisecondsInADay: number = 24 * 60 * 60 * 1000;
103+
const MillisecondsInASecond: number = 1000;
104+
const MillisecondsInAMinute: number = 60 * MillisecondsInASecond;
105+
const MillisecondsInAHour: number = 60 * MillisecondsInAMinute;
106+
const MillisecondsInADay: number = 24 * MillisecondsInAHour;
104107
const MillisecondsInWeek: number = 4 * MillisecondsInADay;
105108
const MillisecondsInAMonth: number = 30 * MillisecondsInADay;
106109
const MillisecondsInAYear: number = 365 * MillisecondsInADay;
110+
const MillisecondsInAQuarter: number = MillisecondsInAYear / 4;
107111
const PaddingTasks: number = 5;
108112
const DefaultChartLineHeight = 40;
109113
const GanttDurationUnitType = [
@@ -246,9 +250,13 @@ module powerbi.extensibility.visual {
246250
TaskLineWidth: 15,
247251
DefaultDateType: "Week",
248252
DateFormatStrings: {
253+
Second: "HH:mm:ss",
254+
Minute: "HH:mm:ss",
255+
Hour: "(dd) HH:mm",
249256
Day: "MMM dd",
250257
Week: "MMM dd",
251258
Month: "MMM yyyy",
259+
Quarter: "MMM yyyy",
252260
Year: "yyyy"
253261
}
254262
};
@@ -908,6 +916,15 @@ module powerbi.extensibility.visual {
908916

909917
private static getDateType(dateType: string): number {
910918
switch (dateType) {
919+
case "Second":
920+
return MillisecondsInASecond;
921+
922+
case "Minute":
923+
return MillisecondsInAMinute;
924+
925+
case "Hour":
926+
return MillisecondsInAHour;
927+
911928
case "Day":
912929
return MillisecondsInADay;
913930

@@ -917,6 +934,9 @@ module powerbi.extensibility.visual {
917934
case "Month":
918935
return MillisecondsInAMonth;
919936

937+
case "Quarter":
938+
return MillisecondsInAQuarter;
939+
920940
case "Year":
921941
return MillisecondsInAYear;
922942

src/settings.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
module powerbi.extensibility.visual {
2828
// powerbi.extensibility.utils.dataview
2929
import DataViewObjectsParser = utils.dataview.DataViewObjectsParser;
30-
export type GanttDateType = "Day" | "Week" | "Month" | "Year";
30+
export type DateType = "Second" | "Minute" | "Hour" | "Day" | "Week" | "Month" | "Year";
3131

3232
export class GanttSettings extends DataViewObjectsParser {
3333
general: GeneralSettings = new GeneralSettings();
@@ -79,7 +79,7 @@ module powerbi.extensibility.visual {
7979

8080
export class DateTypeSettings {
8181
// tslint:disable-next-line:no-reserved-keywords
82-
type: GanttDateType = "Week";
82+
type: DateType = "Week";
8383
todayColor: string = "#000000";
8484
axisColor: string = "#000000";
8585
axisTextColor: string = "#000000";

stringResources/en-US/resources.resjson

+11-8
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@
3434
"Visual_DataLabels": "Data Labels",
3535
"Visual_CategoryLabels": "Category Labels",
3636
"Visual_Type": "Type",
37-
"Visual_GanttDateType": "Gantt Date type",
38-
"Visual_GanttDateType_Day": "Day",
39-
"Visual_GanttDateType_Week": "Week",
40-
"Visual_GanttDateType_Month": "Month",
41-
"Visual_GanttDateType_Year": "Year",
42-
"Visual_GanttDateType_TodayColor": "Today color",
43-
"Visual_GanttDateType_AxisColor": "Axis color",
44-
"Visual_GanttDateType_AxisTextColor": "Axis text color"
37+
"Visual_DateType": "Date type",
38+
"Visual_DateType_Second": "Second",
39+
"Visual_DateType_Minute": "Minute",
40+
"Visual_DateType_Hour": "Hour",
41+
"Visual_DateType_Day": "Day",
42+
"Visual_DateType_Week": "Week",
43+
"Visual_DateType_Month": "Month",
44+
"Visual_DateType_Year": "Year",
45+
"Visual_DateType_TodayColor": "Today color",
46+
"Visual_DateType_AxisColor": "Axis color",
47+
"Visual_DateType_AxisTextColor": "Axis text color"
4548
}

test/visualTest.ts

+19-2
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,14 @@ module powerbi.extensibility.visual.test {
4848

4949
import LegendPosition = powerbi.extensibility.utils.chart.legend.LegendPosition;
5050

51-
export enum GanttDateType {
51+
export enum DateTypes {
52+
Second = <any>"Second",
53+
Minute = <any>"Minute",
54+
Hour = <any>"Hour",
5255
Day = <any>"Day",
5356
Week = <any>"Week",
5457
Month = <any>"Month",
58+
Quarter = <any>"Quarter",
5559
Year = <any>"Year"
5660
}
5761

@@ -221,8 +225,21 @@ module powerbi.extensibility.visual.test {
221225
});
222226
});
223227

224-
for (let dateType in GanttDateType) {
228+
for (let dateType in DateTypes) {
225229
it(`Verify date format (${dateType})`, ((dateType) => (done) => {
230+
switch (dateType) {
231+
case "Second":
232+
case "Minute":
233+
case "Hour":
234+
defaultDataViewBuilder.valuesStartDate = GanttData.getRandomUniqueDates(
235+
defaultDataViewBuilder.valuesTaskTypeResource.length,
236+
new Date(2017, 7, 0),
237+
new Date(2017, 7, 1)
238+
);
239+
dataView = defaultDataViewBuilder.getDataView();
240+
break;
241+
}
242+
226243
dataView.metadata.objects = { dateType: { type: dateType } };
227244

228245
visualBuilder.updateRenderTimeout(dataView, () => {

0 commit comments

Comments
 (0)