☝️Small business or a startup? See if you qualify for our special offer.
+

Install react-flexmonster correctly css file not listed in node_modules package file

Answered
Carlos Lenon asked 5 days ago

Hi Flexmonster Team,
I'm Lenon, Frontend Engineer for FreeBalance company.

As company we testing some pivot table solutions because we interested to adquire a license of one of these solutions. In this moment we testing the flexmonster solution.

I'm trying to build a vite/react POC project in order to test the flexmonster features, but i facing some issues:

1. I having issue with the react component installation using the cli tool.

2. The css file style not listed in the node_module react-flexmonster files

3. Having issue with the connection datasource

 

I shared some screenshot in order to share more details.

I'll appreciate your support and assitance in this process, so we can reach to test all the diff features the flexmonster give us using the react component

 

I'll be waiting on your contact

Regard

4 answers

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster 4 days ago

Hello, Lenon!

Thank you for reaching out to us.

Please find detailed comments on all your questions below:

1) I having issue with the react component installation using the cli tool.

As an entry point, we'd like to share with you all the ways you can get Flexmonster with React:

If the CLI approach doesn't work well for you, we kindly ask for more details about the issue, e.g., if there was an error message in the console, so we can investigate the case further.

2) The css file style not listed in the node_module react-flexmonster files

Please note that the command npm install react-flexmonster adds two folders to your project:

  • flexmonster folder with all minified scripts and styles responsible for the component to work properly
  • react-flexmonster folder with the React wrapper for Flexmonster(e.g. with this wrapper you can apply React hooks to Flexmonster)

So, the CSS styles should be located at node_modules\flexmonster\flexmonster.min.css.

You can check out the full project's structure by the link: https://www.flexmonster.com/faq/#download-package.

3) Having issue with the connection datasource

To begin with, please check if your case is covered in our data sources guide: https://www.flexmonster.com/doc/supported-data-sources/.

If you have any additional questions about connecting to the data source, provide us with more details about the case, so we can reproduce it on our side.
Any screenshots and code snippets would be a great help.

Please let us know if you have any further questions.

Kind regards,
Solomiia

Public
Carlos Lenon 4 days ago

Hi Solomia,

Thanks for getting back to me.

Let me do a new installation in a poco new project. Following your step.

 

Public
Carlos Lenon 4 days ago

Hi Solomia,

I laready download the github pivot-react repo.

I laready ran it on my local and install the /typescript project dependencies.

Everything is running fine on my local with the example.

This example is using .json connection type. So, I want to use my own connection.

What I did is declare the event onReady and set the connection object but its does not works. I do not see anything loading and no error is showing. I may missing some value in the configuration.

 

Here is some screenshot and info about the diff ways i trying to fix my issue. SOrryabout the comments code, but I just want you te see where I missing.

import { useEffectuseRefuseState } from 'react';
import Stack from '@mui/material/Stack';
import Box from '@mui/material/Box';
import LinearProgress from '@mui/material/LinearProgress';
import CircularProgress from '@mui/material/CircularProgress';
import Button from '@mui/material/Button';
import * as FlexmonsterReact from 'react-flexmonster';

function Pivote() {
  const pivotRefReact.RefObject<FlexmonsterReact.Pivot | null> =
    useRef<FlexmonsterReact.Pivot>(null);
  const [isPivotConfigLoadingsetIsPivotConfigLoading] = useState(false);
  const [pivotDataSourceInfosetPivotDataSourceInfo] = useState<string>('');
  const [pivotDataSourceTypesetPivotDataSourceType] = useState<string>('');
  const [pivotDataSourceCatalogsetPivotDataSourceCatalog] =
    useState<string>('');
  const [pivotDataSourceCubesetPivotDataSourceCube] = useState<string>('');

  const fetchDataSourceInfo = async () => {
    if (pivotRef && pivotRef.current) {
      setIsPivotConfigLoading(true);
      const flexmonsterIntance = pivotRef.current.flexmonster;
      const dataSourcesInfostring[] =
        await flexmonsterIntance.getXMLADataSourcesAsync(proxyURL);
      const dataSourceTypestring =
        await flexmonsterIntance.getXMLAProviderNameAsync(proxyURL);
      const catalogsstring[] = await flexmonsterIntance.getXMLACatalogsAsync(
        proxyURL,
        dataSourcesInfo[0]
      );
      const cubesstring[] = await flexmonsterIntance.getXMLACubesAsync(
        proxyURL,
        dataSourcesInfo[0],
        catalogs[0]
      );

      if (
        dataSourcesInfo.length > 0 &&
        dataSourceType &&
        catalogs.length > 0 &&
        cubes.length > 0
      ) {
        const pivotCNX = {
          type: 'microsoft analysis services',
          proxyURL: '[our olap xmla url.../xmla]',
          dataSourceInfo: dataSourcesInfo[0],
          catalog: catalogs[0],
          cube: cubes[3],
        };
        flexmonsterIntance.connectTo(pivotCNX);
        // setPivotDataSourceInfo(dataSourcesInfo[0]);
        // setPivotDataSourceType(dataSourceType);
        // setPivotDataSourceCatalog(catalogs[0]);
        // setPivotDataSourceCube(cubes[3]);
        // console.log('dataSourceInfo', dataSourcesInfo);
        // console.log('dataSourceType', dataSourceType);
        // console.log('catalog', catalogs);
        // console.log('cube', cubes);
        setIsPivotConfigLoading(false);
      }
    }
  };

  // useEffect(() => {
  //   fetchDataSourceInfo();
  // }, []);
  const connectPivotHandler = () => {
    fetchDataSourceInfo();
  };

  const pivotReadyHandler = () => {
    if (pivotRef && pivotRef.current) {
      setIsPivotConfigLoading(true);
      const flexmonsterIntance = pivotRef.current.flexmonster;
      const pivotCNX = {
        type: 'microsoft analysis services',
        proxyURL: '[our olap xmla url.../xmla]',
        dataSourceInfo: 'Transparency Portal',
        catalog: 'OLAP_KOSOVO_DWH',
        cube: 'COA2022_004',
      };
      flexmonsterIntance.connectTo(pivotCNX);
      // setPivotDataSourceInfo(dataSourcesInfo[0]);
      // setPivotDataSourceType(dataSourceType);
      // setPivotDataSourceCatalog(catalogs[0]);
      // setPivotDataSourceCube(cubes[3]);
      // console.log('dataSourceInfo', dataSourcesInfo);
      // console.log('dataSourceType', dataSourceType);
      // console.log('catalog', catalogs);
      // console.log('cube', cubes);
      setIsPivotConfigLoading(false);
    }
  };

  return (
    <div id="pivot-table">
      {isPivotConfigLoading && (
        <>
          <Box
            sx={{
              display: 'flex',
              justifyContent: 'center',
              marginBottom: '10px',
            }}
          >
            <CircularProgress />
          </Box>
          <Stack
            sx={{
              width: '100%',
              color: 'grey.500',
            }}
            spacing={2}
          >
            <LinearProgress color="secondary" />
          </Stack>
        </>
      )}
      <Button variant="text" onClick={connectPivotHandler}>
        CONNECT
      </Button>
      {/* <FlexmonsterReact.Pivot
        ref={pivotRef}
        toolbar={true}
        ready={pivotReadyHandler}
      /> */}
      <FlexmonsterReact.Pivot
        ref={pivotRef}
        toolbar={true}
        report={{
          dataSource: {
            type: 'json',
            data: [
              { Category: 'Beverages'Sales: 100 },
              { Category: 'Snacks'Sales: 150 },
            ],
          },
        }}
      />
    </div>
  );
}

NOTE
If you connect using the connect dialog from table its works properly. But if you set the connect via the connectTo method or via the dataSourceObject, setting those at the beginning is does not works.

For XMLA datasource type, the documentation require to use this approach config

pivot.connectTo({
  type: 'microsoft analysis services',
  proxyUrl: 'https://olap.flexmonster.com/olap/msmdpump.dll',
  dataSourceInfo: 'Provider=MSOLAP; Data Source=extranet;',
  catalog: 'Adventure Works DW Standard Edition',
  cube: 'Adventure Works'
});

In our case, folling the documentation should be

 const pivotCNX = {
          type: 'microsoft analysis services',
          proxyURL: '[our olap xmla url.../xmla]',
          dataSourceInfo: dataSourcesInfo[0],
          catalog: catalogs[0],
          cube: cubes[3],
       };

 
But this does not work.
 
By the otherhand, if I try to connect using the connect modal called from the pivot table toolbar using my custom url its work fine
 


 
I'll appreciate your help,
If we can have a video call in order to solve this. It'll be perfect. Because I need to build this POC for flexmonster, if not I'll have to search for other tools.
Regards
 

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster 1 day ago

Hello, Lenon!

Thank you for the provided details. And we are happy to hear that our sample project was helpful!

If we understand the case correctly, Flexmonster connects to your XMLA endpoint from the UI and the data is shown, but there's something missing while connecting to the OLAP XMLA data source from the code.

As a first step, let's try to connect Flexmonster to OLAP data source in the report object. Here is the code snippet for reference:

import React from "react";
import * as FlexmonsterReact from "react-flexmonster";

class PivotTableDemo extends React.Component {
render() {
return (
<>
<div className="App">
<FlexmonsterReact.Pivot
report={{
dataSource: {
type: "microsoft analysis services",
proxyURL: '[your olap xmla url.../xmla]',
catalog: catalogs[0],
cube: cubes[3],
},
}}
/>
</div>
</>
);
}
}

export default PivotTableDemo;

Please check that your custom variables(catalogs, cubes, etc) are returning the correct values when initializing Flexmonster. We recommend trying to use the string values in dataSource object to locate the cause of the described behavior.

Our Sales Representative will also send you the follow-up email with more organizational information.

Please let us know if the suggested approach was helpful to connect Flexmonster to OLAP cube via XMLA.
Looking forward to hearing from you.

Kind regards,
Solomiia

Please login or Register to Submit Answer