简体   繁体   English

如何手动调整 Tremor 图表中的 y 轴

[英]How do I manually adjust the y-axis in Tremor charts

Im creating dashboards and tremor is doing things pretty well.我正在创建仪表板,而 tremor 做得很好。 I just cant seem to fix this issue of y-axis range.我似乎无法解决这个 y 轴范围问题。 See below.见下文。 The tooltip shows there were 22 sales on Friday, not 12.工具提示显示周五有 22 次销售,而不是 12 次。

在此处输入图像描述 在此处输入图像描述

I dont see anything in the documentation that lets me set the yaxis range.我在文档中看不到任何让我设置 yaxis 范围的内容。 I can set width and height and I tried those but nothing changes and my data is hidden.我可以设置宽度和高度,我试过了,但没有任何变化,我的数据被隐藏了。 I can only guess it must be a styling issue.我只能猜测这一定是样式问题。 Y-axis range min ~1000, max ~26000. Y 轴范围最小 ~1000,最大 ~26000。 I have less data at the moment.我目前的数据较少。

    function ChartView({ netSalesReport, daySalesReport, hourSalesReport, orderAmountReport }) {
  return (
    <>
      <Card marginTop="mt-6">
        <Title>Net Sales Report</Title>
        <AreaChart
          data={netSalesReport}
          dataKey="date"
          categories={["Total Amount"]}
          colors={["indigo"]}
          showLegend={false}
          valueFormatter={numberFormatter}
          height="h-72"
          marginTop="mt-8"
        />
      </Card>
      <ColGrid numColsMd={1} numColsLg={3} marginTop="mt-0" gapX="gap-x-6" gapY="gap-y-6">
        <Card marginTop="mt-6">
          <Title>Net Sales By Day</Title>
          <BarChart
            data={daySalesReport}
            dataKey="day"
            categories={["count"]}
            colors={["blue"]}
            showLegend={false}
            valueFormatter={numberFormatter}
            marginTop="mt-6"
            yAxisWidth="w-12"
          />
        </Card>
        <Card marginTop="mt-6">
          <Title>Net Sales By Hour</Title>
          <BarChart
            data={hourSalesReport}
            dataKey="hour"
            categories={["count"]}
            colors={["blue"]}
            showLegend={false}
            valueFormatter={numberFormatter}
            marginTop="mt-6"
            yAxisWidth="w-12"
          />
        </Card>
        <Card marginTop="mt-6">
          <Title>Order Amount</Title>
          <BarChart
            data={orderAmountReport}
            dataKey="Amount"
            categories={["count"]}
            colors={["blue"]}
            showLegend={false}
            valueFormatter={numberFormatter}
            marginTop="mt-6"
            yAxisWidth="w-12"
          />
        </Card>
      </ColGrid>
    </>
  );
}

One needs to make sure the value being fed in data to the chart is in numeric form and not string (even though the we use formatter and return the result of that as string.需要确保以数据形式提供给图表的值是数字形式而不是字符串(即使我们使用格式化程序并将其结果作为字符串返回。

Example discussed here: https://github.com/tremorlabs/tremor/issues/247#issuecomment-1365856364此处讨论的示例: https://github.com/tremorlabs/tremor/issues/247#issuecomment-1365856364

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM