question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nivo/Line X-Axis Issues with time.

See original GitHub issue

I have been having this issue with Nivo for quite a while, and wanted to clear it out. I have a data-set with this format. data = [ id : "ID: 1", data : [ { x : moment( date ).format("YYYY-mm-DD:HH:MM:ss" , y : int } ] ]

The format for the line chart is this

`<ResponsiveLine
            data={data}
            margin={{ top: 50, right: 110, bottom: 90, left: 60 }}
            xScale={{
              type: "time",
              format: "%Y-%m-%d %H:%M:%S",
              precision: "millisecond"
            }}
            xFormat="time:%Y-%m-%d %H:%M:%S"
            yScale={{
              type: "linear",
              min: "auto",
              max: "auto",
              stacked: false,
              reverse: false
            }}
            curve="cardinal"
            axisTop={null}
            enableGridX={false}
            axisRight={null}
            axisBottom={{
              format: "%b %d",
              tickValues: "every 2 seconds",
              legend: "time scale",
              legendOffset: -12,
              orient: "bottom",
              tickValues: 15,
              tickSize: 5,
              tickPadding: 5,
              tickRotation: 45,
              legend: this.props.legend,
              legendOffset: 36,
              legendPosition: "middle"
            }}
            axisLeft={{
              orient: "left",
              tickSize: 5,
              tickPadding: 5,
              tickRotation: 0,
              legend: "count",
              legendOffset: -40,
              legendPosition: "middle"
            }}
            colors={{ scheme: "nivo" }}
            pointSize={5}
            pointColor={{ theme: "background" }}
            pointBorderWidth={1}
            pointBorderColor={{ from: "serieColor" }}
            pointLabel="y"
            pointLabelYOffset={-12}
            useMesh={true}
            legends={[
              {
                fill: "white",
                anchor: "top",
                direction: "row",
                justify: false,
                translateX: 0,
                translateY: -40,
                itemsSpacing: 0,
                itemDirection: "left-to-right",
                itemWidth: 200,
                itemTextColor: "#cccccc",
                itemHeight: 20,
                itemOpacity: 0.75,
                symbolSize: 12,
                symbolShape: "circle",
                symbolBorderColor: "rgba(0, 0, 0, .5)",
                effects: [
                  {
                    on: "hover",
                    style: {
                      itemBackground: "rgba(0, 0, 0, .03)",
                      itemOpacity: 1
                    }
                  }
                ]
              }
            ]}
            theme={{
              fontFamily: "Montserrat",
              textColor: "white",
              text: {
                fill: "white"
              },
              axis: {
                ticks: {
                  line: {
                    stroke: "green"
                  },
                  text: {
                    fill: "white"
                  }
                },
                legend: {
                  text: {
                    fill: "white"
                  }
                }
              },
              crosshair: {
                line: {
                  stroke: "white",
                  strokeWidth: 0.3,
                  strokeOpacity: 0.75,
                  strokeDasharray: "6 6"
                }
              },
              grid: {
                line: {
                  stroke: "white",
                  strokeWidth: 0.5
                }
              }
            }}
            animate={true}
            motionStiffness={215}
            motionDamping={20}
          />`

I get an error saying

TypeError: null is not an object (evaluating 'v.getTime')

'max = Math.max.apply(Math, _toConsumableArray(all));
  292 | } else if (scaleSpec.type === 'time') {
  293 |   all = uniqBy(all, function (v) {
 294 |     return v.getTime();
      | ^  295 |   });
  296 |   all = all.slice(0).sort(function (a, b) {
  297 |     return b - a;'

I’ve been cracking my head for a while and can’t seem to figure out what the problem is… I think the error is very small maybe with the formats to be set, could anyone please point out what could be the problem?

I want the intervals to be somewhere like every 15 minutes.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
man-personcommented, Jan 7, 2021

i get the same error. The hours and the minutes are required in my case, so removing them as suggested in the answer above is not an option.

0reactions
stale[bot]commented, Nov 5, 2020

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can not pass date to nivo line chart - Stack Overflow
I have read something about trying to use "toString()" but thats just a circle of the same errors. I hope someone can help...
Read more >
@nivo/line time y axis - CodeSandbox
VS Code's tsserver was deleted by another application such as a misbehaving virus detection tool. Please reinstall VS Code. Manage Extension.
Read more >
Line chart X axis how to display both date & time.
The problem I am having is that the chart will only display the time and not both date & time. I know it's...
Read more >
[Solved]-Nivo Line Formatting time tick on the x axis-Reactjs
You can create a new array of all x-axis dates and then show the date once if it appears multiple times. Here is...
Read more >
Add A Simple Target Line Parallel To X-Axis, In Nivo @Nivo ...
issue #3879: Allow Graph/Data Source with custom fields to prompt during ... reaction time on the left side Yaxis and the trial number...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found