Quantcast
Channel: Northwoods Software - Latest topics
Viewing all articles
Browse latest Browse all 7417

When I dynamically changed the graduatedTickUnit, why did the tick mark disappear?

$
0
0

@fecn wrote:

I use a 360 degree sector as the main shape. When I change the graduatedMin or graduatedMax, graduatedTickUnit will change according to the conversion function accordingly. However, the strange thing is that when the range is reduced, the short tick disappears. If I continue to reduce the range, the long tick also disappears.

const makeSector = function (data) {
  let radius = data.width / 2,
    angle = SectorReshapingTool.getAngle(data),
    sweep = data.rotationDirection ? -360 : 360,
    start = new go.Point(radius, 0).rotate(angle),
    geo;

  geo = new go.Geometry()
    .add(new go.PathFigure(radius + start.x, radius + start.y)  // start point
      .add(new go.PathSegment(go.PathSegment.Arc,
        angle, sweep,  // angles
        radius, radius,  // center
        radius, radius))  // radius
      // .add(new go.PathSegment(go.PathSegment.Line, radius, radius).close())
    )
    // .add(new go.PathFigure(0, 0))  // make sure the Geometry always includes the whole circle
    // .add(new go.PathFigure(2 * radius, 2 * radius));  // even if only a small sector is "lit"

  return geo;
}

const getTickUnit = function ({ minValue, maxValue, majorScaleNum, minorScaleNum }) {
  let unit = ((maxValue - minValue) / majorScaleNum / minorScaleNum).toFixed(2)
  // console.log(unit)
  return unit
}

function makeRing() {
  return MAKE(
      go.Node,
      "Auto",
      {
        selectionObjectName: "PAD",
        resizeObjectName: "PAD",
        background: "transparent"
      },
      MAKE(
        go.Panel,
        "Graduated",
        { stretch: go.GraphObject.None },
        // { graduatedTickUnit: 2 },
        new go.Binding("graduatedTickBase", "minValue"),
        new go.Binding("graduatedMin", "minValue"),
        new go.Binding("graduatedMax", "maxValue"),
        new go.Binding("graduatedTickUnit", "", getTickUnit),
        MAKE(
          go.Shape,
          { name: "PAD" },
          new go.Binding("width", "width").makeTwoWay(),
          new go.Binding("height", "height").makeTwoWay(),
          new go.Binding("fill", "backgroundColor"),
          new go.Binding("stroke", "", getOuterStroke),
          new go.Binding("geometry", "", makeSector),
        ),
        MAKE(
          go.Shape,
          { geometryString: "M0 0 V5" },
          new go.Binding("alignmentFocus", "", getAlignmentFocus),
          new go.Binding("stroke", "tickColor"),
          new go.Binding("visible", "showScale")
        ),
        MAKE(
          go.Shape,
          { geometryString: "M0 0 V10" },
          new go.Binding("alignmentFocus", "", getAlignmentFocus),
          new go.Binding("interval", "minorScaleNum"),
          new go.Binding("graduatedSkip", "", skipMaxValue),
          new go.Binding("stroke", "tickColor"),
          new go.Binding("visible", "showScale")
        )))
}

2019-06-24_172052 2019-06-24_172126 2019-06-24_172138

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7417

Trending Articles