react-native-svg#Text TypeScript Examples

The following examples show how to use react-native-svg#Text. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: bar-chart.tsx    From beancount-mobile with MIT License 6 votes vote down vote up
renderValuesOnTopOfBars = ({
    data,
    width = 0,
    height = 0,
    paddingTop = 0,
    paddingRight = 0,
  }: Pick<
    Omit<AbstractChartConfig, "data">,
    "width" | "height" | "paddingRight" | "paddingTop"
  > & {
    data: number[];
  }) => {
    const baseHeight = this.calcBaseHeight(data, height);

    return data.map((x, i) => {
      const barHeight = this.calcHeight(x, data, height);
      const bw = barWidth * this.getBarPercentage();
      return (
        <Text
          key={Math.random()}
          x={paddingRight + (i * (width - paddingRight)) / data.length + bw / 1}
          y={((baseHeight - barHeight) / 4) * 3 + paddingTop - 1}
          fill={
            this.props.chartConfig.color && this.props.chartConfig.color(0.6)
          }
          fontSize="12"
          textAnchor="middle"
        >
          {data[i]}
        </Text>
      );
    });
  };
Example #2
Source File: XTicks.tsx    From nyxo-app with GNU General Public License v3.0 5 votes vote down vote up
Day = styled(Text).attrs(({ theme }) => ({
  fill: theme.PRIMARY_TEXT_COLOR
}))``
Example #3
Source File: XTicks.tsx    From nyxo-app with GNU General Public License v3.0 5 votes vote down vote up
LongDate = styled(Text).attrs(({ theme }) => ({
  fill: theme.PRIMARY_TEXT_COLOR
}))``
Example #4
Source File: YTicks.tsx    From nyxo-app with GNU General Public License v3.0 5 votes vote down vote up
StyledText = styled(Text).attrs(({ theme }) => ({
  fill: theme.PRIMARY_TEXT_COLOR
}))``
Example #5
Source File: FallAsleepWindow.tsx    From nyxo-app with GNU General Public License v3.0 5 votes vote down vote up
FallAsleepWindow: FC<FallAsleepWindowProps> = ({
  goToSleepWindowStart,
  goToSleepWindowEnd,
  x,
  y,
  radius
}) => {
  const startAngle = clockTimeToAngle(goToSleepWindowStart)
  const endAngle = clockTimeToAngle(goToSleepWindowEnd)

  const startTime = format(
    new Date(goToSleepWindowStart ?? new Date()),
    'HH:mm'
  )
  const endTime = format(new Date(goToSleepWindowEnd ?? new Date()), 'HH:mm')

  if (
    startAngle === undefined ||
    endAngle === undefined ||
    startAngle === null ||
    endAngle === null
  ) {
    return null
  }

  const path = describeArc(x, y, radius, startAngle, endAngle)
  const textPath = describeReverseArc(x, y, radius - 10, startAngle, endAngle)

  const time = `${startTime} - ${endTime}`
  return (
    <G>
      <G>
        <Defs>
          <Path
            id="textPath"
            d={textPath}
            fill="none"
            stroke="none"
            strokeWidth="1"
          />
        </Defs>
        <Backdrop d={textPath} fill="none" strokeOpacity={1} strokeWidth="20" />

        <Text
          fill={colors.fallAsleep}
          fontSize="15"
          fontWeight="bold"
          fontFamily={fonts.bold}>
          <TextPath
            href="#textPath"
            startOffset="50%"
            textAnchor="end"
            midLine="smooth">
            <TSpan dy={5} transform={{ scaleX: 1 }} textAnchor="middle">
              {time}
            </TSpan>
          </TextPath>
        </Text>
      </G>
      <Path
        d={path}
        fill="transparent"
        strokeLinecap="round"
        stroke={colors.bedTimeColor}
        strokeWidth={5}
      />
    </G>
  )
}
Example #6
Source File: TrackerName.tsx    From nyxo-app with GNU General Public License v3.0 5 votes vote down vote up
ThemedText = styled(Text).attrs(({ theme }) => ({
  fill: theme.SECONDARY_TEXT_COLOR
}))``