Skip to content

Outer arc doesn't scale and becomes very thin on 4K screens - proposed solution #84

@tepedersen

Description

@tepedersen

Thanks for an excellent react component. The outer/sub arcs have a fixed width that doesn't scale well on 4K screens, becoming almost invisible.

In order to fix it for a project I'm using the component for I cloned it at customized it to allow specifying subarc width, might be something to incorporate in the library (or at least a solution for those that have the same problem on 4K monitors):

In types/Arc.ts I changed the interface Arc, adding:
subArcWidth?: number,
to the list of members

Then in hooks/arc.ts I altered drawGrafanaOuterArc to use the new property:

const drawGrafanaOuterArc = (gauge: Gauge, resize: boolean = false) => {
  const { outerRadius } = gauge.dimensions.current;
  /** TOR EDIT: Added using subArcWidth to set subarc width using component props */
  const subArcWidth = gauge.props.arc?.subArcWidth || 5;
  //Grafana's outer arc will be populates as the standard arc data would
  if (gauge.props.type == GaugeType.Grafana && resize) {
    gauge.doughnut.current.selectAll(".outerSubArc").remove();
    let outerArc = arc()
      .outerRadius(outerRadius + 2 + subArcWidth)
      .innerRadius(outerRadius + 2)
      .cornerRadius(0)
      .padAngle(0);
       ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions