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

feat: enable chart grid enable option #761

Merged
merged 12 commits into from
Sep 10, 2020

Conversation

JennChao
Copy link
Contributor

Updates

Sometimes user might not want to see chart grid. This PR provide the option of showing or not showing chart grid.

Demo screenshot or recording

圖片

Review checklist (for reviewers only)

  • Demos all features
  • Documented/annotated
  • Matches UI/UX specs
  • Meets the code style guide
  • Accessible
  • Mobile first (responsive)
  • RTL support (bidirectional text)
  • Performant (limited bloat)

@JennChao JennChao requested review from natashadecoste, theiliad and a team as code owners August 25, 2020 06:46
@JennChao JennChao requested review from zvonimirfras and removed request for a team August 25, 2020 06:46
Copy link
Member

@theiliad theiliad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably allow individual grid enablement flags...

e.g. x is active but y is disabled

@@ -15,7 +15,7 @@ export class Grid extends Component {
const gridEnable = Tools.getProperty(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const gridEnable = Tools.getProperty(
const isGridEnabled = Tools.getProperty(

@@ -15,7 +15,7 @@ export class Grid extends Component {
const gridEnable = Tools.getProperty(
this.model.getOptions(),
"grid",
"enable"
"enabled"
);
if (!gridEnable) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!gridEnable) {
if (!gridEnable) {

@@ -62,7 +62,7 @@ const legend: LegendOptions = {
*/
export const grid: GridOptions = {
// set enable to false will not draw grid and stroke of grid backdrop
enable: true,
enabled: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grid cannot be disabled by default

} @else {
fill: $ui-background;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this extra classname?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why we need chart-grid-backdrop-no-stroke classname is because we don't want to apply stroke around the chart when there is no grid line.

@JennChao
Copy link
Contributor Author

we should probably allow individual grid enablement flags...

e.g. x is active but y is disabled

x grid and y grid can now be enabled or disabled separately

@JennChao JennChao requested a review from theiliad August 26, 2020 02:57
Comment on lines 64 to 67
// set enable to false will not draw grid and stroke of grid backdrop
xGridEnabled: true,
yGridEnabled: true,

Copy link
Contributor

@natashadecoste natashadecoste Sep 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this should go within the x and y configurations like this

grid:{ 
    x: {
      enabled: true,
      numberOfTicks: 15
    },
    y: {
      enabled: true,
      numberOfTicks: 15
    }
}

or maybe "visible" is a better word... since its still enabled/functional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on @theiliad 's input. I will use "enabled".

Copy link
Member

@theiliad theiliad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi 👋

Please include some more demos and screenshots so we can see this in action when reviewing, thanks.

@@ -85,9 +85,11 @@ export interface ThresholdOptions {

export interface GridOptions {
y?: {
yGridEnabled?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, we always will want to keep things consistent by using enabled

"rect.chart-grid-backdrop"
this.isXGridEnabled || this.isYGridEnabled
? "rect.chart-grid-backdrop.stroke"
: "rect.chart-grid-backdrop"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like stroke should be a separate configurable no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

圖片

A chart with grid but without stroke looks kind of weird. So I guess we would always want to add stroke when there is grid being enabled. And when there is no grid being enabled, we can let the user setup the option to disable stroke? What do you think?

With stroke.
圖片

Without stroke.
圖片

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I think stroke might be something we'd always want to keep unless overriden

@jeanservaas could you please chime in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @theiliad and @jeanservaas,
There is the situation when we don't want to show the stroke.
圖片

@@ -7,6 +7,8 @@
} @else {
fill: $ui-background;
}
}
rect.stroke {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rect.stroke {
rect.chart-grid-backdrop.stroked {

@@ -231,7 +243,9 @@ export class Ruler extends Component {
this.backdrop = DOMUtils.appendOrSelect(svg, "svg.chart-grid-backdrop");
const backdropRect = DOMUtils.appendOrSelect(
this.backdrop,
"rect.chart-grid-backdrop"
this.isXGridEnabled || this.isYGridEnabled
? "rect.chart-grid-backdrop.stroke"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
? "rect.chart-grid-backdrop.stroke"
? "rect.chart-grid-backdrop.stroked"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again my feedback here still applies. seems like Ruler doesn't need to style the backdrop, just needs to grab it.

this piece seems to be in there by mistake from our previous commits.

Are you able to remove all the styling pieces for the backdrop from Ruler and test whether things still work? We should remove any of it that doesn't break charts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the code for styling backdrop in Ruler component has already been done in #765

@@ -197,7 +218,9 @@ export class Grid extends Component {
this.backdrop = DOMUtils.appendOrSelect(svg, "svg.chart-grid-backdrop");
const backdropRect = DOMUtils.appendOrSelect(
this.backdrop,
"rect.chart-grid-backdrop"
isXGridEnabled || isYGridEnabled
? "rect.chart-grid-backdrop.stroke"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
? "rect.chart-grid-backdrop.stroke"
? "rect.chart-grid-backdrop.stroked"

@JennChao JennChao requested a review from theiliad September 7, 2020 08:10
@theiliad theiliad merged commit dc4087b into carbon-design-system:master Sep 10, 2020
JennChao added a commit to JennChao/carbon-charts that referenced this pull request Sep 11, 2020
…to ruler-option

* 'master' of https://github.com/JennChao/carbon-charts:
  v0.36.4
  Merge pull request carbon-design-system#761 from JennChao/sparkline
  Merge pull request carbon-design-system#793 from hlyang397/update-initial-zoom-domain
  fix the defect of label tooltip not showing when using custom tooltip (carbon-design-system#787)
  v0.36.3
  Merge pull request carbon-design-system#785 from sophiiae/skeleton-with-data
JennChao added a commit to JennChao/carbon-charts that referenced this pull request Sep 11, 2020
…to scatter-option

* 'master' of https://github.com/JennChao/carbon-charts:
  v0.36.4
  Merge pull request carbon-design-system#761 from JennChao/sparkline
  Merge pull request carbon-design-system#793 from hlyang397/update-initial-zoom-domain
  fix the defect of label tooltip not showing when using custom tooltip (carbon-design-system#787)
  v0.36.3
  Merge pull request carbon-design-system#785 from sophiiae/skeleton-with-data
JennChao added a commit to JennChao/carbon-charts that referenced this pull request Sep 11, 2020
…to linearGradient

* 'master' of https://github.com/JennChao/carbon-charts:
  v0.36.4
  Merge pull request carbon-design-system#761 from JennChao/sparkline
  Merge pull request carbon-design-system#793 from hlyang397/update-initial-zoom-domain
  fix the defect of label tooltip not showing when using custom tooltip (carbon-design-system#787)
  v0.36.3
  Merge pull request carbon-design-system#785 from sophiiae/skeleton-with-data
JennChao added a commit to JennChao/carbon-charts that referenced this pull request Sep 11, 2020
…to axis-option

* 'master' of https://github.com/JennChao/carbon-charts:
  v0.36.4
  Merge pull request carbon-design-system#761 from JennChao/sparkline
  Merge pull request carbon-design-system#793 from hlyang397/update-initial-zoom-domain
  fix the defect of label tooltip not showing when using custom tooltip (carbon-design-system#787)
  v0.36.3
  Merge pull request carbon-design-system#785 from sophiiae/skeleton-with-data
JennChao added a commit to JennChao/carbon-charts that referenced this pull request Sep 15, 2020
…to tooltip-option

* 'master' of https://github.com/JennChao/carbon-charts:
  v0.37.1
  Merge pull request carbon-design-system#800 from metonym/fix-svelte-base-chart
  v0.37.0
  Merge pull request carbon-design-system#780 from natashadecoste/fix-meter-max-val
  feat: enable or disable scatter dot on charts except scatter chart (carbon-design-system#769)
  feat: create options for tick rotation (carbon-design-system#770)
  v0.36.4
  Merge pull request carbon-design-system#761 from JennChao/sparkline
  Merge pull request carbon-design-system#793 from hlyang397/update-initial-zoom-domain
  fix the defect of label tooltip not showing when using custom tooltip (carbon-design-system#787)
  v0.36.3
  Merge pull request carbon-design-system#785 from sophiiae/skeleton-with-data
theiliad pushed a commit to theiliad/carbon-charts that referenced this pull request May 17, 2021
* feat: enable chart grid enable option

* refactor: rename grid option

* refactor: rename gridEnabled to isGridEnabled

* fix: enable grid as default setting

* feat: enable or disable x and y grid separately

* refactor: interface modification for xGridEnabled and yGridEnabled

* refactor: rename grid option

* refactor: rename class

Co-authored-by: Fei Z <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants