-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(patents): add graph for cpc classification
- Loading branch information
Showing
8 changed files
with
332 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React from "react"; | ||
import Highcharts from "highcharts"; | ||
import HighchartsReact from "highcharts-react-official"; | ||
import HighchartsMore from "highcharts/highcharts-more"; | ||
|
||
HighchartsMore(Highcharts); | ||
|
||
type CpcChartProps = { | ||
data: { | ||
label: any; | ||
name: string; | ||
doc_count: number; | ||
code: string; | ||
}[]; | ||
}; | ||
|
||
const CpcChart: React.FC<CpcChartProps> = ({ data }) => { | ||
const chartData = data.map((item) => ({ | ||
name: item.label, | ||
value: item.doc_count, | ||
code: item.code, | ||
})); | ||
|
||
const options = { | ||
chart: { | ||
type: "packedbubble", | ||
layoutAlgorithm: { | ||
splitSeries: false, | ||
}, | ||
height: "100%", | ||
backgroundColor: "#f4f4f4", | ||
}, | ||
title: { | ||
text: "Répartition des CPC par code", | ||
}, | ||
tooltip: { | ||
pointFormat: "<b>{point.name}</b> (Code: {point.code}): {point.value}", | ||
formatter: function () { | ||
return `<b>${this.point.name}</b> (Code: ${this.point.code}): ${this.point.value}`; | ||
}, | ||
}, | ||
series: [ | ||
{ | ||
minSize: 20, | ||
maxSize: 100, | ||
data: chartData.map((item) => ({ | ||
name: item.name, | ||
value: item.value, | ||
code: item.code, | ||
})), | ||
}, | ||
], | ||
plotOptions: { | ||
packedbubble: { | ||
minSize: 10, | ||
maxSize: 100, | ||
zMin: 0, | ||
zMax: 100, | ||
dataLabels: { | ||
enabled: true, | ||
format: "{point.value}", | ||
}, | ||
cursor: "pointer", | ||
point: { | ||
events: { | ||
click: function () { | ||
window.location.href = `/search/patents?q=${this.code}`; | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
return <HighchartsReact highcharts={Highcharts} options={options} />; | ||
}; | ||
|
||
export default CpcChart; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from "react"; | ||
import Highcharts from "highcharts"; | ||
import HighchartsReact from "highcharts-react-official"; | ||
import wordcloud from "highcharts/modules/wordcloud"; | ||
|
||
wordcloud(Highcharts); | ||
|
||
type CpcWordChartProps = { | ||
data: { | ||
label: string; | ||
doc_count: number; | ||
code: string; | ||
}[]; | ||
}; | ||
|
||
const CpcWordCloud: React.FC<CpcWordChartProps> = ({ data }) => { | ||
const wordCloudData = data.map((item) => ({ | ||
name: item.code, | ||
weight: item.doc_count, | ||
label: item.label, | ||
})); | ||
|
||
const options = { | ||
chart: { | ||
type: "wordcloud", | ||
}, | ||
title: { | ||
text: "Nuage de mots des CPC par code", | ||
}, | ||
series: [ | ||
{ | ||
type: "wordcloud", | ||
data: wordCloudData, | ||
name: "Occurrences", | ||
}, | ||
], | ||
tooltip: { | ||
pointFormat: | ||
"{point.label}: <b>{point.name}</b> (Occurrences: {point.weight})", | ||
}, | ||
plotOptions: { | ||
series: { | ||
cursor: "pointer", | ||
point: { | ||
events: { | ||
click: function () { | ||
window.location.href = `/search/patents?q=${this.name}`; | ||
}, | ||
}, | ||
}, | ||
}, | ||
wordcloud: { | ||
minFontSize: 10, | ||
maxFontSize: 50, | ||
}, | ||
}, | ||
}; | ||
|
||
return <HighchartsReact highcharts={Highcharts} options={options} />; | ||
}; | ||
|
||
export default CpcWordCloud; |
Oops, something went wrong.