Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tool bar above zoom bar and shift-clicking on chart #717

Closed
wants to merge 527 commits into from
Closed
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
527 commits
Select commit Hold shift + click to select a range
8aa950b
feat: update chart brush selection storke to dash
hlyang397 Jul 13, 2020
ad2f115
feat: show tooltip when mouseover zoombar handle
hlyang397 Jul 13, 2020
e903a6a
fix: avoid tick rotation flip during zoom domain changing
hlyang397 Jul 14, 2020
3b7413e
fix: move chart brush selection above all graphs
hlyang397 Jul 14, 2020
d974b60
fix: use another svg to display front selection
hlyang397 Jul 14, 2020
ac6ed57
fix: set cursor for front selection
hlyang397 Jul 14, 2020
fa1ac37
fix: use unique chartClipId for each chart
hlyang397 Jul 16, 2020
80324a2
fix: keep zoom bar handle inside zoom bar range
hlyang397 Jul 16, 2020
3ccef0d
fix: use DOMUtils.appendOrSelect in case the element does not exist yet
hlyang397 Jul 20, 2020
68993ec
feat: allow user to set zoom bar data
hlyang397 Jul 20, 2020
1b0b962
fix: definedZoomBarData needs at least two elements
hlyang397 Jul 21, 2020
93cce4a
fix: axis needs to set opacity if not loading
hlyang397 Jul 21, 2020
eebb780
fix: format zoom bar handle tooltip
hlyang397 Jul 21, 2020
2e76f0a
fix: don't set brush handle tooltip if domain is undefined
hlyang397 Jul 22, 2020
c04d0db
Merge branch 'zoom-bar' of https://github.com/hlyang397/carbon-charts…
JennChao Jul 23, 2020
563f680
feat: initial zoom bar implementation from PR 511
hlyang397 May 27, 2020
1ff4343
fix: update ZoomBar to match new data format
hlyang397 Jun 2, 2020
6845aff
feat: use d3-brush to implement selection
hlyang397 Jun 3, 2020
5efec0d
fix: add left margin to align to chart
hlyang397 Jun 8, 2020
b8d7d38
feat: set brush selection to zoomDomain in Model
hlyang397 Jun 10, 2020
2208434
feat: create ZoomBarOptions and default configuration
hlyang397 Jun 10, 2020
aed57ea
feat: create zoombar story in storybook
hlyang397 Jun 10, 2020
fc1fccc
fix: set tslint trailing-comma to never
hlyang397 Jun 11, 2020
c2c700e
fix: allow zoomDomain to update for every brush event
hlyang397 Jun 11, 2020
d5d512e
feat: provide ZoomBar options for brush event callback
hlyang397 Jun 11, 2020
48a313d
feat: apply clipPath to line chart - v1
JennChao Jun 15, 2020
fd250d5
feat: apply cover to axis chart
JenniferChao-tc Jun 16, 2020
15020af
refactor: clean code
JennChao Jun 16, 2020
fc20325
feat: set axes margins as zoom bar left margin
hlyang397 Jun 16, 2020
22a9478
refactor: add todo
JennChao Jun 16, 2020
feea0d9
fix: double the minTickSize for datetime ticks
hlyang397 Jun 16, 2020
89e8af6
feat: add chart brush
JennChao Jun 18, 2020
b45a8dd
refactor: add brush in axis chart component
JennChao Jun 18, 2020
a803433
refactor: move brush functions to ZoomBar class function
hlyang397 Jun 18, 2020
3c23df6
fix: handel situation of zoom bar selection[0] equals selection[1]
JennChao Jun 19, 2020
4575327
feat: ZoomBar could update brush based on zoomDomain
hlyang397 Jun 19, 2020
c7770e3
fix: handle empty selection
hlyang397 Jun 19, 2020
4f3cc99
fix: set to default full range when same selection of brush
JennChao Jun 19, 2020
85b056e
fix: fix bug when selection === null
hlyang397 Jun 19, 2020
604577e
feat: add ZoomBarOptions.initZoomDomain
hlyang397 Jun 19, 2020
75c8d36
feat: create Zoombar storybook demo group
hlyang397 Jun 20, 2020
338f298
fix: apply cover to stacked bar
JennChao Jun 23, 2020
708a1cb
feat: create ZoomBar event and handler
hlyang397 Jun 24, 2020
e71c7db
fix: fix merge error
hlyang397 Jun 24, 2020
beefd10
feat: update color for non-highlighted areas
hlyang397 Jun 29, 2020
ed3bf3f
fix: avoid extra brush handle update
hlyang397 Jun 29, 2020
a753521
fix: fix the brush handle style
hlyang397 Jun 29, 2020
7d2a57a
refactor: remove unnecessary svg.brush-container
hlyang397 Jun 30, 2020
9373977
fix: move brush layer to back to allow tooltips in graph
hlyang397 Jun 30, 2020
8247969
feat: add stacked-area chart with zoom bar in storybook
hlyang397 Jun 30, 2020
c8f3f2e
refactor: delete unused axis-zoom service
hlyang397 Jul 1, 2020
874e7c2
feat: allow addSpaceOnEdges to work with zoom bar
hlyang397 Jul 1, 2020
4fd15a0
refactor: code refactoring
hlyang397 Jul 1, 2020
7a23808
fix: display multiline tooltip with zoom bar
hlyang397 Jul 1, 2020
9359888
feat: create ZoomBarOptions and default configuration
hlyang397 Jun 10, 2020
529ecb5
fix: chart brush with correct range
JennChao Jul 2, 2020
af8519c
fix: remove graph out of zoom domain
hlyang397 Jul 2, 2020
1dbd716
refactor: code refactoring
hlyang397 Jul 3, 2020
ca01a85
fix: set min selection difference threshold
hlyang397 Jul 3, 2020
bf98e62
refactor: code refactoring
hlyang397 Jul 3, 2020
8faf441
fix: avoid extra/duplicate external callback
hlyang397 Jul 6, 2020
d1a0697
fix: remove ZoomBarOptions in BaseChartOptions
hlyang397 Jul 7, 2020
5a1372e
refactor: change initZoomDomain to initialZoomDomain
hlyang397 Jul 9, 2020
f5574f6
refactor: use Tools.getProperty to load zoomBarOptions
hlyang397 Jul 9, 2020
fad73e6
refactor: update code format
hlyang397 Jul 9, 2020
7b83c72
refactor: use Tools.getProperty to get initialZoomDomain
hlyang397 Jul 9, 2020
4e6097e
refactor: Change Cover to ChartClip
hlyang397 Jul 10, 2020
6604563
refactor: Change Brush to ChartBrush
hlyang397 Jul 10, 2020
4b2bcce
refactor: set model.set() function default config
hlyang397 Jul 10, 2020
b4399d9
fix: remove unnecessary selector
hlyang397 Jul 10, 2020
53d1ee2
refactor: create reusable getMainXScaleType()
hlyang397 Jul 10, 2020
5826383
refactor: make sure zoom bar only shows with supported options
hlyang397 Jul 10, 2020
877c013
refactor: set clip-path url in containerSVG
hlyang397 Jul 10, 2020
b7239cd
refactor: dispatch zoombar selection events instead of callback
hlyang397 Jul 13, 2020
8a94716
feat: update chart brush selection storke to dash
hlyang397 Jul 13, 2020
21d2d28
feat: show tooltip when mouseover zoombar handle
hlyang397 Jul 13, 2020
d3483b1
fix: avoid tick rotation flip during zoom domain changing
hlyang397 Jul 14, 2020
7821866
fix: move chart brush selection above all graphs
hlyang397 Jul 14, 2020
274799d
fix: use another svg to display front selection
hlyang397 Jul 14, 2020
df80f1c
fix: set cursor for front selection
hlyang397 Jul 14, 2020
e74427f
fix: use unique chartClipId for each chart
hlyang397 Jul 16, 2020
e05fc0c
fix: keep zoom bar handle inside zoom bar range
hlyang397 Jul 16, 2020
e25b8a3
fix: use DOMUtils.appendOrSelect in case the element does not exist yet
hlyang397 Jul 20, 2020
3cdad63
feat: allow user to set zoom bar data
hlyang397 Jul 20, 2020
55c4fa2
fix: definedZoomBarData needs at least two elements
hlyang397 Jul 21, 2020
20a3dca
fix: axis needs to set opacity if not loading
hlyang397 Jul 21, 2020
a1252ba
fix: format zoom bar handle tooltip
hlyang397 Jul 21, 2020
3f3092d
fix: don't set brush handle tooltip if domain is undefined
hlyang397 Jul 22, 2020
9b34ff6
Merge branch 'zoom-bar' of https://github.com/hlyang397/carbon-charts…
JennChao Jul 28, 2020
6eb41d2
fix: filter out invalid domain value to avoid exception
hlyang397 Jul 28, 2020
9388463
Merge branch 'zoom-bar' of https://github.com/hlyang397/carbon-charts…
JennChao Jul 28, 2020
a01f087
fix: zoomDomain event and overflow menu option position
JennChao Jul 28, 2020
3ece1ba
fix: dispatch zoomDomain event when event type equals to end
JennChao Jul 28, 2020
0fd3d07
feat: initial zoom bar implementation from PR 511
hlyang397 May 27, 2020
114dbee
fix: update ZoomBar to match new data format
hlyang397 Jun 2, 2020
30fc426
feat: use d3-brush to implement selection
hlyang397 Jun 3, 2020
384cd30
fix: add left margin to align to chart
hlyang397 Jun 8, 2020
1ee5869
feat: set brush selection to zoomDomain in Model
hlyang397 Jun 10, 2020
5927de0
feat: create ZoomBarOptions and default configuration
hlyang397 Jun 10, 2020
b381d2d
feat: create zoombar story in storybook
hlyang397 Jun 10, 2020
481b0f3
fix: set tslint trailing-comma to never
hlyang397 Jun 11, 2020
98e7749
fix: allow zoomDomain to update for every brush event
hlyang397 Jun 11, 2020
8929eed
feat: provide ZoomBar options for brush event callback
hlyang397 Jun 11, 2020
f947ec9
feat: apply clipPath to line chart - v1
JennChao Jun 15, 2020
cf42561
feat: apply cover to axis chart
JenniferChao-tc Jun 16, 2020
0b50223
refactor: clean code
JennChao Jun 16, 2020
7b8e17e
feat: set axes margins as zoom bar left margin
hlyang397 Jun 16, 2020
f6f685a
refactor: add todo
JennChao Jun 16, 2020
d973aeb
fix: double the minTickSize for datetime ticks
hlyang397 Jun 16, 2020
868b8a3
feat: add chart brush
JennChao Jun 18, 2020
c5dec99
refactor: add brush in axis chart component
JennChao Jun 18, 2020
27e00e3
refactor: move brush functions to ZoomBar class function
hlyang397 Jun 18, 2020
c486eb9
fix: handel situation of zoom bar selection[0] equals selection[1]
JennChao Jun 19, 2020
baba478
feat: ZoomBar could update brush based on zoomDomain
hlyang397 Jun 19, 2020
c46af66
fix: handle empty selection
hlyang397 Jun 19, 2020
c442885
fix: set to default full range when same selection of brush
JennChao Jun 19, 2020
8259517
fix: fix bug when selection === null
hlyang397 Jun 19, 2020
8755c86
feat: add ZoomBarOptions.initZoomDomain
hlyang397 Jun 19, 2020
ee50ab6
feat: create Zoombar storybook demo group
hlyang397 Jun 20, 2020
c4c3613
fix: apply cover to stacked bar
JennChao Jun 23, 2020
0b0c407
feat: create ZoomBar event and handler
hlyang397 Jun 24, 2020
a3a1291
fix: fix merge error
hlyang397 Jun 24, 2020
9a767b6
feat: update color for non-highlighted areas
hlyang397 Jun 29, 2020
b749d99
fix: avoid extra brush handle update
hlyang397 Jun 29, 2020
2df63ff
fix: fix the brush handle style
hlyang397 Jun 29, 2020
1095fc4
refactor: remove unnecessary svg.brush-container
hlyang397 Jun 30, 2020
0c1501e
fix: move brush layer to back to allow tooltips in graph
hlyang397 Jun 30, 2020
8c8c598
feat: add stacked-area chart with zoom bar in storybook
hlyang397 Jun 30, 2020
0b7eea7
refactor: delete unused axis-zoom service
hlyang397 Jul 1, 2020
74bf969
feat: allow addSpaceOnEdges to work with zoom bar
hlyang397 Jul 1, 2020
2326608
refactor: code refactoring
hlyang397 Jul 1, 2020
bcfdbd9
fix: display multiline tooltip with zoom bar
hlyang397 Jul 1, 2020
aa437b8
feat: create ZoomBarOptions and default configuration
hlyang397 Jun 10, 2020
278e5e2
fix: chart brush with correct range
JennChao Jul 2, 2020
fac1a44
fix: remove graph out of zoom domain
hlyang397 Jul 2, 2020
4465f27
refactor: code refactoring
hlyang397 Jul 3, 2020
79f912b
fix: set min selection difference threshold
hlyang397 Jul 3, 2020
6d8a6a8
refactor: code refactoring
hlyang397 Jul 3, 2020
b17b390
fix: avoid extra/duplicate external callback
hlyang397 Jul 6, 2020
60afec8
fix: remove ZoomBarOptions in BaseChartOptions
hlyang397 Jul 7, 2020
fd032a9
refactor: change initZoomDomain to initialZoomDomain
hlyang397 Jul 9, 2020
5a9cc62
refactor: use Tools.getProperty to load zoomBarOptions
hlyang397 Jul 9, 2020
826ee56
refactor: update code format
hlyang397 Jul 9, 2020
dfbf0df
refactor: use Tools.getProperty to get initialZoomDomain
hlyang397 Jul 9, 2020
5a7c898
refactor: Change Cover to ChartClip
hlyang397 Jul 10, 2020
767af06
refactor: Change Brush to ChartBrush
hlyang397 Jul 10, 2020
a1da889
refactor: set model.set() function default config
hlyang397 Jul 10, 2020
7ea54d2
fix: remove unnecessary selector
hlyang397 Jul 10, 2020
8a54d4f
refactor: create reusable getMainXScaleType()
hlyang397 Jul 10, 2020
6b66c77
refactor: make sure zoom bar only shows with supported options
hlyang397 Jul 10, 2020
51cd780
refactor: set clip-path url in containerSVG
hlyang397 Jul 10, 2020
2bbd953
refactor: dispatch zoombar selection events instead of callback
hlyang397 Jul 13, 2020
3f8eebd
feat: update chart brush selection storke to dash
hlyang397 Jul 13, 2020
310471f
feat: show tooltip when mouseover zoombar handle
hlyang397 Jul 13, 2020
39c22d9
fix: avoid tick rotation flip during zoom domain changing
hlyang397 Jul 14, 2020
25c7298
fix: move chart brush selection above all graphs
hlyang397 Jul 14, 2020
15fe502
fix: use another svg to display front selection
hlyang397 Jul 14, 2020
88ccc92
fix: set cursor for front selection
hlyang397 Jul 14, 2020
21cfda4
fix: use unique chartClipId for each chart
hlyang397 Jul 16, 2020
82d336e
fix: keep zoom bar handle inside zoom bar range
hlyang397 Jul 16, 2020
fd51108
fix: use DOMUtils.appendOrSelect in case the element does not exist yet
hlyang397 Jul 20, 2020
62c6f23
feat: allow user to set zoom bar data
hlyang397 Jul 20, 2020
c9ad27d
fix: definedZoomBarData needs at least two elements
hlyang397 Jul 21, 2020
731c973
fix: axis needs to set opacity if not loading
hlyang397 Jul 21, 2020
819bcd8
fix: format zoom bar handle tooltip
hlyang397 Jul 21, 2020
1f94df4
fix: don't set brush handle tooltip if domain is undefined
hlyang397 Jul 22, 2020
16c3736
fix: filter out invalid domain value to avoid exception
hlyang397 Jul 28, 2020
60b4266
fix: never out of zoom domain if only one bar in chart
hlyang397 Jul 29, 2020
5c218c2
fix: don't set zoomDomain to invalid value
hlyang397 Jul 29, 2020
8267039
Merge branch 'zoom-bar' of https://github.com/hlyang397/carbon-charts…
JennChao Jul 29, 2020
afd99ed
fix: toolbar icon hover style and zoomDomain undefined issue
JennChao Jul 29, 2020
a881220
refactor code
theiliad Jul 29, 2020
2410b31
format
theiliad Jul 29, 2020
a426d4d
Merge branch 'master' of github.com:carbon-design-system/carbon-chart…
theiliad Jul 29, 2020
5053075
Merge branch 'zoom-bar' of github.com:hlyang397/carbon-charts into zo…
theiliad Jul 29, 2020
a4b6e3d
fix: toolbar icon hover style
JennChao Jul 30, 2020
f079264
refactor: add comment for px calculation
JennChao Jul 30, 2020
a786d12
refactor: toolBar height and spacerHeight
JennChao Jul 30, 2020
369fda7
refactor: add toolBarOptions interface with overflow menu options array
JennChao Jul 30, 2020
24e6721
refactor: use class instead of id for applying style
JennChao Jul 30, 2020
5e3c12e
feat: add zoom bar skeleton and demo
hlyang397 Jul 30, 2020
9b1e851
refactor: use class instead of id for applying style
JennChao Jul 30, 2020
7543850
Merge branch 'zoom-bar' of https://github.com/hlyang397/carbon-charts…
JennChao Jul 30, 2020
b4e4304
fix: set width and height to rect not with css
JennChao Jul 30, 2020
e11c0e8
refactor: update interface naming
JennChao Jul 30, 2020
ae56130
fix: tool bar height set to 30px when loading
JennChao Jul 30, 2020
ff3b006
Merge branch 'master' of https://github.com/hlyang397/carbon-charts i…
JennChao Jul 31, 2020
ed35d47
fix: hide zoom bar handle if selection is invalid
hlyang397 Aug 1, 2020
78c7216
fix: not set zoom domain to invalid value
hlyang397 Aug 1, 2020
6580558
feat: render zoombar skeleton while loading
hlyang397 Aug 1, 2020
1ae7f65
refactor: handle zoom in and zoom out event
JennChao Aug 3, 2020
9807801
fix: overflow menu option position issue and hover fill issue
JennChao Aug 3, 2020
4d01a2e
fix: some options need assignment instead of merge
hlyang397 Aug 4, 2020
92d2d95
fix: some options need assignment instead of merge
hlyang397 Aug 4, 2020
43b84c9
fix: keep default zoom bar domain for future data changes
hlyang397 Aug 5, 2020
2cc538f
fix: tool bar position
JennChao Aug 5, 2020
cd77fd3
fix: tool bar loading spacer height issue
JennChao Aug 5, 2020
fe16282
fix: overflow menu option position issue and hover fill issue
JennChao Aug 5, 2020
77439e2
fix: attr hidden value
JennChao Aug 5, 2020
a5767ee
fix: show toolbar when there is no title
JennChao Aug 5, 2020
23833a7
fix: put a spacer in toolbar for loading state
hlyang397 Aug 5, 2020
29d292b
fix: avoid duplicate spacer
hlyang397 Aug 5, 2020
77a511c
refactor: tool bar icon size naming
JennChao Aug 5, 2020
57eebda
fix: the spacer should be invisible
hlyang397 Aug 5, 2020
1d9348f
fix: need a smaller title spacer if toolbar enabled
hlyang397 Aug 5, 2020
e95e964
refactor: isZoomBarEnabled(), isToolbarEnabled() in zoom service
hlyang397 Aug 5, 2020
5278029
fix: white theme demo broken issue
JennChao Aug 5, 2020
4c6f0ec
refactor: isZoomBarEnabled(), isToolbarEnabled() in zoom service
hlyang397 Aug 6, 2020
de5d8d5
refactor: code refactoring
JennChao Aug 6, 2020
a830e42
refactor: use this instead of self
JennChao Aug 6, 2020
87afa1b
feat: disable zoom bar with empty data state
hlyang397 Aug 6, 2020
dc533a7
refactor: code refactor
JennChao Aug 7, 2020
925b9b4
refactor: code refactor
JennChao Aug 7, 2020
247f2cf
fix: allow zoom bar area chart with one data point
hlyang397 Aug 7, 2020
0af7b5b
feat: clear d3 brush if loading or empty state
hlyang397 Aug 7, 2020
d1298df
refactor: refactor code and update code style
hlyang397 Aug 7, 2020
82746d9
fix: allow zoom bar data to use string type date
hlyang397 Aug 7, 2020
a4c5489
Merge branch 'master' of github.com:carbon-design-system/carbon-chart…
hlyang397 Aug 7, 2020
69fe6f2
fix: stop rendering if parent size is 0
hlyang397 Aug 7, 2020
10d9604
fix: stop rendering if parent size is 0
hlyang397 Aug 7, 2020
b5bdb9c
fix: remove redundant ChartClip in charts
hlyang397 Aug 9, 2020
20627d7
refactor: reuse setDomain()
hlyang397 Aug 9, 2020
53e62c6
refactor: remove getDefaultZoomBarDomain()
hlyang397 Aug 9, 2020
cd3fbaa
fix: allow layout component to render even 0 parent element size
hlyang397 Aug 9, 2020
50a9137
feat: separate toolbar options from zoom bar options
hlyang397 Aug 9, 2020
a734ef0
refactor: use Layout component to layout ToolBar component
hlyang397 Aug 9, 2020
b9d0398
refactor: move getZoomRatio() into zoom service
hlyang397 Aug 10, 2020
be16376
refactor: refactor ToolBar Component
hlyang397 Aug 10, 2020
b9be31d
refactor: remove unnecessary css style
hlyang397 Aug 10, 2020
5ebf4a8
refactor: calculation of overflow menu options position
hlyang397 Aug 10, 2020
3eaade9
fix: fix zoom bar handle display error at edge
hlyang397 Aug 10, 2020
94e05e0
fix: don't show zoom feature in empty state
hlyang397 Aug 10, 2020
bc342d7
refactor: update per comments
hlyang397 Aug 11, 2020
1e6ff2a
refactor: remove duplicate zoom service binding
hlyang397 Aug 11, 2020
ba21aeb
refactor: update per comment
hlyang397 Aug 11, 2020
ad2c4fb
refactor: remove setOverflowMenuIconHover()
hlyang397 Aug 11, 2020
a956942
refactor: make all overflow icon, menu, item variable names consistent
hlyang397 Aug 11, 2020
d979d09
refactor: refactor overflow menu (items) html generation framework
hlyang397 Aug 11, 2020
c3d15a6
fix: hide overflow icon if no overflow menu item
hlyang397 Aug 11, 2020
e4e07b9
refactor: change defaultZoomBarDomain to initialZoomBarDomain
hlyang397 Aug 11, 2020
4594c1b
refactor: move addEventListener to init() to avoid duplication
hlyang397 Aug 11, 2020
f1b5747
Merge branch 'master' into tool-bar
hlyang397 Aug 12, 2020
fa0f2fe
fix: keep title component if toolbar is enabled for alignment
hlyang397 Aug 12, 2020
a4060bb
Merge branch 'master' into tool-bar
hlyang397 Aug 13, 2020
2b07934
Merge branch 'master' into tool-bar
Aug 13, 2020
9732c8a
feat: change zoom bar handle cursor from "pointer" to "ew-resize"
hlyang397 Aug 14, 2020
61f3f76
Merge branch 'master' of github.com:carbon-design-system/carbon-chart…
hlyang397 Aug 15, 2020
bc597f1
feat: provide option to refresh range axis label
hlyang397 Aug 16, 2020
a2832f8
Merge branch 'master' into toolbar
JennChao Aug 26, 2020
0bee757
fix: duplicated import
JennChao Aug 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ All notable changes to this project will be documented in this file. See

### Bug Fixes

- fix pie chart alignment
([#716](https://github.com/carbon-design-system/carbon-charts/issues/716))
([638c331](https://github.com/carbon-design-system/carbon-charts/commit/638c331b7fa8fbc73cf557cf99a6b3af2435b492))
* fix pie chart alignment ([#716](https://github.com/carbon-design-system/carbon-charts/issues/716)) ([638c331](https://github.com/carbon-design-system/carbon-charts/commit/638c331b7fa8fbc73cf557cf99a6b3af2435b492))





# Change Log

Expand Down
6 changes: 6 additions & 0 deletions packages/core/demo/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,12 @@ let allDemoGroups = [
chartType: chartTypes.LineChart,
isDemoExample: false
},
{
options: zoomBarDemos.zoomBarEmptyStateOptions,
data: zoomBarDemos.zoomBarEmptyStateData,
chartType: chartTypes.StackedBarChart,
isDemoExample: false
},
{
options: zoomBarDemos.zoomBarSkeletonOptions,
data: zoomBarDemos.zoomBarSkeletonData,
Expand Down
16 changes: 16 additions & 0 deletions packages/core/demo/data/zoom-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ const definedZoomBarData = [
{ date: new Date(2019, 0, 19), value: 21300 }
];

const defaultToolBarOptions = {
enabled: true,
overflowMenuItems: {
resetZoom: {
enabled: true
}
}
};

// utility function to update title and enable zoomBar option
const addZoomBarToOptions = (options, includeDefinedZoomBarData = false) => {
options["experimental"] = true;
Expand All @@ -43,6 +52,7 @@ const addZoomBarToOptions = (options, includeDefinedZoomBarData = false) => {
}
};
}
options["toolbar"] = defaultToolBarOptions;
return options;
};

Expand Down Expand Up @@ -104,6 +114,12 @@ export const zoomBarLineTimeSeriesInitDomainOptions = addZoomBarToOptions(
zoomBarLineTimeSeriesInitDomainOptions["title"] += " (initial zoomed domain)";
zoomBarLineTimeSeriesInitDomainOptions.zoomBar.top.initialZoomDomain = initialZoomDomain;

export const zoomBarEmptyStateData = barChart.stackedBarEmptyStateData;
export const zoomBarEmptyStateOptions = addZoomBarToOptions(
Object.assign({}, barChart.stackedBarTimeSeriesOptions)
);
zoomBarEmptyStateOptions["title"] = "Zoom bar (empty state)";

// assume no data set while loading is true
export const zoomBarSkeletonData = [];
export const zoomBarSkeletonOptions = addZoomBarToOptions(
Expand Down
70 changes: 47 additions & 23 deletions packages/core/src/axis-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import {
LegendOrientations,
LegendPositions,
ChartConfig,
AxisChartOptions,
AxisPositions,
ScaleTypes
AxisChartOptions
} from "./interfaces";
import {
ChartBrush,
Expand All @@ -17,8 +15,9 @@ import {
Title,
AxisChartsTooltip,
Spacer,
Toolbar,
ZoomBar
} from "./components";
} from "./components/index";
import { Tools } from "./tools";

import { CartesianScales, Curves, Zoom } from "./services";
Expand All @@ -35,30 +34,49 @@ export class AxisChart extends Chart {
}

protected getAxisChartComponents(graphFrameComponents: any[]) {
const isZoomBarEnabled = Tools.getProperty(
const zoomBarEnabled = this.services.zoom.isZoomBarEnabled();

const toolbarEnabled = Tools.getProperty(
this.model.getOptions(),
"zoomBar",
"top",
"toolbar",
"enabled"
);

this.services.cartesianScales.findDomainAndRangeAxes(); // need to do this before getMainXAxisPosition()
const mainXAxisPosition = this.services.cartesianScales.getMainXAxisPosition();
const mainXScaleType = Tools.getProperty(
this.model.getOptions(),
"axes",
mainXAxisPosition,
"scaleType"
);
// @todo - Zoom Bar only supports main axis at BOTTOM axis and time scale for now
const zoomBarEnabled =
isZoomBarEnabled &&
mainXAxisPosition === AxisPositions.BOTTOM &&
mainXScaleType === ScaleTypes.TIME;
const titleAvailable = !!this.model.getOptions().title;

const titleComponent = {
id: "title",
components: [new Title(this.model, this.services)],
growth: {
x: LayoutGrowth.STRETCH,
y: LayoutGrowth.FIXED
}
};

const toolbarComponent = {
id: "toolbar",
components: [new Toolbar(this.model, this.services)],
growth: {
x: LayoutGrowth.PREFERRED,
y: LayoutGrowth.FIXED
}
};

const headerComponent = {
id: "header",
components: [
new LayoutComponent(
this.model,
this.services,
[
...(titleAvailable ? [titleComponent] : []),
...(toolbarEnabled ? [toolbarComponent] : [])
],
{
direction: LayoutDirection.ROW
}
)
],
growth: {
x: LayoutGrowth.PREFERRED,
y: LayoutGrowth.FIXED
Expand Down Expand Up @@ -168,12 +186,18 @@ export class AxisChart extends Chart {

// Add chart title if it exists
const topLevelLayoutComponents = [];
if (this.model.getOptions().title) {
topLevelLayoutComponents.push(titleComponent);
if (titleAvailable || toolbarEnabled) {
topLevelLayoutComponents.push(headerComponent);

const titleSpacerComponent = {
id: "spacer",
components: [new Spacer(this.model, this.services)],
components: [
new Spacer(
this.model,
this.services,
toolbarEnabled ? { size: 10 } : undefined
)
],
growth: {
x: LayoutGrowth.PREFERRED,
y: LayoutGrowth.FIXED
Expand Down
111 changes: 82 additions & 29 deletions packages/core/src/components/axes/grid-brush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import { Component } from "../component";
import { Events, ScaleTypes } from "../../interfaces";
import { DOMUtils } from "../../services";
import { Tools } from "../../tools";

// D3 Imports
import { brushX } from "d3-brush";
import { event } from "d3-selection";
import { event, mouse } from "d3-selection";
import { scaleTime } from "d3-scale";

// This class is used for handle brush events in chart
Expand All @@ -19,6 +20,8 @@ export class ChartBrush extends Component {
frontSelectionSelector = "rect.frontSelection"; // needs to match the class name in _grid-brush.scss

render(animate = true) {
const zoomRatio = this.services.zoom.getZoomRatio();

const svg = this.parent;
// use this area to display selection above all graphs
const frontSelectionArea = this.getContainerSVG();
Expand All @@ -29,6 +32,14 @@ export class ChartBrush extends Component {
// use this area to handle d3 brush events
const brushArea = DOMUtils.appendOrSelect(backdrop, `g.${this.type}`);

if (
this.services.zoom.isDataLoading() ||
this.services.zoom.isEmptyState()
) {
brushArea.html(null);
return;
}

// set an id for rect.selection to be referred
const d3Selection = DOMUtils.appendOrSelect(
brushArea,
Expand All @@ -38,8 +49,17 @@ export class ChartBrush extends Component {
const { width, height } = DOMUtils.getSVGElementSize(backdrop, {
useAttrs: true
});
// initialization is not completed yet
if (width === 0 || height === 0) {
return;
}

const { cartesianScales } = this.services;
let axesLeftMargin = 0;
const axesMargins = this.model.get("axesMargins");
if (axesMargins && axesMargins.left) {
axesLeftMargin = axesMargins.left;
}
const mainXScaleType = cartesianScales.getMainXScaleType();
const mainXScale = cartesianScales.getMainXScale();
const [xScaleStart, xScaleEnd] = mainXScale.range();
Expand All @@ -49,13 +69,19 @@ export class ChartBrush extends Component {
this.frontSelectionSelector
);

const setDomain = (newDomain) => {
this.model.set({ zoomDomain: newDomain }, { animate: false });
};

if (mainXScale && mainXScaleType === ScaleTypes.TIME) {
// get current zoomDomain
let zoomDomain = this.model.get("zoomDomain");
if (zoomDomain === undefined) {
// default to full range with extended domain
zoomDomain = this.services.zoom.getDefaultZoomBarDomain();
this.model.set({ zoomDomain: zoomDomain }, { animate: false });
if (zoomDomain) {
setDomain(zoomDomain);
}
}

const updateSelectionDash = (selection) => {
Expand Down Expand Up @@ -127,37 +153,44 @@ export class ChartBrush extends Component {
});
}
};

const handleZoomDomain = (startPoint, endPoint) => {
// create xScale based on current zoomDomain
const xScale = scaleTime()
.range([axesLeftMargin, width])
.domain(zoomDomain);

let newDomain = [
xScale.invert(startPoint),
xScale.invert(endPoint)
];

// if selected start time and end time are the same
// reset to default full range
if (newDomain[0].valueOf() === newDomain[1].valueOf()) {
// same as d3 behavior and zoom bar behavior: set to default full range
newDomain = this.services.zoom.getDefaultZoomBarDomain();
}

// only if zoomDomain needs update
if (
zoomDomain[0].valueOf() !== newDomain[0].valueOf() ||
zoomDomain[1].valueOf() !== newDomain[1].valueOf()
) {
// only dispatch zoom domain change event for triggering api call when event type equals to end
this.services.events.dispatchEvent(
Events.ZoomDomain.CHANGE,
{ newDomain }
);
setDomain(newDomain);
}
};

const brushed = () => {
const selection = event.selection;

if (selection !== null) {
// create xScale based on current zoomDomain
const xScale = scaleTime()
.range([0, width])
.domain(zoomDomain);

let newDomain = [
xScale.invert(selection[0]),
xScale.invert(selection[1])
];

// if selected start time and end time are the same
// reset to default full range
if (newDomain[0].valueOf() === newDomain[1].valueOf()) {
// same as d3 behavior and zoom bar behavior: set to default full range
newDomain = this.services.zoom.getDefaultZoomBarDomain();
}

// only if zoomDomain needs update
if (
zoomDomain[0].valueOf() !== newDomain[0].valueOf() ||
zoomDomain[1].valueOf() !== newDomain[1].valueOf()
) {
this.model.set(
{ zoomDomain: newDomain },
{ animate: false }
);
}
handleZoomDomain(selection[0], selection[1]);

// clear brush selection
brushArea.call(brush.move, null);
Expand All @@ -176,6 +209,26 @@ export class ChartBrush extends Component {
.on("end.brushed", brushed);

brushArea.call(brush);

backdrop.on("click", function () {
if (event.shiftKey) {
const coords = mouse(this);
const currentClickLocation = coords[0] - axesLeftMargin;

let leftPoint =
currentClickLocation - (width * zoomRatio) / 2;
if (leftPoint < 0) {
leftPoint = 0;
}
let rightPoint =
currentClickLocation + (width * zoomRatio) / 2;
if (rightPoint > width) {
rightPoint = width;
}

handleZoomDomain(leftPoint, rightPoint);
}
});
}
}
}
Loading