-
Notifications
You must be signed in to change notification settings - Fork 74
Group tooltips for line chart #1336
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
Merged
+485
−8
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
43b8c32
group tooltips for line chart
Steve-Mcl 9202806
Merge branch 'main' into 1254-tooltip-grouping
Steve-Mcl 71bc0ad
default chart interaction mode to 'nearest' (chartjs default)
Steve-Mcl 321306d
Add support for testtime changes to a fixture
Steve-Mcl 6040f1c
add basic e2e tests for chart options (tooltip mode, legend option)
Steve-Mcl 55c5220
Update ui/src/widgets/ui-chart/UIChart.vue
Steve-Mcl 644938b
Merge branch 'main' into 1254-tooltip-grouping
Steve-Mcl 651754e
ensure interaction axis is cleared for line chart
Steve-Mcl bd924c0
re-do tests to check scatter and bar interaction modes
Steve-Mcl edf2152
fix test spelling of donut!
Steve-Mcl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,210 @@ | ||
| [ | ||
| { | ||
| "id": "chart-1", | ||
| "type": "ui-chart", | ||
| "z": "9524c548fb0b956c", | ||
| "group": "dashboard-ui-group", | ||
| "name": "chart-name", | ||
| "label": "chart-label", | ||
| "order": 2, | ||
| "chartType": "line", | ||
| "category": "", | ||
| "categoryType": "property", | ||
| "xAxisLabel": "", | ||
| "xAxisProperty": "", | ||
| "xAxisPropertyType": "property", | ||
| "xAxisType": "time", | ||
| "xAxisFormat": "", | ||
| "xAxisFormatType": "auto", | ||
| "yAxisLabel": "", | ||
| "yAxisProperty": "", | ||
| "ymin": "", | ||
| "ymax": "", | ||
| "action": "append", | ||
| "stackSeries": false, | ||
| "pointShape": "circle", | ||
| "pointRadius": 4, | ||
| "showLegend": true, | ||
| "removeOlder": 1, | ||
| "removeOlderUnit": "3600", | ||
| "removeOlderPoints": "10", | ||
| "colors": [ | ||
| "#1f77b4", | ||
| "#aec7e8", | ||
| "#ff7f0e", | ||
| "#2ca02c", | ||
| "#98df8a", | ||
| "#d62728", | ||
| "#ff9896", | ||
| "#9467bd", | ||
| "#c5b0d5" | ||
| ], | ||
| "textColor": [ | ||
| "#666666" | ||
| ], | ||
| "textColorDefault": true, | ||
| "gridColor": [ | ||
| "#e5e5e5" | ||
| ], | ||
| "gridColorDefault": true, | ||
| "width": 6, | ||
| "height": "4", | ||
| "className": "", | ||
| "x": 1690, | ||
| "y": 640, | ||
| "wires": [ | ||
| [] | ||
| ] | ||
| }, | ||
| { | ||
| "id": "da1332f160b6a255", | ||
| "type": "inject", | ||
| "z": "9524c548fb0b956c", | ||
| "name": "", | ||
| "props": [ | ||
| { | ||
| "p": "payload" | ||
| }, | ||
| { | ||
| "p": "topic", | ||
| "vt": "str" | ||
| } | ||
| ], | ||
| "repeat": "", | ||
| "crontab": "", | ||
| "once": true, | ||
| "onceDelay": 0.1, | ||
| "topic": "", | ||
| "payload": "[]", | ||
| "payloadType": "json", | ||
| "x": 1490, | ||
| "y": 680, | ||
| "wires": [ | ||
| [ | ||
| "chart-1" | ||
| ] | ||
| ] | ||
| }, | ||
| { | ||
| "id": "13bf93c81c0bd0a7", | ||
| "type": "change", | ||
| "z": "9524c548fb0b956c", | ||
| "name": "rand", | ||
| "rules": [ | ||
| { | ||
| "t": "set", | ||
| "p": "payload", | ||
| "pt": "msg", | ||
| "to": "(\t $minimum := 1;\t $maximum := 10;\t $round(($random() * ($maximum-$minimum)) + $minimum, 0)\t)", | ||
| "tot": "jsonata" | ||
| } | ||
| ], | ||
| "action": "", | ||
| "property": "", | ||
| "from": "", | ||
| "to": "", | ||
| "reg": false, | ||
| "x": 1490, | ||
| "y": 640, | ||
| "wires": [ | ||
| [ | ||
| "chart-1" | ||
| ] | ||
| ] | ||
| }, | ||
| { | ||
| "id": "12a55e898bb4162f", | ||
| "type": "ui-button", | ||
| "z": "9524c548fb0b956c", | ||
| "group": "dashboard-ui-group", | ||
| "name": "random", | ||
| "label": "random", | ||
| "order": 0, | ||
| "width": 0, | ||
| "height": 0, | ||
| "emulateClick": true, | ||
| "tooltip": "", | ||
| "color": "", | ||
| "bgcolor": "", | ||
| "className": "", | ||
| "icon": "", | ||
| "iconPosition": "left", | ||
| "payload": "", | ||
| "payloadType": "date", | ||
| "topic": "topic", | ||
| "topicType": "msg", | ||
| "buttonColor": "", | ||
| "textColor": "", | ||
| "iconColor": "", | ||
| "x": 1340, | ||
| "y": 640, | ||
| "wires": [ | ||
| [ | ||
| "13bf93c81c0bd0a7" | ||
| ] | ||
| ] | ||
| }, | ||
| { | ||
| "id": "dashboard-ui-group", | ||
| "type": "ui-group", | ||
| "name": "Group Name", | ||
| "page": "dashboard-ui-page-1", | ||
| "width": "6", | ||
| "height": "1", | ||
| "order": 1, | ||
| "showTitle": true, | ||
| "className": "", | ||
| "visible": "true", | ||
| "disabled": "false" | ||
| }, | ||
| { | ||
| "id": "dashboard-ui-page-1", | ||
| "type": "ui-page", | ||
| "name": "import demos", | ||
| "ui": "dashboard-ui-base", | ||
| "path": "/page4", | ||
| "icon": "home", | ||
| "layout": "grid", | ||
| "theme": "dashboard-ui-theme", | ||
| "order": 1, | ||
| "className": "", | ||
| "visible": "true", | ||
| "disabled": "false" | ||
| }, | ||
| { | ||
| "id": "dashboard-ui-base", | ||
| "type": "ui-base", | ||
| "name": "base", | ||
| "path": "/dashboard", | ||
| "includeClientData": true, | ||
| "acceptsClientConfig": [ | ||
| "ui-notification", | ||
| "ui-control" | ||
| ], | ||
| "showPathInSidebar": false, | ||
| "navigationStyle": "default", | ||
| "titleBarStyle": "default" | ||
| }, | ||
|
|
||
|
|
||
|
|
||
| { | ||
| "id": "dashboard-ui-theme", | ||
| "type": "ui-theme", | ||
| "name": "Default", | ||
| "colors": { | ||
| "surface": "#ffffff", | ||
| "primary": "#6771f4", | ||
| "bgPage": "#e5dcdc", | ||
| "groupBg": "#ffffff", | ||
| "groupOutline": "#d39292" | ||
| }, | ||
| "sizes": { | ||
| "pagePadding": "6px", | ||
| "groupGap": "12px", | ||
| "groupBorderRadius": "4px", | ||
| "widgetGap": "6px", | ||
| "density": "default" | ||
| } | ||
| } | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| /// <reference types="cypress" /> | ||
| import should from 'should' | ||
|
|
||
| /* eslint-disable cypress/no-unnecessary-waiting */ | ||
| describe('Node/-RED Dashboard 2.0 - Chart Widget - chart options', () => { | ||
| it('resets tooltip mode to "nearest" for bar charts', () => { | ||
| const chartName = 'bar-chart-1' | ||
| const overrides = [ | ||
| { | ||
| id: 'chart-1', // the ID in the base flow fixture (required) | ||
| mode: 'merge', | ||
| data: { | ||
| label: chartName, // set the label | ||
| chartType: 'bar' // change the chart type to bar | ||
| } | ||
| } | ||
| ] | ||
| cy.deployFixture('dashboard-chart-options', overrides) | ||
| cy.visit('/dashboard/page1') | ||
| cy.reload() | ||
|
|
||
| cy.get('#nrdb-ui-widget-chart-1 > div > canvas').should('exist') | ||
| cy.clickAndWait(cy.get('button').contains('random'), 10) | ||
|
|
||
| // eslint-disable-next-line promise/catch-or-return, promise/always-return | ||
| cy.window().then(win => { | ||
| should(win.uiCharts).is.not.empty() | ||
| const barChart = win.uiCharts['chart-1'] | ||
| should(barChart).is.not.empty() | ||
| should(barChart.chart.options.interaction).be.an.Object() | ||
| should(barChart.chart.options.interaction.mode).be.equal('nearest') | ||
| should(barChart.chart.options.interaction.axis).not.equal('x') | ||
| }) | ||
| }) | ||
|
|
||
| it('sets tooltip mode to "index" and axis x for line charts', () => { | ||
| const chartName = 'line-chart-1' | ||
| const overrides = [ | ||
| { | ||
| id: 'chart-1', // the ID in the base flow fixture (required) | ||
| mode: 'merge', | ||
| data: { | ||
| label: chartName, // set the label | ||
| chartType: 'line' // change the chart type to line | ||
| } | ||
| } | ||
| ] | ||
| cy.deployFixture('dashboard-chart-options', overrides) | ||
| cy.visit('/dashboard/page1') | ||
| cy.reload() | ||
|
|
||
| cy.get('#nrdb-ui-widget-chart-1 > div > canvas').should('exist') | ||
| cy.clickAndWait(cy.get('button').contains('random'), 10) | ||
|
|
||
| // eslint-disable-next-line promise/catch-or-return, promise/always-return | ||
| cy.window().then(win => { | ||
| should(win.uiCharts).is.not.empty() | ||
| const lineChart = win.uiCharts['chart-1'] | ||
| should(lineChart).is.not.empty() | ||
| should(lineChart.chart.options.interaction).be.an.Object() | ||
| should(lineChart.chart.options.interaction.mode).be.equal('index') | ||
| should(lineChart.chart.options.interaction.axis).be.equal('x') | ||
| }) | ||
| }) | ||
|
|
||
| it('hides legend when option is unchecked', () => { | ||
| const overrides = [ | ||
| { | ||
| id: 'chart-1', // the ID in the base flow fixture (required) | ||
| mode: 'merge', | ||
| data: { | ||
| label: 'scatter-without-legend', // set the label | ||
| chartType: 'scatter', // change the chart type to scatter | ||
| showLegend: false // hide the legend | ||
| } | ||
| } | ||
| ] | ||
| cy.deployFixture('dashboard-chart-options', overrides) | ||
| cy.visit('/dashboard/page1') | ||
| cy.reload() | ||
|
|
||
| cy.get('#nrdb-ui-widget-chart-1 > div > canvas').should('exist') | ||
| cy.clickAndWait(cy.get('button').contains('random'), 10) | ||
|
|
||
| // eslint-disable-next-line promise/catch-or-return, promise/always-return | ||
| cy.window().then(win => { | ||
| should(win.uiCharts).is.not.empty() | ||
| const barChart = win.uiCharts['chart-1'] | ||
| should(barChart).is.not.empty() | ||
| should(barChart.chart.options.plugins.legend.display).be.false() | ||
| }) | ||
| }) | ||
|
|
||
| it('Shows legend when option is checked', () => { | ||
| const overrides = [ | ||
| { | ||
| id: 'chart-1', // the ID in the base flow fixture (required) | ||
| mode: 'merge', | ||
| data: { | ||
| label: 'scatter-chart-with-legend', // set the label | ||
| chartType: 'scatter', // change the chart type to scatter | ||
| showLegend: true // show the legend | ||
| } | ||
| } | ||
| ] | ||
| cy.deployFixture('dashboard-chart-options', overrides) | ||
| cy.visit('/dashboard/page1') | ||
| cy.reload() | ||
|
|
||
| cy.get('#nrdb-ui-widget-chart-1 > div > canvas').should('exist') | ||
| cy.clickAndWait(cy.get('button').contains('random'), 10) | ||
|
|
||
| // eslint-disable-next-line promise/catch-or-return, promise/always-return | ||
| cy.window().then(win => { | ||
| should(win.uiCharts).is.not.empty() | ||
| const barChart = win.uiCharts['chart-1'] | ||
| should(barChart).is.not.empty() | ||
| should(barChart.chart.options.plugins.legend.display).be.true() | ||
| }) | ||
| }) | ||
| }) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.