Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web GL not supported issue #241

Open
ssalveMobiltex opened this issue Jun 21, 2023 · 5 comments
Open

Web GL not supported issue #241

ssalveMobiltex opened this issue Jun 21, 2023 · 5 comments

Comments

@ssalveMobiltex
Copy link

Hi all, I am facing web gl not supported issue on Production build for plotly
Angular Plotly version - "angular-plotly.js": "^5.1.0",
"plotly.js-dist": "^2.24.2",
"plotly.js-dist-min": "^2.24.2",

I am using the latest Chrome version with hardware acceleration on.

@andrefarzat
Copy link
Collaborator

Hello @ssalveMobiltex . Quite weird this. Does this happen with another browser ? (e.g.: Firefox, edge or safari ?)

@ssalveMobiltex
Copy link
Author

Yes @andrefarzat I do get it on different browsers as well

@andrefarzat
Copy link
Collaborator

I could not replicate this issue. Could you show me the code you're using to import the angular-plotly.js module and an example of graph data ?

@ssalveMobiltex
Copy link
Author

ssalveMobiltex commented Jun 23, 2023

eg.
Step 1. Create a shared-plotly.module.ts
Code:

import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { PlotlyViaWindowModule } from 'angular-plotly.js';

@NgModule({
  declarations: [],
  imports: [
    CommonModule,
    PlotlyViaWindowModule
  ],
  exports: [
    CommonModule,
    PlotlyViaWindowModule
  ]
})

Step 2: Import the shared module in your lazy loaded module

import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { SharedPlotlyModule} from '../../shared-plotly.module';
import { SharedModule } from '../../shared.module';
import { GraphRoutingModule } from './graph-routing.module';
import { GraphWrapperComponent } from './reading-graph-wrapper/graph-wrapper.component';
import { GraphComponent } from './graph.component';

@NgModule({
  declarations: [
    GraphComponent,
    GraphWrapperComponent
  ],
  imports: [
    CommonModule,
    GraphRoutingModule,
    SharedModule,
    SharedPlotlyModule
  ]
})
export class GraphModule { }

Step 3: Code in Component

<div>
    <plotly-plot class='chart' [data]="graph.data" [layout]="graph.layout" [config]="graph.config">
    </plotly-plot>
</div>

TS:

graph;
  graphData = [];
  createGraph(result) {
    const X = [], Y = [];
    let fData, pData = {};
    if (Condition) {
      for (let index = 0; index < result.length; index++) {
        X.push(result.x),
          Y.push(result.y)
      }
      fData = {
        type: "scattergl",
        mode: "line",
        x: X,
        y: Y,
      }
      this.graphData.push(fData);
    }
    else if (Condition) {
        for (let index = 0; index < result.length; index++) {
        X.push(result.x),
          Y.push(result.y)
      }
      pData = {
        type: "scattergl",
        mode: "line",
        yaxis: 'y2',
        x: X,
        y: Y,
     
      }
      this.graphData.push(pData);
    }
    const layout = {
      title: 'Graph',
      yaxis: {domain: [0, 0.40], title: 'F'},
      yaxis2: {domain: [0.50,1], title: 'P'},
      showlegend: true,
      legend: { orientation: "h",
                traceorder: 'reversed',
                x: 0,
                y: -0.2
      },
      height: 700
    }
    this.graph = {
      data: this.graphData,
      layout: layout,
      config: { responsive: true, displaylogo: false }
    };
  }

@andrefarzat
Copy link
Collaborator

I can't see anything wrong with your code.
Let's see if things go wrongly with plotly.js itself. I found an aleatory 3d graph. Please, open it and check if it's working properly in your browser: https://codepen.io/plotly/pen/MaxrwW

Secondly, please fork this codepen and try to make it work within your data. I am trying to confirm that plotly.js is working correctly before attacking angular-plotly.js, for it's just a wrapper for plotly.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants