|
@@ -68,7 +68,7 @@ var ctx;
|
|
|
var chartlabels;
|
|
|
var chartdata;
|
|
|
|
|
|
-var XfontSizeValue = 18;
|
|
|
+var XfontSizeValue = 16;
|
|
|
var YfontSizeValue = 18;
|
|
|
|
|
|
var TitlefontSizeValue = 32;
|
|
@@ -84,6 +84,9 @@ var chart_bgimg_url = "url(./img/bg06.webp)";
|
|
|
|
|
|
var vocab = [];
|
|
|
|
|
|
+var vocab_compare = [];
|
|
|
+
|
|
|
+
|
|
|
var chartDiv = document.getElementById('chartdiv');
|
|
|
|
|
|
var dataFirstValue;
|
|
@@ -110,6 +113,21 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+// 比較提示詞
|
|
|
+document.addEventListener('DOMContentLoaded', function () {
|
|
|
+ axios.get("https://cmm.ai:8080/vocab_comparision")
|
|
|
+ .then(response => {
|
|
|
+ // apiHideLoading();
|
|
|
+ console.log(response);
|
|
|
+
|
|
|
+ vocab_compare = response.data;
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+
|
|
|
+ console.error('發生錯誤:', error);
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
|
|
|
inputField.addEventListener('click', function () {
|
|
|
// 確保輸入框處於焦點狀態
|
|
@@ -236,7 +254,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
// const filteredVocab = vocab.filter(item => item.toLowerCase().includes(query));
|
|
|
const queryTerms = query.split(/\s+/); // 分割輸入的內容
|
|
|
const lastQueryTerm = queryTerms[queryTerms.length - 1];
|
|
|
- const filteredVocab = vocab.filter(item => {
|
|
|
+ const filteredVocab = vocab_compare.filter(item => {
|
|
|
// 對每個分割後的單詞進行匹配,只要其中有一個匹配成功就返回 true
|
|
|
return item.toLowerCase().includes(lastQueryTerm.toLowerCase());
|
|
|
|
|
@@ -334,11 +352,14 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
// }
|
|
|
// });
|
|
|
|
|
|
+
|
|
|
// 定義按鈕點擊事件處理函數
|
|
|
function sendButtonClickHandler() {
|
|
|
+
|
|
|
// inputField.value = "";
|
|
|
console.log(inputField.value);
|
|
|
var input_text_value = inputField.value;
|
|
|
+ // input_text_value = '台積電近兩週收盤價'
|
|
|
compare_box.style.display = "none";
|
|
|
$('#chartdiv').hide();
|
|
|
sidebar.classList.remove('show');
|
|
@@ -486,7 +507,7 @@ send_data_compare.addEventListener("click", function () {
|
|
|
|
|
|
if (response.data.data.length < 15) {
|
|
|
pointRadiusValue = 5;
|
|
|
- pointHoverRadiusValue = 8;
|
|
|
+ pointHoverRadiusValue = 0;
|
|
|
|
|
|
togglePoints.checked = true;
|
|
|
}
|
|
@@ -649,8 +670,13 @@ var dataArray;
|
|
|
|
|
|
|
|
|
|
|
|
+// get_data('2330近兩週收盤價');
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
function generateChart(dataArray) {
|
|
|
- if (dataArray.length > 10) {
|
|
|
+
|
|
|
+ if (dataArray.length > 15) {
|
|
|
lineYfontSize.style.display = 'none'
|
|
|
} else {
|
|
|
lineYfontSize.style.display = 'block'
|
|
@@ -1473,6 +1499,9 @@ function getDatalabelsConfig(isEnabled) {
|
|
|
} : null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// 版型一折線圖
|
|
|
// // 创建 Chart.js 图表
|
|
|
function createChart(chartType, data, labels) {
|
|
@@ -1487,13 +1516,15 @@ function createChart(chartType, data, labels) {
|
|
|
|
|
|
if (data.length < 15) {
|
|
|
pointRadiusValue = 5;
|
|
|
- pointHoverRadiusValue = 8;
|
|
|
+ pointHoverRadiusValue = 0;
|
|
|
|
|
|
togglePoints.checked = true;
|
|
|
toggleValue.checked = true;
|
|
|
|
|
|
|
|
|
} else {
|
|
|
+ pointRadiusValue = 0;
|
|
|
+
|
|
|
togglePoints.checked = false;
|
|
|
|
|
|
toggleValue.checked = false;
|
|
@@ -1520,7 +1551,9 @@ function createChart(chartType, data, labels) {
|
|
|
size: YfontSizeValue,
|
|
|
},
|
|
|
anchor: 'end',
|
|
|
- align: 'top'
|
|
|
+ align: 'end',//固定
|
|
|
+ offset: 5,
|
|
|
+
|
|
|
} : null;
|
|
|
|
|
|
|
|
@@ -1540,27 +1573,22 @@ function createChart(chartType, data, labels) {
|
|
|
pointRadius: pointRadiusValue,
|
|
|
pointBorderColor: '#fff',
|
|
|
pointBorderWidth: 3,
|
|
|
- pointHoverRadius: pointHoverRadiusValue,
|
|
|
+ // pointHoverRadius: 10,
|
|
|
fill: false,
|
|
|
backgroundColor: chartColor,
|
|
|
borderColor: chartColor,
|
|
|
+ hitRadius: 10,
|
|
|
// barPercentage: 0.5,
|
|
|
// categoryPercentage: 0.5
|
|
|
}]
|
|
|
},
|
|
|
options: {
|
|
|
|
|
|
- // responsive: true, // 啟用響應式
|
|
|
+ responsive: true, // 啟用響應式
|
|
|
maintainAspectRatio: false,
|
|
|
|
|
|
plugins: {
|
|
|
|
|
|
- chart3d: {
|
|
|
- enabled: true, // 啟用 3D 插件
|
|
|
- alpha: 25, // 圖表繞 x 軸的旋轉角度
|
|
|
- beta: 25, // 圖表繞 y 軸的旋轉角度
|
|
|
- depth: 15 // 圖表的深度
|
|
|
- },
|
|
|
datalabels: datalabelsConfig,
|
|
|
backgroundColor: 'transparent',
|
|
|
// datalabels: {
|
|
@@ -1593,11 +1621,12 @@ function createChart(chartType, data, labels) {
|
|
|
// anchor: 'end',
|
|
|
// align: 'end',
|
|
|
// } : null,
|
|
|
- customLabels: null,
|
|
|
+ // customLabels: null,
|
|
|
|
|
|
legend: {
|
|
|
display: false,
|
|
|
- fullSize: true
|
|
|
+ fullSize: true,
|
|
|
+ position: 'bottom',
|
|
|
},
|
|
|
|
|
|
},
|
|
@@ -1636,6 +1665,7 @@ function createChart(chartType, data, labels) {
|
|
|
},
|
|
|
},
|
|
|
ticks: {
|
|
|
+ padding: 10,
|
|
|
textStrokeColor: '#fff',
|
|
|
textStrokeWidth: 5,
|
|
|
font: {
|
|
@@ -1682,7 +1712,8 @@ function createChart(chartType, data, labels) {
|
|
|
|
|
|
colorInput.disabled = false; // 启用 colorPicker
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
|
|
|
},
|
|
|
});
|
|
@@ -1826,6 +1857,17 @@ toggleValue.addEventListener('change', function () {
|
|
|
|
|
|
});
|
|
|
|
|
|
+// 是否顯示x軸
|
|
|
+const toggleXAxis = document.getElementById('toggleXAxis');
|
|
|
+
|
|
|
+toggleXAxis.addEventListener('change', function () {
|
|
|
+ // 根据复选框的状态来显示或隐藏 X 轴
|
|
|
+ myChart.options.scales.x.ticks.display = this.checked;
|
|
|
+
|
|
|
+ // 更新图表
|
|
|
+ myChart.update();
|
|
|
+});
|
|
|
+
|
|
|
// 是否顯示單位
|
|
|
var toggleUnit = document.getElementById('toggleUnit');
|
|
|
|
|
@@ -1875,10 +1917,19 @@ var YfontSize = document.getElementById('YfontSize');
|
|
|
YfontSize.addEventListener('input', function () {
|
|
|
|
|
|
YfontSizeValue = YfontSize.value;
|
|
|
- if (myChart) {
|
|
|
- myChart.destroy();
|
|
|
- }
|
|
|
- createChart(chartType, data, labels);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const newSize = parseInt(YfontSizeValue);
|
|
|
+
|
|
|
+ // 更新 datalabelsConfig 的字体大小
|
|
|
+ myChart.options.plugins.datalabels.font.size = newSize;
|
|
|
+
|
|
|
+ // 更新图表
|
|
|
+ myChart.update();
|
|
|
+
|
|
|
+
|
|
|
+ // createChart(chartType, data, labels);
|
|
|
});
|
|
|
|
|
|
// ==========================
|
|
@@ -2163,7 +2214,9 @@ function get_data(input_text_value) {
|
|
|
source = cancelToken.source();
|
|
|
// inputField.value = "";
|
|
|
apiLoading();
|
|
|
+
|
|
|
var existingTable = chartJsBox.querySelector('table');
|
|
|
+
|
|
|
downloadButton.style.display = "none";
|
|
|
if (chartDiv.childElementCount != 0) {
|
|
|
data = [];
|
|
@@ -2207,9 +2260,12 @@ function get_data(input_text_value) {
|
|
|
|
|
|
console.log(response);
|
|
|
|
|
|
+ // console.log(response.data.chart_info === undefined);
|
|
|
+
|
|
|
|
|
|
- if (response.data.data == "未達相似度搜尋標準") {
|
|
|
- alert('無法生成圖表')
|
|
|
+ if (response.data.chart_info === undefined) {
|
|
|
+ console.log(response.data.data)
|
|
|
+ alert(response.data.data)
|
|
|
return
|
|
|
} else {
|
|
|
unit_value_box.style.display = "block";
|
|
@@ -2265,7 +2321,7 @@ function get_data(input_text_value) {
|
|
|
} else if (chartType === "doughnut") {
|
|
|
unit_value.textContent = "";
|
|
|
$('#textToChart').hide();
|
|
|
-
|
|
|
+ unit_value_box.style.display = 'none';
|
|
|
generatePieChart(dataArray, pieFontSize, PieMaxWidth)
|
|
|
} else {
|
|
|
unit_value_box.style.display = "block"
|
|
@@ -2940,3 +2996,8 @@ Object.defineProperty(obj, 'text', {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// sendButtonClickHandler(input_text_value);
|