Skip to content

Commit

Permalink
fix: resolve bar chart gap issue
Browse files Browse the repository at this point in the history
  • Loading branch information
x1uc committed Feb 17, 2025
1 parent 9f8f5de commit 2bb354e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion crawler/getSource.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var phoneBrands = map[string]string{
"努比亚": "努比亚",
"IQOO": "IQOO",
"Neo5": "IQOO",
"Android": "未知Android设备",
"Android": "未知Android",
}

// GetSource 获取手机品牌
Expand Down
30 changes: 15 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ import (
var limit int = 1000

var brandDict = map[string]bool{
"华为": true,
"小米": true,
"OPPO": true,
"Vivo": true,
"苹果": true,
"三星": true,
"魅族": true,
"真我": true,
"红米": true,
"一加": true,
"荣耀": true,
"中兴": true,
"努比亚": true,
"IQOO": true,
"未知Android设备": true,
"华为": true,
"小米": true,
"OPPO": true,
"Vivo": true,
"苹果": true,
"三星": true,
"魅族": true,
"真我": true,
"红米": true,
"一加": true,
"荣耀": true,
"中兴": true,
"努比亚": true,
"IQOO": true,
"未知Android": true,
}

func main() {
Expand Down
12 changes: 9 additions & 3 deletions picexport/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"comment_phone_analyse/pojo"
"fmt"
"os"
"strconv"

"github.com/go-echarts/go-echarts/v2/charts"
"github.com/go-echarts/go-echarts/v2/opts"
Expand Down Expand Up @@ -31,10 +32,15 @@ func Export(uid string, phoneArr []pojo.StatisticsData) {

// 设置柱状图数据
bar.SetGlobalOptions(
charts.WithTitleOpts(opts.Title{Title: "Phone Type Statistics"}),
charts.WithXAxisOpts(opts.XAxis{Name: "Phone Type"}),
charts.WithTitleOpts(opts.Title{Title: ""}),
charts.WithXAxisOpts(opts.XAxis{
Name: "Phone Type",
AxisLabel: &opts.AxisLabel{
Interval: strconv.Itoa(0), // 确保每个柱子都显示 X 轴标签
},
}),
charts.WithYAxisOpts(opts.YAxis{Name: "Number"}),
charts.WithGridOpts(opts.Grid{Left: "10%", Right: "10%", Bottom: "10%", Top: "10%"}), // 设置图表区域的边距
charts.WithGridOpts(opts.Grid{Left: "10%", Right: "10%", Bottom: "15%", Top: "10%"}), // 适当增加底部边距
)
bar.SetXAxis(xLabels).AddSeries("Phone Count", yValues)

Expand Down

0 comments on commit 2bb354e

Please sign in to comment.