小编Yig*_*ong的帖子

如何在 ChartJS 中单击时获取活动标签元素?

我使用 ChartJS 创建了一个饼图。

现在我想创建一个单击处理程序,在其中我可以获取已创建的图表部分的标签和值。我该如何实现这一目标?

let my_chart = new Chart('tot_pop_chart', {
    type: 'pie',
    data: {
      labels: ['NSW', 'VIC', 'QSD', 'SA', 'WA', 'TAS', 'NT', 'ACT'],
      datasets: [{
          data: [1, 2, 3, 4, 5, 6, 7, 8],
          backgroundColor: ['rgba(63, 75, 59, 1)', 'rgba(242, 246, 208, 1)', 'rgba(197, 123, 87, 1)', 'rgba(118, 159, 182, 1)', 'rgba(58, 110, 165, 1)', 'rgba(88, 12, 31, 1)', 'rgba(157, 172, 255, 1)', 'rgba(122, 48, 108, 1)']
        }

      ]
    },
    options: {
      animation: {},
      plugins: {
        legend: {
          display: true, …
Run Code Online (Sandbox Code Playgroud)

javascript chart.js

4
推荐指数
1
解决办法
9700
查看次数

如何在整个数据框中搜索特定值并返回其列和行索引

在熊猫中,我想在整个数据框中搜索特定值并返回其行和列索引。

例如:

    apple pear orange banana
cat    1     2     3     4
dog    5     6     7     8    
fish   9     10    11    12
bird   13    14    15    16
Run Code Online (Sandbox Code Playgroud)

输入:10

输出:鱼,梨

python search dataframe pandas

2
推荐指数
1
解决办法
2573
查看次数

Haskell:为用户定义的类型定义 Show 函数,由“type”关键字定义

假设我有如下定义的类型 StrInt

type StrInt = (String, Int)

toStrInt:: Str -> Int -> StrInt
toStrInt str int = (str, int)
Run Code Online (Sandbox Code Playgroud)

我希望 Show 函数如下工作:输入:show (toStrInt "Hello", 123) 输出:"Hello123"

我试图定义 show 如下:

instance Show StrInt where
    show (str, int) = (show str) ++ (show int)
Run Code Online (Sandbox Code Playgroud)

但这给了我错误:

    Illegal instance declaration for ‘Show StrInt’
      (All instance types must be of the form (T t1 ... tn)
       where T is not a synonym.
       Use TypeSynonymInstances if you want to disable this.)
    In the instance …
Run Code Online (Sandbox Code Playgroud)

haskell

1
推荐指数
1
解决办法
89
查看次数

标签 统计

chart.js ×1

dataframe ×1

haskell ×1

javascript ×1

pandas ×1

python ×1

search ×1