[Bug]: Cannot import labels enum
See original GitHub issueContact Details
No response
What happened?
Typescript error
Type '"labels"' is not assignable to type 'ScaleTypes'
And if I try to import it I get a different error:
import { ScaleTypes } from "@carbon/charts/interfaces/enums";
import * as EventEnums from './events';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:190:29)
at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Promise.all (index 0)
Version
“@carbon/charts-svelte”: “^0.54.0”
Data & options used
<script lang="ts">
// import { ScaleTypes } from "@carbon/charts/interfaces/enums"
import { BarChartSimple } from "@carbon/charts-svelte";
import "@carbon/charts/styles.min.css";
import "carbon-components/css/carbon-components.min.css";
</script>
<BarChartSimple
data={[
{ group: "Qty", value: 65000 },
{ group: "More", value: 29123 },
{ group: "Sold", value: 35213 },
{ group: "Restocking", value: 51213 },
{ group: "Misc", value: 16932 },
]}
options={{
title: "Simple bar (discrete)",
height: "400px",
axes: {
left: { mapsTo: "value" },
bottom: { mapsTo: "group", scaleType: "labels" },
},
}}
/>
### Relevant log output
```js
Error: Type '"labels"' is not assignable to type 'ScaleTypes'. (ts)
left: { mapsTo: "value" },
bottom: { mapsTo: "group", scaleType: "labels" },
},
### Codesandbox example
_No response_
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
enum — Support for enumerations — Python 3.9.14 ...
This module defines four enumeration classes that can be used to define unique sets of names and values: Enum , IntEnum , Flag...
Read more >How to Make SelectFields for Prisma enums in RedwoodJS
Cannot get values from the enum to make a select control because Redwood ... import { label } from 'src/lib/helpers' const getEnumValues ......
Read more >Dart How to get the name of an enum as a String
I need to get the name of the enum as a string such as can be done with Java but cannot. For instance...
Read more >[Django] #32460: TextChoices/IntegerChoices can not have a ...
import enum from django.db.models import TextChoices, IntegerChoices. class A(enum.Enum): label = "label". print("case A, builtin Enum ...
Read more >[JDK-8179419] Compilation fails for class that has inner enum ...
Type: Bug ... Compilation fails with "error: cannot find symbol" if you have the following ... 2. uses the enum values X by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m seeing this same issue with @carbon/charts-react.
@metonym you may be able to get away with applying
as any
to the labels field, like so:Hi @leetrout,
Pls let us know if @metonym’s proposed solutions solves this issue for you https://github.com/carbon-design-system/carbon-charts/issues/1255#issuecomment-1023867195
Closing for now, feel free to reopen with additional details 🙂