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

initial attempt at a stargazer page #749

Closed
wants to merge 4 commits into from
Closed
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
7 changes: 7 additions & 0 deletions docusaurus/docs/reference/developer/stargazers/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Stargazers Over Time
---

import StarChart from '../../../../src/components/StarChart';

<StarChart />
2 changes: 2 additions & 0 deletions docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@canvasjs/charts": "^3.7.26",
"@canvasjs/react-charts": "^1.0.0",
"@docusaurus/core": "^2.4.3",
"@docusaurus/plugin-client-redirects": "^2.4.3",
"@docusaurus/plugin-sitemap": "^2.4.3",
Expand Down
996 changes: 996 additions & 0 deletions docusaurus/src/components/StarChart/all.other.stargazers.json

Large diffs are not rendered by default.

1,490 changes: 1,490 additions & 0 deletions docusaurus/src/components/StarChart/all.ziti.stargazers.json

Large diffs are not rendered by default.

1,106 changes: 1,106 additions & 0 deletions docusaurus/src/components/StarChart/all.zrok.stargazers.json

Large diffs are not rendered by default.

134 changes: 134 additions & 0 deletions docusaurus/src/components/StarChart/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import React, { useState, useEffect } from 'react';
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
import CanvasJSReact from '@canvasjs/react-charts';
if (ExecutionEnvironment.canUseDOM) {
require('@canvasjs/react-charts');
}
import BrowserOnly from '@docusaurus/BrowserOnly';
import zrok from './all.zrok.stargazers.json'
import ziti from './all.ziti.stargazers.json'
import others from './all.other.stargazers.json'

var CanvasJS = CanvasJSReact.CanvasJS;
var CanvasJSChart = CanvasJSReact.CanvasJSChart;

export default function StarChart(props) {
if (!ExecutionEnvironment.canUseDOM) {
return <p>sorry charlie</p>;
} else {
console.info("you got this");
}

const zitiData = ziti.map((entry, index) => {
const dateObject = new Date(entry.date);
const r = {
x: dateObject,
y: index + 1
};
return r;
});
const zrokData = zrok.map((entry, index) => {
const dateObject = new Date(entry.date);
const r = {
x: dateObject,
y: index + 1
};
return r;
});
const othersData = others.map((entry, index) => {
const dateObject = new Date(entry.date);
const r = {
x: dateObject,
y: index + 1
};
return r;
});

const lastRow = {
x: new Date(new Date().setMonth(new Date().getMonth() + 1)), // Add an extra month to the current date
y: null
};

const options = {
zoomEnabled: true,
panEnabled: true,
title: {
//text: "OpenZiti Combined Stars Over Time"
},
axisX: {
title: "Date / Time"
},
axisY: {
title: "Stargazers"
},
toolTip: {
shared: true
},
legend: {
cursor: "pointer",
verticalAlign: "top",
horizontalAlign: "center",
dockInsidePlotArea: false,
},
data: [{
name: "ziti",
type: "line",
connectNullData: true,
showInLegend: true,
xValueType: "dateTime",
dataPoints: zitiData
},
{
name: "zrok",
type: "line",
connectNullData: true,
showInLegend: true,
xValueType: "dateTime",
dataPoints: zrokData
},
{
name: "all others",
type: "line",
connectNullData: true,
showInLegend: true,
xValueType: "dateTime",
dataPoints: othersData
}
]
}

othersData.push(lastRow);

const [chartData, setChartData] = useState(null);
return (
<BrowserOnly fallback={<div>Loading data...</div>}>
{() => {
useEffect(() => {
const fetchData = async () => {
try {
// Simulate an API request (replace with your actual API call)
// const response = await fetch('https://api.example.com/chart-data');
// const result = await response.json();
// Set the chart data in state
setChartData(othersData);
} catch (error) {
console.error('Error fetching chart data:', error);
}
};

fetchData();
}, []);

return (
<div>
{chartData ? (
<CanvasJSChart options={options} />
) : (
<p>Loading chart data...</p>
)}
</div>
);
}}
</BrowserOnly>
);
}
10 changes: 10 additions & 0 deletions docusaurus/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,16 @@
resolved "https://registry.yarnpkg.com/@braintree/sanitize-url/-/sanitize-url-6.0.4.tgz#923ca57e173c6b232bbbb07347b1be982f03e783"
integrity sha512-s3jaWicZd0pkP0jf5ysyHUI/RE7MHos6qlToFcGWXVp+ykHOy77OUMrfbgJ9it2C5bow7OIQwYYaHjk9XlBQ2A==

"@canvasjs/charts@^3.7.26":
version "3.7.26"
resolved "https://registry.yarnpkg.com/@canvasjs/charts/-/charts-3.7.26.tgz#6138e5a5355b5bb1667a6ddda3838aa3ace45c92"
integrity sha512-4BcaB0ko64NH+A4OHlKjONBEMaPDRt2V7XYTJ+lFcn0MlzzkzhWhNXGYdPL3wN9uIEkBw/1yaNZuU55cadPVpw==

"@canvasjs/react-charts@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@canvasjs/react-charts/-/react-charts-1.0.0.tgz#84e97e1e3bd045cf345ac9dbe270edf11446af51"
integrity sha512-wGI675kz65owAwXZWzJULK9GXKCrPV59+CCawXP801f4rmYGmPskdtGrczgJhA8ThFEgIvq3K4qrkpLDPSmxCQ==

"@colors/[email protected]":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9"
Expand Down