Skip to content

Changes from igniteui-xplat-examples-output+PRs_2025.2.28.1 #741

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions samples/charts/category-chart/selection-matcher/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// https://www.robertcooper.me/using-eslint-and-prettier-in-a-typescript-project
module.exports = {
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
ecmaFeatures: {
jsx: true // Allows for the parsing of JSX
}
},
settings: {
react: {
version: "999.999.999" // Tells eslint-plugin-react to automatically detect the version of React to use
}
},
extends: [
"eslint:recommended",
"plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react
"plugin:@typescript-eslint/recommended" // Uses the recommended rules from @typescript-eslint/eslint-plugin
],
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
"default-case": "off",
"jsx-a11y/alt-text": "off",
"jsx-a11y/iframe-has-title": "off",
"no-undef": "off",
"no-unused-vars": "off",
"no-extend-native": "off",
"no-throw-literal": "off",
"no-useless-concat": "off",
"no-mixed-operators": "off",
"no-prototype-builtins": "off",
"no-mixed-spaces-and-tabs": 0,
"prefer-const": "off",
"prefer-rest-params": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-useless-constructor": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/prefer-namespace-keyword": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"rules": {
"default-case": "off",
"jsx-a11y/alt-text": "off",
"jsx-a11y/iframe-has-title": "off",
"no-var": "off",
"no-undef": "off",
"no-unused-vars": "off",
"no-extend-native": "off",
"no-throw-literal": "off",
"no-useless-concat": "off",
"no-mixed-operators": "off",
"no-mixed-spaces-and-tabs": 0,
"no-prototype-builtins": "off",
"prefer-const": "off",
"prefer-rest-params": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-useless-constructor": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/prefer-namespace-keyword": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"
}
}
]
};
45 changes: 45 additions & 0 deletions samples/charts/category-chart/selection-matcher/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "example-ignite-ui-react",
"description": "This project provides example of using Ignite UI for React components",
"author": "Infragistics",
"version": "1.4.0",
"license": "",
"homepage": ".",
"private": true,
"scripts": {
"start": "set PORT=4200 && react-scripts --max_old_space_size=10240 start",
"build": "react-scripts --max_old_space_size=10240 build ",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"lint": "eslint ./src/**/*.{ts,tsx}"
},
"dependencies": {
"igniteui-react": "18.7.7",
"igniteui-react-charts": "18.7.7",
"igniteui-react-core": "18.7.7",
"igniteui-webcomponents": "5.2.1",
"lit-html": "^3.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "^5.0.1",
"tslib": "^2.4.0"
},
"devDependencies": {
"@types/jest": "^29.2.0",
"@types/node": "^18.11.7",
"@types/react": "^18.0.24",
"@types/react-dom": "^18.0.8",
"eslint": "^8.33.0",
"eslint-config-react": "^1.1.7",
"eslint-plugin-react": "^7.20.0",
"react-app-rewired": "^2.2.1",
"typescript": "^4.8.4",
"worker-loader": "^3.0.8"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
11 changes: 11 additions & 0 deletions samples/charts/category-chart/selection-matcher/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Sample | Ignite UI | React | infragistics</title>
<link rel="shortcut icon" href="https://static.infragistics.com/xplatform/images/browsers/react.png" >
<link rel="stylesheet" href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" />
</head>
<body>
<div id="root"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"infiniteLoopProtection": false,
"hardReloadOnChange": false,
"view": "browser"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
export class EnergyRenewableConsumptionItem {
public constructor(init: Partial<EnergyRenewableConsumptionItem>) {
Object.assign(this, init);
}

public location: string;
public year: number;
public hydro: number;
public solar: number;
public wind: number;
public other: number;

}
export class EnergyRenewableConsumption extends Array<EnergyRenewableConsumptionItem> {
public constructor(items: Array<EnergyRenewableConsumptionItem> | number = -1) {
if (Array.isArray(items)) {
super(...items);
} else {
const newItems = [
new EnergyRenewableConsumptionItem(
{
location: `China`,
year: 2019,
hydro: 1269.5,
solar: 223,
wind: 405.2,
other: 102.8
}),
new EnergyRenewableConsumptionItem(
{
location: `Europe`,
year: 2019,
hydro: 632.54,
solar: 154,
wind: 461.3,
other: 220.3
}),
new EnergyRenewableConsumptionItem(
{
location: `USA`,
year: 2019,
hydro: 271.16,
solar: 108,
wind: 303.4,
other: 78.34
}),
new EnergyRenewableConsumptionItem(
{
location: `Brazil`,
year: 2019,
hydro: 399.3,
solar: 5.5,
wind: 55.83,
other: 56.25
}),
new EnergyRenewableConsumptionItem(
{
location: `Canada`,
year: 2019,
hydro: 381.98,
solar: 4.3,
wind: 34.17,
other: 10.81
}),
];
super(...newItems.slice(0));
}
}
}
2 changes: 2 additions & 0 deletions samples/charts/category-chart/selection-matcher/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
134 changes: 134 additions & 0 deletions samples/charts/category-chart/selection-matcher/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';

import { IgrLegendModule, IgrCategoryChartModule, IgrDataChartAnnotationModule, IgrDataChartInteractivityModule, IgrDataChartCoreModule } from 'igniteui-react-charts';
import { IgrLegend, IgrCategoryChart } from 'igniteui-react-charts';
import { ComponentRenderer, LegendDescriptionModule, CategoryChartDescriptionModule, DataChartAnnotationDescriptionModule, DataChartInteractivityDescriptionModule, DataChartCoreDescriptionModule } from 'igniteui-react-core';
import { EnergyRenewableConsumptionItem, EnergyRenewableConsumption } from './EnergyRenewableConsumption';
import { IgrChartSelection, IgrSeriesMatcher } from 'igniteui-react-charts';

const mods: any[] = [
IgrLegendModule,
IgrCategoryChartModule,
IgrDataChartAnnotationModule,
IgrDataChartInteractivityModule,
IgrDataChartCoreModule
];
mods.forEach((m) => m.register());

export default class Sample extends React.Component<any, any> {
private legend: IgrLegend
private legendRef(r: IgrLegend) {
this.legend = r;
this.setState({});
}
private chart: IgrCategoryChart
private chartRef(r: IgrCategoryChart) {
this.chart = r;
this.setState({});
}

constructor(props: any) {
super(props);

this.legendRef = this.legendRef.bind(this);
this.chartRef = this.chartRef.bind(this);
}
public componentDidMount() {
this.selectionMatcherOnViewInit();
}

public render(): JSX.Element {
return (
<div className="container sample">

<div className="legend-title">
Renewable Electricity Generated
</div>

<div className="legend">
<IgrLegend
ref={this.legendRef}
orientation="Horizontal">
</IgrLegend>
</div>

<div className="container fill">
<IgrCategoryChart
ref={this.chartRef}
legend={this.legend}
dataSource={this.energyRenewableConsumption}
chartType="Column"
crosshairsDisplayMode="None"
yAxisTitle="TWh"
isHorizontalZoomEnabled="false"
isVerticalZoomEnabled="false"
selectionMode="SelectionColorFill"
selectionBehavior="Auto"
selectionBrush="orange">
</IgrCategoryChart>
</div>
</div>
);
}

private _energyRenewableConsumption: EnergyRenewableConsumption = null;
public get energyRenewableConsumption(): EnergyRenewableConsumption {
if (this._energyRenewableConsumption == null)
{
this._energyRenewableConsumption = new EnergyRenewableConsumption();
}
return this._energyRenewableConsumption;
}

private _componentRenderer: ComponentRenderer = null;
public get renderer(): ComponentRenderer {
if (this._componentRenderer == null) {
this._componentRenderer = new ComponentRenderer();
var context = this._componentRenderer.context;
LegendDescriptionModule.register(context);
CategoryChartDescriptionModule.register(context);
DataChartAnnotationDescriptionModule.register(context);
DataChartInteractivityDescriptionModule.register(context);
DataChartCoreDescriptionModule.register(context);
}
return this._componentRenderer;
}

private _timer: ReturnType<typeof setInterval>;

public selectionMatcherOnViewInit(): void {

var chart = this.chart;

this._timer = setInterval(() => {
var data = this.energyRenewableConsumption;

var matcher = new IgrSeriesMatcher();

var selection = new IgrChartSelection();
selection.item = data[1];
matcher.memberPath = "hydro";
matcher.memberPathType = "ValueMemberPath";
selection.matcher = matcher;
chart.selectedSeriesItems.add(selection);

var matcher2 = new IgrSeriesMatcher();

var selection2 = new IgrChartSelection();
selection2.item = data[2];
matcher2.memberPath = "wind";
matcher2.memberPathType = "ValueMemberPath";
selection2.matcher = matcher2;

chart.selectedSeriesItems.add(selection2);

}, 100);
}

}

// rendering above component in the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Sample/>);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
Loading