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.

Is it possible to flip x & y view in LineChart?

See original GitHub issue

I’m currently use vuechart-js wrapper, but it sends me to chartjs docs.

I create charts like this

chart (1)

But I need this. chart rotated For sure I can make it with CSS, but I can’t rotate hover chart info, anyway it’s not beautiful solution, is it?

I have lbl = [0, 0.1, 0.2, 0.3 …] with fixed step for X-axis and some unpredictable data dt0 for Y-axis, but in fact it’s just dotes. When I flip data in dataset…

labels: dt0,
                    datasets: [
                        {
                            label: 'W(q) (a/2; b/2)',
                            borderColor: 'rgb(255, 99, 132)',
                            data: lbl,
                            fill: false,
                            showLine: false
                        },

…I get this chart (2)

Is it possible to do that I need with Chart.js? Did I miss something? Thank you!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
etimbergcommented, Mar 29, 2020

Ah, perfect @ereborDeveloper. I was going to recommend the scatter chart. You can use the x & y axis options to control how the ticks are generated if you want different steps

0reactions
ereborDevelopercommented, Mar 29, 2020

@benmccann @etimberg so sorry for bothering you. I found in Scatter docs, what we got {x: value, y: value} dots, so I just switched them and it works.

Here is my data update method:

            fillData() {
                let json = [];
                this.dt0 = [];
                this.dt1 = [];
                for (var k in this.chartData) {
                    let w0 = this.chartData[k][0];
                    let w1 = this.chartData[k][1];
                    if (w0 > this.maxW) {
                        w0 = this.maxW;
                    }
                    if (w0 < this.minW) {
                        w0 = this.minW;
                    }
                    if (w1 > this.maxW) {
                        w1 = this.maxW;
                    }
                    if (w1 < this.minW) {
                        w1 = this.minW;
                    }
                    var ob = {q: k, W: [w0, w1]};
                    json.push(ob)
                }
                json.sort(function (a, b) {
                    return a.q - b.q;
                });
                for (let obj in json) {
                    const q = Number(json[obj].q).toFixed(2);
                    if (q >= this.minQ && q <= this.maxQ) {
                        this.dt0.push({x: json[obj].W[0], y: q});
                        this.dt1.push({x: json[obj].W[1], y: q});
                    }
                }
                this.deflection = {
                    datasets: [
                        {
                            label: 'W(q) (a/2; b/2)',
                            borderColor: 'rgb(255, 99, 132)',
                            data: this.dt0,
                        },
                        {
                            label: 'W(q) (a/4; b/4)',
                            borderColor: 'rgb(99, 255, 132)',
                            data: this.dt1,
                        }
                    ]
                };
            }

And here is some visual image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swapping X and Y axis in Line chart
Solved: Hi everyone. Could someone please explain how to swap X and Y axis in a regular line chart using standard visualization.
Read more >
A Complete Guide to Line Charts | Tutorial by Chartio
Line charts are a fundamental chart type generally used to show change in values across time. Learn how to best use this chart...
Read more >
Tableau - Customising the Y-axis on a Line Chart - YouTube
Periodically in Tableau, the 'edit axis' option doesn't provide the level of control required to communicate the trend of your line chart.
Read more >
How do i flip the x and y axes in a chart in Excel 2013?
SO im trying to take some data and make a chart, and now i've found that it automatically takes the largest values and...
Read more >
Line chart reference - Looker Studio Help - Google Support
Line charts don't display trendlines. Time series do. Line chart example. You are launching a series of mobile apps and want to visualize...
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