Backend API
import React from 'react';
import RowTemplate from './RowTemplate.tsx';
const years = ['2021', '2022', '2023'];
function App() {
return (
<>
<div className="long-title"><h3>Monthly Prices of Copper, Nickel and Palladium</h3></div>
<div id="chart-demo">
<table className="demo-table" style={{ border: 1 }}>
<tbody>
<tr>
<th />
<th>Copper (USD/ton)</th>
<th>Nickel (USD/ton)</th>
<th>Palladium (USD/troy ounce)</th>
</tr>
{years.map((year, index) => (
<RowTemplate key={index} year={year} />
))}
</tbody>
</table>
</div>
</>
);
}
export default App;
import React from 'react';
import RowTemplate from './RowTemplate.js';
const years = ['2021', '2022', '2023'];
function App() {
return (
<>
<div className="long-title">
<h3>Monthly Prices of Copper, Nickel and Palladium</h3>
</div>
<div id="chart-demo">
<table
className="demo-table"
style={{ border: 1 }}
>
<tbody>
<tr>
<th />
<th>Copper (USD/ton)</th>
<th>Nickel (USD/ton)</th>
<th>Palladium (USD/troy ounce)</th>
</tr>
{years.map((year, index) => (
<RowTemplate
key={index}
year={year}
/>
))}
</tbody>
</table>
</div>
</>
);
}
export default App;
import React from 'react';
import Sparkline, {
Tooltip,
} from 'devextreme-react/sparkline';
import {
copperCosts,
nickelCosts,
palladiumCosts,
} from './data.ts';
interface RowTemplateProps {
key: number;
year: string;
}
export default function RowTemplate(props: RowTemplateProps) {
return (
<tr>
<th>{props.year}</th>
<td>
<Sparkline
dataSource={copperCosts}
showMinMax={true}
className="sparkline"
argumentField="month"
valueField={props.year}
type="area"
>
<Tooltip format={{ type: 'currency', precision: 2 }} />
</Sparkline>
</td>
<td>
<Sparkline
dataSource={nickelCosts}
pointSize={6}
showMinMax={true}
showFirstLast={false}
className="sparkline"
argumentField="month"
valueField={props.year}
type="splinearea"
lineColor="#8076bb"
minColor="#6babac"
maxColor="#8076bb"
>
<Tooltip format={{ type: 'currency', precision: 2 }} />
</Sparkline>
</td>
<td>
<Sparkline
dataSource={palladiumCosts}
lineWidth={3}
className="sparkline"
argumentField="month"
valueField={props.year}
type="steparea"
lineColor="#7e4452"
firstLastColor="#e55253"
pointColor="#e8c267"
pointSymbol="polygon"
>
<Tooltip format={{ type: 'currency', precision: 2 }} />
</Sparkline>
</td>
</tr>
);
}
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App.tsx';
ReactDOM.render(
<App />,
document.getElementById('app'),
);
export const copperCosts = [{
month: 1,
2021: 7970.50,
2022: 9775.93,
2023: 8999.79,
}, {
month: 2,
2021: 8460.25,
2022: 9941.35,
2023: 8955.20,
}, {
month: 3,
2021: 9004.98,
2022: 10237.59,
2023: 8835.72,
}, {
month: 4,
2021: 9335.55,
2022: 10183.13,
2023: 8814.00,
}, {
month: 5,
2021: 10183.97,
2022: 9362.81,
2023: 8234.28,
}, {
month: 6,
2021: 9612.43,
2022: 9033.13,
2023: 8386.23,
}, {
month: 7,
2021: 9433.59,
2022: 7529.79,
2023: 8445.26,
}, {
month: 8,
2021: 9357.19,
2022: 7960.98,
2023: 8351.77,
}, {
month: 9,
2021: 9324.07,
2022: 7734.70,
2023: 8270.86,
}, {
month: 10,
2021: 9778.50,
2022: 7621.21,
2023: 7939.66,
}, {
month: 11,
2021: 9765.48,
2022: 8029.95,
2023: 8173.95,
}, {
month: 12,
2021: 9550.31,
2022: 8367.23,
2023: 8394.11,
}];
export const nickelCosts = [{
month: 1,
2021: 17847.68,
2022: 22355.40,
2023: 28194.61,
}, {
month: 2,
2021: 18595.30,
2022: 24015.55,
2023: 26727.95,
}, {
month: 3,
2021: 16460.83,
2022: 33924.18,
2023: 23288.61,
}, {
month: 4,
2021: 16480.91,
2022: 33132.74,
2023: 23894.56,
}, {
month: 5,
2021: 17552.45,
2022: 28062.55,
2023: 21970.39,
}, {
month: 6,
2021: 17942.32,
2022: 25658.63,
2023: 21233.28,
}, {
month: 7,
2021: 18819.36,
2022: 21481.89,
2023: 21091.26,
}, {
month: 8,
2021: 19160.23,
2022: 22057.39,
2023: 20438.65,
}, {
month: 9,
2021: 19398.23,
2022: 22773.97,
2023: 19644.64,
}, {
month: 10,
2021: 19420.52,
2022: 22032.89,
2023: 18281.23,
}, {
month: 11,
2021: 19970.43,
2022: 25562.70,
2023: 17027.36,
}, {
month: 12,
2021: 20015.55,
2022: 28946.81,
2023: 16460.84,
}];
export const palladiumCosts = [{
month: 1,
2021: 2391.20,
2022: 2030.86,
2023: 1734.27,
}, {
month: 2,
2021: 2342.33,
2022: 2350.10,
2023: 1543.90,
}, {
month: 3,
2021: 2525.61,
2022: 2582.78,
2023: 1426.00,
}, {
month: 4,
2021: 2776.45,
2022: 2330.67,
2023: 1508.00,
}, {
month: 5,
2021: 2900.52,
2022: 2060.05,
2023: 1482.61,
}, {
month: 6,
2021: 2752.48,
2022: 1913.05,
2023: 1348.09,
}, {
month: 7,
2021: 2754.76,
2022: 1973.10,
2023: 1264.48,
}, {
month: 8,
2021: 2544.73,
2022: 2135.52,
2023: 1247.30,
}, {
month: 9,
2021: 2130.32,
2022: 2113.95,
2023: 1239.29,
}, {
month: 10,
2021: 2058.48,
2022: 2078.86,
2023: 1142.09,
}, {
month: 11,
2021: 2036.32,
2022: 1911.55,
2023: 1050.27,
}, {
month: 12,
2021: 1810.52,
2022: 1808.36,
2023: 1087.76,
}];
window.exports = window.exports || {};
window.config = {
transpiler: 'ts',
typescriptOptions: {
module: 'system',
emitDecoratorMetadata: true,
experimentalDecorators: true,
jsx: 'react',
},
meta: {
'react': {
'esModule': true,
},
'typescript': {
'exports': 'ts',
},
'devextreme/time_zone_utils.js': {
'esModule': true,
},
'devextreme/localization.js': {
'esModule': true,
},
'devextreme/viz/palette.js': {
'esModule': true,
},
'openai': {
'esModule': true,
},
},
paths: {
'npm:': 'https://cdn.jsdelivr.net/npm/',
'bundles:': '../../../../bundles/',
'externals:': '../../../../bundles/externals/',
'anti-forgery:': '../../../../shared/anti-forgery/',
},
defaultExtension: 'js',
map: {
'anti-forgery': 'anti-forgery:fetch-override.js',
'ts': 'npm:plugin-typescript@8.0.0/lib/plugin.js',
'typescript': 'npm:typescript@4.2.4/lib/typescript.js',
'jszip': 'npm:jszip@3.10.1/dist/jszip.min.js',
'react': 'npm:react@17.0.2/umd/react.development.js',
'react-dom': 'npm:react-dom@17.0.2/umd/react-dom.development.js',
'prop-types': 'npm:prop-types/prop-types.js',
'rrule': 'npm:rrule@2.6.4/dist/es5/rrule.js',
'luxon': 'npm:luxon@3.4.4/build/global/luxon.min.js',
'es6-object-assign': 'npm:es6-object-assign',
'devextreme': 'npm:devextreme@link:../../packages/devextreme/artifacts/npm/devextreme/cjs',
'devextreme-react': 'npm:devextreme-react@link:../../packages/devextreme-react/npm/cjs',
'devextreme-quill': 'npm:devextreme-quill@1.7.8/dist/dx-quill.min.js',
'devexpress-diagram': 'npm:devexpress-diagram@2.2.25/dist/dx-diagram.js',
'devexpress-gantt': 'npm:devexpress-gantt@4.1.67/dist/dx-gantt.js',
'inferno': 'npm:inferno@8.2.3/dist/inferno.min.js',
'inferno-compat': 'npm:inferno-compat/dist/inferno-compat.min.js',
'inferno-create-element': 'npm:inferno-create-element@8.2.3/dist/inferno-create-element.min.js',
'inferno-dom': 'npm:inferno-dom/dist/inferno-dom.min.js',
'inferno-hydrate': 'npm:inferno-hydrate/dist/inferno-hydrate.min.js',
'inferno-clone-vnode': 'npm:inferno-clone-vnode/dist/inferno-clone-vnode.min.js',
'inferno-create-class': 'npm:inferno-create-class/dist/inferno-create-class.min.js',
'inferno-extras': 'npm:inferno-extras/dist/inferno-extras.min.js',
'@preact/signals-core': 'npm:@preact/signals-core@1.8.0/dist/signals-core.min.js',
'devextreme-cldr-data': 'npm:devextreme-cldr-data@1.0.3',
// SystemJS plugins
'plugin-babel': 'npm:systemjs-plugin-babel@0.0.25/plugin-babel.js',
'systemjs-babel-build': 'npm:systemjs-plugin-babel@0.0.25/systemjs-babel-browser.js',
// Prettier
'prettier/standalone': 'npm:prettier@2.8.8/standalone.js',
'prettier/parser-html': 'npm:prettier@2.8.8/parser-html.js',
},
packages: {
'devextreme': {
defaultExtension: 'js',
},
'devextreme-react': {
main: 'index.js',
},
'devextreme-react/common': {
main: 'index.js',
},
'devextreme/events/utils': {
main: 'index',
},
'devextreme/common/core/events/utils': {
main: 'index',
},
'devextreme/localization/messages': {
format: 'json',
defaultExtension: 'json',
},
'devextreme/events': {
main: 'index',
},
'es6-object-assign': {
main: './index.js',
defaultExtension: 'js',
},
},
packageConfigPaths: [
'npm:@devextreme/*/package.json',
],
babelOptions: {
sourceMaps: false,
stage0: true,
react: true,
},
};
window.process = {
env: {
NODE_ENV: 'production',
},
};
System.config(window.config);
// eslint-disable-next-line
const useTgzInCSB = ['openai'];
import React from 'react';
import Sparkline, { Tooltip } from 'devextreme-react/sparkline';
import { copperCosts, nickelCosts, palladiumCosts } from './data.js';
export default function RowTemplate(props) {
return (
<tr>
<th>{props.year}</th>
<td>
<Sparkline
dataSource={copperCosts}
showMinMax={true}
className="sparkline"
argumentField="month"
valueField={props.year}
type="area"
>
<Tooltip format={{ type: 'currency', precision: 2 }} />
</Sparkline>
</td>
<td>
<Sparkline
dataSource={nickelCosts}
pointSize={6}
showMinMax={true}
showFirstLast={false}
className="sparkline"
argumentField="month"
valueField={props.year}
type="splinearea"
lineColor="#8076bb"
minColor="#6babac"
maxColor="#8076bb"
>
<Tooltip format={{ type: 'currency', precision: 2 }} />
</Sparkline>
</td>
<td>
<Sparkline
dataSource={palladiumCosts}
lineWidth={3}
className="sparkline"
argumentField="month"
valueField={props.year}
type="steparea"
lineColor="#7e4452"
firstLastColor="#e55253"
pointColor="#e8c267"
pointSymbol="polygon"
>
<Tooltip format={{ type: 'currency', precision: 2 }} />
</Sparkline>
</td>
</tr>
);
}
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App.js';
ReactDOM.render(<App />, document.getElementById('app'));
export const copperCosts = [
{
month: 1,
2021: 7970.5,
2022: 9775.93,
2023: 8999.79,
},
{
month: 2,
2021: 8460.25,
2022: 9941.35,
2023: 8955.2,
},
{
month: 3,
2021: 9004.98,
2022: 10237.59,
2023: 8835.72,
},
{
month: 4,
2021: 9335.55,
2022: 10183.13,
2023: 8814.0,
},
{
month: 5,
2021: 10183.97,
2022: 9362.81,
2023: 8234.28,
},
{
month: 6,
2021: 9612.43,
2022: 9033.13,
2023: 8386.23,
},
{
month: 7,
2021: 9433.59,
2022: 7529.79,
2023: 8445.26,
},
{
month: 8,
2021: 9357.19,
2022: 7960.98,
2023: 8351.77,
},
{
month: 9,
2021: 9324.07,
2022: 7734.7,
2023: 8270.86,
},
{
month: 10,
2021: 9778.5,
2022: 7621.21,
2023: 7939.66,
},
{
month: 11,
2021: 9765.48,
2022: 8029.95,
2023: 8173.95,
},
{
month: 12,
2021: 9550.31,
2022: 8367.23,
2023: 8394.11,
},
];
export const nickelCosts = [
{
month: 1,
2021: 17847.68,
2022: 22355.4,
2023: 28194.61,
},
{
month: 2,
2021: 18595.3,
2022: 24015.55,
2023: 26727.95,
},
{
month: 3,
2021: 16460.83,
2022: 33924.18,
2023: 23288.61,
},
{
month: 4,
2021: 16480.91,
2022: 33132.74,
2023: 23894.56,
},
{
month: 5,
2021: 17552.45,
2022: 28062.55,
2023: 21970.39,
},
{
month: 6,
2021: 17942.32,
2022: 25658.63,
2023: 21233.28,
},
{
month: 7,
2021: 18819.36,
2022: 21481.89,
2023: 21091.26,
},
{
month: 8,
2021: 19160.23,
2022: 22057.39,
2023: 20438.65,
},
{
month: 9,
2021: 19398.23,
2022: 22773.97,
2023: 19644.64,
},
{
month: 10,
2021: 19420.52,
2022: 22032.89,
2023: 18281.23,
},
{
month: 11,
2021: 19970.43,
2022: 25562.7,
2023: 17027.36,
},
{
month: 12,
2021: 20015.55,
2022: 28946.81,
2023: 16460.84,
},
];
export const palladiumCosts = [
{
month: 1,
2021: 2391.2,
2022: 2030.86,
2023: 1734.27,
},
{
month: 2,
2021: 2342.33,
2022: 2350.1,
2023: 1543.9,
},
{
month: 3,
2021: 2525.61,
2022: 2582.78,
2023: 1426.0,
},
{
month: 4,
2021: 2776.45,
2022: 2330.67,
2023: 1508.0,
},
{
month: 5,
2021: 2900.52,
2022: 2060.05,
2023: 1482.61,
},
{
month: 6,
2021: 2752.48,
2022: 1913.05,
2023: 1348.09,
},
{
month: 7,
2021: 2754.76,
2022: 1973.1,
2023: 1264.48,
},
{
month: 8,
2021: 2544.73,
2022: 2135.52,
2023: 1247.3,
},
{
month: 9,
2021: 2130.32,
2022: 2113.95,
2023: 1239.29,
},
{
month: 10,
2021: 2058.48,
2022: 2078.86,
2023: 1142.09,
},
{
month: 11,
2021: 2036.32,
2022: 1911.55,
2023: 1050.27,
},
{
month: 12,
2021: 1810.52,
2022: 1808.36,
2023: 1087.76,
},
];
<!DOCTYPE html>
<html lang="en">
<head>
<title>DevExtreme Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/25.2.6/css/dx.light.css" />
<link rel="stylesheet" type="text/css" href="styles.css" />
<script src="https://cdn.jsdelivr.net/npm/core-js@2.6.12/client/shim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/systemjs@0.21.3/dist/system.js"></script>
<script type="text/javascript" src="config.js"></script>
<script type="text/javascript">
System.import("./index.tsx");
</script>
</head>
<body class="dx-viewport">
<div class="demo-container">
<div id="app"></div>
</div>
</body>
</html>
#chart-demo {
height: 440px;
}
.demo-table {
width: 100%;
border: 1px solid #c2c2c2;
border-collapse: collapse;
}
.demo-table th,
.demo-table td {
font-weight: 400;
width: 200px;
padding: 25px 10px 5px;
border: 1px solid #c2c2c2;
}
.demo-table th {
padding: 25px 15px 20px;
border: 1px solid #c2c2c2;
}
.demo-table tr:nth-child(2) td {
border-top: 1px solid #c2c2c2;
}
.demo-table td:first-of-type {
border-left: 1px solid #c2c2c2;
}
.demo-table .sparkline {
width: 200px;
height: 30px;
}
.long-title h3 {
font-weight: 200;
font-size: 28px;
text-align: center;
margin-bottom: 20px;
margin-top: 0;
}